2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-28 21:07:43 +00:00

446 Commits

Author SHA1 Message Date
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
Cyrill Gorcunov
03b95b5717 fpu: Move definitions to asm/fpu.h
The FPU data is quite CPU-type oriented,
thus move it to asm/fpu.h.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-02-18 18:42:08 +04:00
Pavel Emelyanov
c77e52992b locks: Move dump_task_file_locks into file-locks.c
Make all locks code be in one place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-02-08 02:58:10 +04:00
Pavel Emelyanov
2cdbeb4a11 files: Move dump_task_files into files.c
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-02-08 02:54:24 +04:00
Pavel Emelyanov
bd6a0b8919 files: Move do_dump_gen_file into files.c
It's a file dumping fn, it should be there.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-02-08 02:49:33 +04:00
Pavel Emelyanov
5d7cfa8fcf sk: Don't fail collect_sockets in non netns case
This is already so, just move the check for netns case
into collect_sockets. It knows it does so.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-25 15:20:38 +04:00
Andrey Vagin
d6ae662374 cr-dump: call stat for /proc/pid/fd/X directly
This patch can be committed instead of:
[PATCH 1/6] cr-dump: move parasite_drain_fds_seized out of dump_task_files
[PATCH 2/6] cr-dump: fix dumping file locks in a mount namespace

readlink is not required here and a file can be unavailable,
if a process is in another mnt namespace

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-21 17:34:27 +04:00
Pavel Emelyanov
7ee4c484ae dump: Fix dump_zombies declaration
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 23:34:30 +04:00
Pavel Emelyanov
ac845bd1d8 cr: Obsolete the --namespaces option
It's no longer required to use this option -- two currently
supported cases (tasks on host and tasks in containers) can
be detected automatically. Keep this option for future.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 13:25:16 +04:00
Pavel Emelyanov
2f22c68849 dump: Collect tasks' IDs early
It's required to know whether the root task lives in
namespaces very very early (e.g. -- to lock the network
properly). Thus we have to collect task IDs right at
the time we collect the tasks themselves.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 13:25:06 +04:00
Pavel Emelyanov
15999f6b2f ids: Split routine that dumps task's IDs
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 13:24:55 +04:00
Pavel Emelyanov
2105e18eee core: Save tasks' namespaces IDs in the ids image
The recent kernels allow to get namespaces IDs by reading proc-ns links.
Use this to generate IDs for tasks' namespaces (I do generate them, since
IDs provided by kernel look ugly :( ).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 13:18:33 +04:00