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

542 Commits

Author SHA1 Message Date
Pavel Emelyanov
ec50a07727 ns: Add c/r for /proc/$pid/ns/$ids references
Based on work done by Cyrill Corcunov (many thanks for that).

In this commit we implement c/r for files which have opened
/proc/$pid/ns/$ids entries.

The idea is rather simple one

Checkpoint
==========

- Check if the file name is the one of known to be ns ref
- If match then write protobuf entry

Restore
=======

- Read all ns entries from the image
- When criu tries to open one we lookup over process
  tree to figure out which PID should be used in path
  and then just open it

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-18 04:00:05 +04:00
Pavel Emelyanov
e75148dc03 util: Move user-per-sec constant into util.h header
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-13 13:50:09 +04:00
Kir Kolyshkin
3e8b82d367 Change crtools to criu in comments
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-10 11:02:27 +04:00
Kir Kolyshkin
c19e62f87c Change crtools to criu in criu messages
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-10 11:02:20 +04:00
Kir Kolyshkin
00ab805b74 cr-restore.c: fix a typo in a comment
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-10 11:02:08 +04:00
Kir Kolyshkin
43ce038e6e criu dump: don't require -t
and warn if it is used.

v2: fix help text as well

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-08 13:41:42 +04:00
Cyrill Gorcunov
921dbf23de Don't use \Newline in pr_perror
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-05-02 22:44:24 +04:00
Andrey Vagin
15b64d12ca restore: use a correct object core for restoring fpu
tcore (per thread core) should be used here

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-29 18:40:39 +04:00
Andrey Vagin
ae729638ef restore: fix restoring signal blocking mask on arm
RT_SIGFRAME_UC(sigframe).uc_sigmask.sig = args->blk_sigset;

blk_sigset is u64, but uc_sigmask.sig has type ulong [2], so
only a part of mask is restore here.

This patch reworks restoring of blocking masks symmetrically to dumping
these masks.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Tested-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-29 16:36:04 +04:00
Andrey Vagin
a724acf571 restore: handle errors of setting credentials (v2)
v2: handle errors from setXids and securebits manipulations
    handle errors of restoring creds after finishing CR_STATE_RESTORE_CREDS,
    because a sigchild handler is already restored in this moment.
    Only the current process is killed in a error case.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-29 16:32:24 +04:00
Andrey Vagin
a34057c192 restore: add a synchronisation point after restoring credentials
For security reason processes can be resumed only when all
credentials are restored. Otherwise someone can attach to a
process, which are not restored credentials yet and execute
some code.

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

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-19 15:58:50 +04:00
Kir Kolyshkin
41c7ca8218 Fix typos in comments
This is less useful than fixing typos in output messages, but anyway.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-15 12:46:46 +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
Pavel Emelyanov
757f9c570f page-read: New abstraction for restoring pages
Now we have 2 forms of storing pages -- legacy pages.img and
new pagemap + pages image. We'll have one more (ovz) and the
pagemap + pages will be stacked (snapshot restore). Thus it's
handy to have this as an page-reader object.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-12 19:45:12 +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
Pavel Emelyanov
5cae819d8c img: Get rid of open_image_ro helper
O_RSTR flag should be used instead for regular open_image

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-09 19:22:21 +04:00
Andrey Vagin
510b0dacb4 cr-restore: fix error handling and memory leak in read_vma
CID 996203 (#1 of 1): Resource leak (RESOURCE_LEAK)
15. leaked_storage: Variable "vma" 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:21:05 +04:00
Andrey Vagin
0ebc4f058c cr-restore: remove extra initialization of variables
cr-restore.c:1795:2: warning: Value stored to 'restore_task_vma_len' is
never read
        restore_task_vma_len    = 0;
        ^                         ~
cr-restore.c:1796:2: warning: Value stored to 'restore_thread_vma_len'
is never read
        restore_thread_vma_len  = 0;

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:00:29 +04:00
Pavel Emelyanov
000404adad rst: Properly check si_code of sigchild
The CLD_XXX macros are not bit fields.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-27 17:27:36 +04:00
Cyrill Gorcunov
78ced79e15 caps: Print error message on size mismatch
So when we fail print error thus a user would know
where exactly it failed.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
CC: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-27 16:32:46 +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
Cyrill Gorcunov
e902861c08 restore: Unify exit() return code
Some exit()'s are called with exit(-1), some
are with exit(1). Use exit(1) everywhere for
consistency.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-27 15:52:20 +04:00
Pavel Emelyanov
421d46f79e pages: Accept pages images from versions v0.4 and below
After reworkring the way pagemap is stored the backward compatibility
was not preserved for patches simplicity. Time to return it back.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-27 13:12:02 +04:00
Andrey Vagin
04f8a1a53e sockets: restore netlink sockets
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-26 00:24:00 +04:00
Andrey Vagin
bc3089983a restore: collect signals from zombies (v4)
Each zombie sends SIGCHLD to parent. crtools restores all pending
signals, so all other signals should be collected.

Here is a problems, that signals SIGCHLD can be merged, but crtools
should be sure, that all signals are collected.

For that a zombie locks a global zombie_lock, which is released by
parent.

This operation should be done between CR_STATE_RESTORE and
CR_STATE_RESTORE_SIGCHLD.

Here is one more CR_STATE_RESTORE_ZOMBIES, whic is used for waiting all
zombies.

v2: clean up
v3: rework synchronization
v4: rework without additional CR_STATE-s

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-25 23:44:10 +04:00
Andrey Vagin
c2b081102b restore: read core.img before forking to know a child state
It's necessary to get a number of zombies.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-25 23:43:41 +04:00
Andrey Vagin
7a8729fff5 crtools: restore pending signals (v4)
Read siginfo-s from images and send them to itself by sigqueueinfo.

Thread signals cannot be restored in restore_thread_common, because
it blocks SIGCHLD, which used for error detecting.

v2: Don't remap task_args and thread_args
v3: fix error handling
v4: cosmetic clean up

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-25 23:43:38 +04:00
Cyrill Gorcunov
be2773660b restore: Validate page address in restore_priv_vma_content
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-25 17:43:07 +04:00
Cyrill Gorcunov
41192bbb33 restore: Return error instead of BUG_ON on image corruption
In case if there image corruption and page entry addres
is invalid -- exit out gracefully instead of BUG_ON hammer.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-25 14:48:55 +04:00
Cyrill Gorcunov
f81d009af8 restore: Add debug info on premapped VMA address
| Map 0x0000000000400000-0x00000000004a5000 0x0000000000000000 vma
| 	premap 0x0000000000400000-0x00000000004a5000 -> 00007f26eb898000

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-25 14:48:31 +04:00
Cyrill Gorcunov
b7960d7716 restore: Update error message in map_private_vma
"Can't fixup VMA's fd" is more understandable than plain
"Can't fixup fd".

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-21 00:44:33 +04:00
Alexander Kartashov
74053de77d cr-restore.c: fixed compilation errors on ARM
Use decode_pointer() to convert a virtual address into a native pointer.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-19 15:46:00 +04:00
Andrey Vagin
5f5306eda9 crtools: remove declaration of rt_sigset_t
Actually rt_sigset_t and k_rtsigset_t are the same

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-15 19:11:25 +04:00
Andrey Vagin
c776580dc0 restore: find VMA for each restored page
Otherwise ppage_bitmap and page_bitmap will be updated for wrong VMA

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-15 18:24:27 +04:00
Cyrill Gorcunov
4159cd5de6 cr-restore: Report the mem size if mmap failed
Without patch

 | Error (cr-restore.c:414): Unable to reserve memory: Invalid argument

with applied

 | Error (cr-restore.c:414): Unable to reserve memory (0 bytes): Invalid argument

more convenient for debugging.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-03-14 19:41:31 +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
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
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
Alexander Kartashov
a27f0e5cb0 cr-restore: align the stack on 8-byte boundary
The section 5.2.1.2 of the AAPCS says that the stack must be 8-byte aligned
and this rule is broken when the thread restore_task_with_children()
is forked by the function fork_with_pid() since the variable ca
and its field stack are likely to be 4-byte aligned.

This patch forces 8-byte alingment of the field cr_clone_arg::stack.
This made the following tests pass on ARM:
* static/shm,
* static/ipc_namespace.

Particulary the unaligned stack results in incorrect passing
of the 64-bit argument to the function snprintf() in the function
sysctl_write_u64().

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-29 09:21:46 +04:00
Andrey Vagin
ea767143f1 tty: require stdin to be a terminal only if shell_job is set
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-22 22:45:31 +04:00
Pavel Emelyanov
475bb1e775 rst: Evaluate per-task clone mask early
When we've read all pstree-items and their ids we
can get the desired clone-flags early and avoid all
these dances with flag calculations in fork_with_pid
and company.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-19 01:16:19 +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
Alexander Kartashov
b97e24e3fb cr: introduced the functions decode_pointer() and encode_pointer()
These functions are designated to convert a native pointer
to uint64_t used to store a virtual address in protobuf messages
and vice versa in a machine-independent way.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 11:41:43 +04:00
Alexander Kartashov
bde8beca71 cr: use uint64_t to represent a virtual address
The patch reverts the commit 58064d9b723bd5a5e5910ed752fb3b19cc962fa8.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-18 11:41:42 +04:00
Qiang Huang
4bf96b6680 crtools: restore flock&posix file locks
According to the file lock information from the image, we recall
flock or fcntl with proper parameters, so we can rehold the file
locks as we were dumped.
We only support flock and posix file locks so far.

Changelog since the initial version:
a. Use prepare_file_locks instead of restore function directly.
b. Fix some bugs.

Originally-signed-off-by: Zheng Gu <cengku.gu@huawei.com>
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-17 14:42:43 +04:00
Alexander Kartashov
3c16edc0bd cr: generalized format strings
This patch replaces the format specifier %ld with PRIx64
in the following places:

* the format string argument of the functions scanf() and printf(),
* in the macros GEN_SYSCTL_*_FUNC.

We need explicit specification of the integer size there.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-16 19:20:08 +04:00
Alexander Kartashov
d63ed7a443 x86: fixed the value of the macro TASK_SIZE to match the kernel one
This makes it possible to use TASK_SIZE instead of TASK_SIZE_MAX.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-16 19:10:58 +04:00
Andrey Vagin
e7189054d5 restore: close_old_fds after restoring namespaces
Restore of netns uses the file descriptor on the root netns. This
descriptor is opened before forking.
We can add one more service fd, but I think this approach is better.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-15 18:52:57 +04:00
Cyrill Gorcunov
b724096f0f fsnotify: Rename inotify files to fsnotify
We will be handling both inotify and fanotify
objects here thus to make less confusion rename
the files to fsnotify.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-01-15 18:34:26 +04:00