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

3426 Commits

Author SHA1 Message Date
Andrey Vagin
e63f8c20e9 uts: don't use global fdset for dumping namespace
We are going to replace pid on id in names of image files. The id is
uniq for each namespace, so it's more convient, if image files are
opened per namespace.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:10:57 +04:00
Andrey Vagin
faf7b94868 netns: don't use global fdset for dumping namespace
We are going to replace pid on id in names of image files. The id is
uniq for each namespace, so it's more convient, if image files are
opened per namespace.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:10:45 +04:00
Andrey Vagin
762d932cbb namespace: open images per namespace to show them
It's preparation to replace pid on id in image names.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:10:13 +04:00
Andrey Vagin
b1b02fe676 images: split namespace contants per subsystems
Currently all values of constants should be continuous,
because cr_fdset_open is used for opening images for all namespaces.

The next patches will rework this code and image files will be opened
per namespace, then all these ugly settings of one constant to another
will be removed.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:10:07 +04:00
Andrey Vagin
8a23c3106d images: export cr_fdset_open
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 12:09:56 +04:00
Andrey Vagin
d92874697b zdtm: check, that stopped tasks are restored correctly
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 11:22:17 +04:00
Andrey Vagin
79d47a939d crtoools: add support of stopped tasks (v2)
Currently we catch processes on the exit point from sigreturn.
If a task must be restored in the stopped state, we can send SIGSTOP
before detaching from it.

v2: add more descriptive comment about skipping SIGSTOP in ptrace.c
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 11:21:34 +04:00
Pavel Emelyanov
2169020bea dump: Add comment saying why we dump zombies separately from alive tasks
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 11:17:28 +04:00
Andrey Vagin
ca3a23ec9c dump: transfer pstree_item in dump_task_core_all
Currently we take pid and core from it and we are going to take state.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-10-01 11:14:44 +04:00
Andrey Vagin
6b31a75a68 parasite: add a comment why we can safly trap task on sigreturn
The kernel notifies about leaving syscall before starting to deliver
signals. If you don't believe me, pls look at arch/x86/kernel/entry_64.S:

int_ret_from_sys_call
        syscall_trace_leave
        do_notify_resume

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-30 18:46:50 +04:00
Ruslan Kuprieiev
3f1aeb2c86 unix: SOCK_SEQPACKET
Everything in the sk-unix.c is ready for seq-packet sockets.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-30 18:44:57 +04:00
Pavel Emelyanov
d135ad3538 mnt: Collect mntns root from criu, in case we don't dump mount namespace
In case criu and dumpee live in the same mount namespace there's no
need in getting ns' root from init task. We can get it from criu and
(!) void the root == "/" check, required for namespace case.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-27 21:20:41 +04:00
Pavel Emelyanov
7576fa2bdf rst: Create posix timers earlier
No failures should occur after sigchld restore.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-27 21:08:02 +04:00
Pavel Emelyanov
aec951ec07 rst: Don't fail if task entries unmap fail
We cannot fail at that late stage, as everything is restored
and running. In the worst case (unmap fails) restored task would
have one extra mapping.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-27 17:04:20 +04:00
Pavel Emelyanov
f1edcb32f5 rst: Introduce fine-grained pgid-restore synchronization
We can restore task's pgid which is not equal to its pid,
only when the respective group leader is alive. To make
restore reliable we wait for all group leaders to restore
using separate restore stage.

It's better to optimize this -- each task has a pointer on
its group leader and waits for one to become such.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-27 04:38:00 +04:00
Pavel Emelyanov
656693503e zdtm: Check that out-of-root file survives
If a task opens a file, then goes chroot, CRIU should still
be able to dump and restore the now-invisible file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-25 14:15:31 +04:00
Pavel Emelyanov
2c6b61f122 zdtm: Test for chroot
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-25 13:59:23 +04:00
Pavel Emelyanov
c378f790b8 fs: Restore root
First of all, this should be done strictly after we've stopped accessing
files by their paths, even absolute. This place is right before going
into restorer.

And the second thing is that we want to re-use the open_fd_by_id engine,
since it handles various tricky cases of open-file-by-path. And since
there's no such thing as fchroot(int fd), we emulate it using the
/proc/self/fd/ links.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-25 13:59:20 +04:00
Pavel Emelyanov
75b1d4a1e3 rst: Open sys.ns_last_pid before diving into restorer
We restore chroot before doing this, so if we might need to
open one, we may have no access to the /proc/... paths.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-25 13:59:17 +04:00
Pavel Emelyanov
cd19b2fe25 fs: Reshuffle prepare_fs code flow
Make it ready for root dir restore:
* fix comments
* rename variables
* tune error paths

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-25 13:59:15 +04:00
Pavel Emelyanov
fe3fb8851e tcp: Support CORK and NODELAY options
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-25 11:43:02 +04:00
Pavel Emelyanov
4b6e1d6dc0 unix: Print sockets IDs in hex when collect skips them
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-25 11:40:40 +04:00
Pavel Emelyanov
3ebb368299 unix: Print "socket not found" error message on dump
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-25 11:39:54 +04:00
Alexander Kartashov
8f74187af1 arm: don't use the register R12 in the routine syscall_common()
The register R12 has a special meaning when syscalls are hooked
with ptrace() in ARM that results in a dumpee context corruption
on an injected blob unmap. Note that this patch doesn't solve
the problem entirely since the compiler may corrupt the register
before issuing a call to the routine sys_munmap(); however
we assume that a sufficiently decent compiler doesn't.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Tested-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-26 15:56:35 +04:00
Pavel Emelyanov
4e2031ca64 show: Don't print out-of-buffer-range symbols
The print_data helper may access symbols beyond the buffer
range and would thus print trash.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-19 13:30:12 +04:00
Pavel Emelyanov
255d985174 show: Put printing xdigits and symbols in helpers
This is preparation for the next patch.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-19 13:28:40 +04:00
Pavel Emelyanov
360c1c13b2 tcp: Show tcp queues contents when requested
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-19 12:16:07 +04:00
Pavel Emelyanov
008d3a9898 show: Show (lost) mm-*.img image files
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-19 12:03:10 +04:00
Pavel Emelyanov
057adb4cdc zdtm: Check that O_APPEND is preserved properly
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-19 10:45:36 +04:00
Ruslan Kuprieiev
3c0ea1c9ca test: rpc: test.py
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-24 11:36:17 +04:00
Ruslan Kuprieiev
6c718214df test: rpc: test.c
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-24 11:36:15 +04:00
Ruslan Kuprieiev
8a200fd651 test: rpc: run.sh
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-24 11:36:14 +04:00
Ruslan Kuprieiev
4a856a5b0f test: rpc: Makefile
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-24 11:36:13 +04:00
Pavel Emelyanov
8708c2d2db help: Add info about --pidfile works for service and page-server
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-24 11:33:36 +04:00
Ruslan Kuprieiev
3f9478d68c service: check errors of xmalloc
Original-patch-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-24 11:18:51 +04:00
Ruslan Kuprieiev
bc5828c111 service: don't leak a client socket if fork failed
Original-patch-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-24 11:17:33 +04:00
Andrey Vagin
c861f61e0c service: exit if accept() returned an error
I don't know a reason, when accept() fails once and then goes back to
normal work.

Cc: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-24 11:12:55 +04:00
Andrey Vagin
3477223068 service: set one exit point (v2)
v2: remove exit()

Cc: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-24 11:11:56 +04:00
Andrey Vagin
bf7c171a8b arm: mark the "[vectors]" vma as VMA_AREA_VSYSCALL
This vma looks like VSYSCALL on x86. We don't need to dump and restore it.

Currently this vma is dumped and restored as a private vma, but it is not
remmaped in a correct place:
Restore
 --- dump/pipe00/6392/1/dump.maps	2013-09-23 12:49:19.436816192 +0000
 +++ dump/pipe00/6392/1/restore.maps	2013-09-23 12:49:20.276766356 +0000
 @@ -6,5 +6,6 @@ e05000-e26000
  4009d000-4009f000
  400a0000-400aa000
  400b8000-401e7000
 +b6d6f000-b6d70000
  be838000-be859000
  ffff0000-ffff1000
ERROR: Sets of mappings differ:

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-23 17:51:46 +04:00
Andrey Vagin
1dd4810af1 zdtm: check that pending signals are handled after resuming processes
This patch detects the race, when a signal hanler could be executed
during restore.
More details are in: 5d18eca restorer: Block signals early

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-23 15:25:17 +04:00
Andrey Vagin
4c52aaf441 zdtm: check that a process has the same set of VMS-s after restore
Some VMA-s can be merged on restore. For example, If a process maps
VMA1, VMA2 and then VMA3 between the previous ones.
|VMA1|VMA3|VMA2|
The VMA3 will be merged only with VMA1, but all three VMA-s will be
merged on restore, because they are mmaped in a correct order VMA1,
VMA3, VMA2.

Due to this issue, we have a small script for merging continuous VMA-s.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-23 15:23:12 +04:00
Andrey Vagin
e1e1034786 restorer: rework unmaping old VMA-s (v3)
All process VMA-s are in "premmaped area". All restorer stuff are in
bootstap "area", so we have two areas.

So we don't need to unmap extra VMA-s one by one. We can call munmap
three times for the region before the first area, for the hole between
areas and for the region after the second area.

The old scheme didn't work, because the list of VMA-s can be changed
after collecting. It can be due to memory allocations by libc or due to
increased stack.

v2: improve readability at the expense of beautiness
v3: print return code of munmap in error messages
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-23 15:23:11 +04:00
Andrey Vagin
c900bf74b0 parasite: unmap itself (v2)
This patch adds a new parasite command, which unmaps the parasite blob.
This command never returns and the criu process traps the target process
on the exit from the munmap syscall.

v2: rename the function for unmaping a parasite blob to not intersects
with criu's functions.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-23 15:23:10 +04:00
Andrey Vagin
89d8b20186 restorer: unmap itself (v2)
This patch adds a function for removing the restorer blob. This function
never returns and the process must be trapped on the exit from the
munmap syscall.

v2: * release parasite_ctl sturcture and use the new interface of
      parasite_prep_ctl

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-23 15:23:09 +04:00
Andrey Vagin
66f21e6b71 restore: catch task on the exit from sigreturn (v4)
A task is stopped here for unmaping restorer blob and restoring a state.

The method is the same as for parasite. CRIU attaches to processes via
ptrace and start to trace all syscalls.

v2: don't use a software breakpoint
v3: stop all thread on the exit from sigreturn
v4: attach to each thread
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-23 15:23:08 +04:00
Andrey Vagin
f43ac0643e restore: save a task state on pstree_item
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-23 15:23:07 +04:00
Andrey Vagin
5273ae9036 pstree: initialize real pid to -1 for threads on restore
We are going to check is it valid or not.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-23 15:23:05 +04:00
Andrey Vagin
dbd41b522f proc: allow parse_thread to use an existent buffer
parse_thread allocated a buffer for threads and then it initialized read
pid for each thread.

Now we want to use it on restore and in this moment we already have
a buffer with initialized virt pid-s, so we need to initialize read
pid-s only.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-23 15:23:04 +04:00
Andrey Vagin
3e5ad587f4 parse_proc: move parse_threads from cr-dump.c
It will be used in cr-restore.c for stopping threads on the exit from
sigreturn.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-23 15:23:03 +04:00
Andrey Vagin
b65ba9a8d6 parasite: add a function for unmaping bootstrap blob
The munmap syscall must be executed from a process memory. The code can
be injected in memory and then removed. But we can avoid all these
actions, if the code will be in the blob and a process will be trapped
on the exit from the munmap syscall.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-23 15:23:02 +04:00