2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 05:48:05 +00:00

407 Commits

Author SHA1 Message Date
Pavel Emelyanov
d20089fb32 dump: Merge thread and task parasite-core info dumping
There are parts dumping which is common to thread and task,
and this stuff is represented by parasite_dump_thread structure.

Merge this into parasite_dump_misc and facror out dumping code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-16 19:47:52 +04:00
Andrey Vagin
c2c44d5261 signals: dump alternate stack as misc parameters
The initilization stage is not good for that, because it can fail.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-16 17:24:16 +04:00
Cyrill Gorcunov
a18f28d61e restore: Set up zombie name on restore
Otherwise we lost 1:1 mapping between names being
dumped and what user sees after restore.

| 1455 pts/0    T      0:00          \_ ./crtools restore -t 1448
| 1448 ?        Ss     0:00          |   \_ ./zombie00 --pidfile=zombie00.pid --outfile=zombie00.out
| 1449 ?        Z      0:00          |       \_ [zombie00] <defunct>
| 1450 ?        Z      0:00          |       \_ [zombie00] <defunct>
| 1451 ?        Z      0:00          |       \_ [zombie00] <defunct>
| 1452 ?        Z      0:00          |       \_ [zombie00] <defunct>

https://bugzilla.openvz.org/show_bug.cgi?id=2635

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-12 18:12:12 +04:00
Andrey Vagin
5336bc13c6 dump: dump tid_addr_clear for thread leaders
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-10 18:05:27 +04:00
Pavel Emelyanov
5762076dbb dump: Factor out thread_core dumping
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-10 16:09:23 +04:00
Pavel Emelyanov
a04ccc22a0 dump: Remove unused arg from dump_task_core_all
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-10 16:06:08 +04:00
Pavel Emelyanov
ae25daf007 dump: Move dump_task_mm out of dump_task_core
Mm used to be in code, so the call was left in that place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-10 16:05:29 +04:00
Pavel Tikhomirov
9a9424ee10 posix-timer: Add dump functionality
Signed-off-by: Pavel Tikhomirov <snorcht@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-07-01 16:19:28 +04:00
Andrey Vagin
75a3932be6 dump: Return signal mask from parasite on initialization
This mask should be put into sigframe (used by parasite, coming
soon) thus we have to pull one from dumpee early.

Plus, check that signals are blocked for each thread separately

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 20:26:34 +04:00
Andrey Vagin
64ecb2746c dump: save registers when the task is already infected
Otherwise a task can start to handle a signal and registers can be
changed.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 19:28:34 +04:00
Andrey Vagin
9b656a47d0 dump: dumping signals when a task is stopped
Currently it's always stopped, but it will be changed, when a parasite
will be executed as a daemon.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 18:55:33 +04:00
Andrey Vagin
3f48f35bfd parasite: use transparent thread indexes
We have three arrays for thread related data: item->threads,
parasite_ctl->thread and tid_state in parasite.

With this patch a thread will have the same index in all arrays.
The zero index is used for a thread leader.

In this case we don't need to search thread_state in parasite.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 18:47:11 +04:00
Cyrill Gorcunov
0772e47511 pstree: Bind CoreEntry to pstree and fill it with registers early
When parasite daemon mode will be implemented we get deprived of ability
to fetch registers at the late moment of dumping as we were, thus just
bind CoreEntry to pstree item and allocate CoreEntry'ies for every
thread found, once process tree is in seized state.

Then immediately fill CoreEntry'ies with registers. We use prctl
opcode for that but fetch a complete set of registers including
FPU state, and convert them into protobuf format.

Zombie tasks remains untouched, we allocate CoreEntry for them
right at moment of dumping becuase we don't need registers there
to be written on disk.

This way get_task_regs no longer need parasite_ctl argument
and it's zapped.

Still parasite_ctl has own copy of general registers set but
this is because we need them to be in cpu native format unlike
ones kept in CoreEntry.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 18:42:11 +04:00
Cyrill Gorcunov
0ae67a7743 vdso: Escape double dumping of rt-vdso if proxy present
In case if we have created vdso proxy the rt-vdso should
not be dumped because it will be re-created on next restore
anyway. Thus with help of parasite service routine find
the rt-vdso and tear it off from VMAs list.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 13:27:20 +04:00
Cyrill Gorcunov
e44b3dbe84 vdso: Initialize vdso data on startup
During criu startup we need to fill symbol table of own
run-time vdso provided by the kernel. We will need this
data for vdso proxy.

Because this functions are not used in restorer code,
we move them out of PIE (since PIE code must remain
as small as possible).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-24 13:27:15 +04:00
Andrey Vagin
653053b40c proc: use vma flags for determing vmas with MAP_GROWSDOWN
When a kernel didn't show vma flags, we set MAP_GROWSDOWN for stack
vmas, but it's not reliable. E.g. thread stacks are mapped without
MAP_GROWSDOWN.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-21 19:03:57 +04:00
Cyrill Gorcunov
19ce784db5 dump: Add missing FD_PARMS_INIT assignments
struct fd_parms is reused for two calls, so don't
forget to initialize it before dump_one_reg_file
call.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-18 03:36:01 +04:00
Pavel Emelyanov
a533820b7e dump: Introduce the pre-dump action
With this action criu will seize tasks, grab all its memory into
page-pipes, rest dirty tracker and will then release them. Writing
the memory from page-pipes would occur after tasks are unfreezed
and thus the frozen time should become reasonably small.

When pre-dump is in action, the dirty tracking is forcedly turned
off as well as tasks are resumed afterwards, not killed, by default.

This is a prerequisite for iterative migration.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-14 12:00:40 +04:00
Pavel Emelyanov
b556f01be3 dump: Collect pstree IDs separately from pstree items
For pre-dump we won't need IDs, but will need items only,
thus make these two calls separate.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-14 11:44:36 +04:00
Pavel Emelyanov
c15d4ee66a dump: Cleanup dump_pages_seized arguments and declaration
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-13 14:09:19 +04:00
Pavel Emelyanov
d7e547dfb7 cr: Remove opts argument from cr_dump_tasks
Options are collected in global variable, no need to have them on stack.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-13 14:08:55 +04:00
Pavel Emelyanov
1e18128423 stats: Dump-time statistics
Basic timings for dump (freeze, frozen, mem dump).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-13 13:53:31 +04:00
Pavel Emelyanov
bd1d6186be stats: Write dump stats after dump is finished
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-13 13:51:53 +04:00
Pavel Emelyanov
5b343b40eb kerndat: Introduce the storage of kernel run-time info
One of such things we use right now is the device for anon shmem
mappings backing. In the furure this can be extended to check for
various kernel features.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-15 13:02:09 +04:00
Kir Kolyshkin
d90d4b1b88 Fix typos in log messages
Someone has to do it, right?..

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-15 12:46:25 +04:00
Andrey Vagin
13a8e60bca cr-dump: collect mount points in the target namespace
Information about mount points is used for dumping fanotify.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-11 22:06:48 +04:00
Alexander Kartashov
91b48d1297 cr-dump.c: fixed a format string warning on ARM
Use a PRI* format specifier to convert an integer of known size
to a string.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-11 19:59:39 +04:00
Pavel Emelyanov
ba0ed60368 dump: Reshuffle arguments for dump_task_mm
Will need vpid there soon, so switch to using ctl instead.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-09 19:21:23 +04:00
Pavel Emelyanov
2f7a7bbd8d mem: Use ctl's vpid, not the one from arguments
This saves some space on stack.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-08 17:59:29 +04:00
Pavel Emelyanov
fb9b0f500a parasite: Use struct pid on parasite_ctl
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-08 17:56:48 +04:00
Andrey Vagin
c9c1ec7b44 cr-dump: fix memory leak in fill_zombies_pids
CID 996204 (#1 of 1): Resource leak (RESOURCE_LEAK)
11. leaked_storage: Variable "ch" going out of scope leaks the storage it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-05 08:20:36 +04:00
Andrey Vagin
50e94780f4 cr-dump: core_entry_free should free core
CID 996205 (#1-2 of 2): Resource leak (RESOURCE_LEAK)
14. leaked_storage: Variable "core" going out of scope leaks the storage it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-05 08:19:47 +04:00
Andrey Vagin
30a7de3513 cr-dump: move core_entry_free closer to core_entry_alloc
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-05 08:19:24 +04:00
Pavel Emelyanov
75d8b81fd1 ipc: Check for IPC namespace to be dumped when such mapping is
If any task has a sysvipc mapping we should make sure, that the
ipc namespace is dumped as well. Otherwise after restore the task
will die.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 13:09:59 +04:00
Andrey Vagin
2020d3957e dump: prevent dumping if a session leader is outside of the current pidns
A parasite code returns zero sid for such cases.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-01 20:11:13 +04:00
Andrey Vagin
6ed19e31a7 dump: unprotect vmas for dumping content
VMA-s may be protected against read, so rights for such VMA-s should be
changed for dumping and protected back after dumping.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-30 00:17:03 +04:00
Pavel Emelyanov
87d0d61e41 lock: Show long option in log message about using one
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-27 20:17:59 +04:00
Pavel Emelyanov
cbf0ba9f48 inventory: Kill inventory.img file in case of failed dump
This will result in more sane error in case restore is launched
on such semi-complete images.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-27 16:16:25 +04:00
Pavel Emelyanov
c03a4c5801 msg: Make final dump/restore more descriptive
Currently dump silently terminates and restore emits some
meaning-less messages in either case. Make these important
messages more informative.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-27 16:06:26 +04:00
Pavel Emelyanov
7571ff69e1 collect: Properly report tasks collecting error
When we've failed to seize tasks we should report this error to the caller.

Reported-by: Kevin Wilson <wkevils@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-26 22:02:37 +04:00
Pavel Emelyanov
118526cc0a dump: Missing \n in pr_err message.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-26 19:49:18 +04:00
Pavel Emelyanov
21c663dc01 dump: Use pr_err when reporting error about locks in use and no -l option
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-26 19:27:43 +04:00
Andrey Vagin
ab65ba0afd crtools: dump pending signals (v4)
PTRACE_PEEKSIGINFO is used for received pending signals,
then all signal are sent back and saved in a image.

v2: rework according with the new kernel interface
v3: rework according with the newrest kernel interface
v4: fix error handling

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-25 23:43:37 +04:00
Pavel Emelyanov
213faeae6d mem: Introduce page server
The page server is a process, that is about to get pages over
the network and put them into pagemap- + pages- images. Right
now what it does is simply get the data and puts it into the
image files. When we have dirty set tracking in the kernel the
page server will have to collect "page changes" and properly
integrate them into images.

Running crtools with page server is like this:

dst_node# crtools page-server --port <port> -D dump/ ...
src_node# crtools dump -t <pid> --page-server --address <dst_node> --port <port> -D dump/ ...

After this images from dst_node/dump/ and src_node/dump/ should
be put into one place and tasks can be restored out of it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-14 18:16:44 +04:00
Pavel Emelyanov
8801f59615 mem: Protobuf format for page dumps
Since now we drain pages out of parasite, we can invent any format for
page dumps. Let is be ... prorobuf one! :)

Another thing to keep in mind, is that we're about to use splices and
implement iterative migration, so it's better to have actual pages be
page-aligned in the image.

And -- backward compatibility. That said the new format is:

1. pagemap-... file which contains a header (currently with a ID of
   the image with pages, see below) and an array of <nr_pages:vaddr>
   pairs. The first value means "how many pages to take from the
   file with pages (see below)" and the second -- where in the task
   address space to put them. Simple.

2. pages-... file which containes only pages one by one (thus aligned
   as we want).

This patch breaks backward compatibility (old images with pages wil
be restored and then crash). Need to do it before v0.5 release.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-14 18:16:41 +04:00
Pavel Emelyanov
4d0b24b52a vma: Keep track of lonest vma in list and sum of its lengths
I will have to push some sort of map of pages to dump into parasite.
For this, I need to have estimation of how much memory I'd need for
than in parasite args. These two values will help with it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-01 20:12:33 +04:00
Pavel Emelyanov
8fdc707084 vma: Helper, that checks whether vma is dumped via parasite
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-01 20:12:02 +04:00
Pavel Emelyanov
b71f9e80be vma: Introduce list-of-vmas object
Right now when we collect list of vmas we need to know the
number of elements in it. In the future I will need to know
more, so it makes sense to create a vmas-list object for it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-01 20:11:51 +04:00
Pavel Emelyanov
7a7506f615 fd: Dynamically allocate args for the array of fds to drain
Just make use of previous patch. The creds dumping args are tuned to
fit one page (minimal static args size).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-01 20:11:38 +04:00
Cyrill Gorcunov
55412e0d16 make: Use -iquote for headers lookup
Some of ours headers (such as syscall.h) are
clashes with system headers names. So we need
to be sure that the headers we include as

 | #include "something.h"

being searched in known place. In particular on
some machines it it already produced problems.

This btw revealved a problem in cr-dump.c -- we've
had #include <parasite.h> there. Fix it.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Tested-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-02-19 15:46:06 +04:00