2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00
Commit Graph

3753 Commits

Author SHA1 Message Date
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
Andrey Vagin
6382ec4e66 parasite: prep_ctl doesn't search place for syscall if vma_list is NULL
This feature will be used for unmaping restorer blobs. All reqired code
will be in the blob.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-23 15:23:01 +04:00
Andrey Vagin
f9f690262c parasite: allow to wait more than one process on the exit from syscall
All processes must be started by PTRACE_SYSCALL. The function calls wait
in a loop and if a process on the exit from the required syscall, it
is stopped, otherwise it will be reexecuted by PTRACE_SYSCALL.

The function doesn't know, which processes should be trapped, so
you should care, that wait() will not catch someone else.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-23 15:23:00 +04:00
Andrey Vagin
833b1f950a parasite: stop task on exit from a specified syscall
This patch adds nothing new, just splits the existant function.

Currently a parasite stopped on sigreturn for unmaping a parasite blob.
The same scheme will be used for restorer blob and this function will be
used to stop on 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:22:59 +04:00
Andrey Vagin
5a37481914 restore: get real pid for each task (v2)
For the root task the clone syscall returns the pid in criu's pidns,
but for other processes the clone syscall returns PID in the restored
namespace.

The /proc/self link contains the PID value of the current process, so if
we want to determing the PID in a criu's pidns, we should use criu's
/proc.

v2: readlink() does not append a null byte to buf, so we must do that
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-23 15:22:58 +04:00
Andrey Vagin
5649722388 restore: allocate pstree items from a shared pool (v2)
A pstree item will contain pid and state. Both these properties will be
determined after creating processes and will be used from the
controlling proces.

v2: fix the error path
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-23 15:22:57 +04:00
Pavel Emelyanov
bd90e9887c service: move worker's code in a separate function
Original-patch-by: Andrey Vagin <avagin@openvz.org>
Original-patch-by: Ruslan Kuprieiev <kupruser@gmail.com>

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-23 14:37:56 +04:00
Ruslan Kuprieiev
c90b58d855 service: change a few "puts" with "pr_perror"
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-23 14:31:29 +04:00
Andrey Vagin
5d18eca3d5 restorer: Block signals early
Otherwise threads can handle them before calling sigreturn with wrong (not
belonging to crtools, but to the target task) handers:

__export_restore_task				| __export_restore_thread

restore_finish_stage(CR_STATE_RESTORE);		| restore_finish_stage(CR_STATE_RESTORE);
sys_sigaction(SIGCHLD, &args->sigchld_act, ...) |
restore_signals()				|
	ksigfillset(&to_block);			|
	sys_rt_sigqueueinfo(sys_getpid(), ...); |
						| execute signal handler() <------ BUG !!!
						| restore_signals()
						|	ksigfillset(&to_block);

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-20 20:04:46 +04:00
Cyrill Gorcunov
c721a2751f net: Print link name when restore it
For debug purpose.

 | (00.013002)      1: Restoring link lo type 1
 | (00.013002)      1: Restoring netdev lo idx 1
 | (00.015002)      1: Restoring link venet0 type 4
 | (00.015002)      1: Restoring link eth0 type 2
 | (00.015002)      1: Restoring netdev eth0 idx 3

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-18 20:43:59 +04:00
Pavel Emelyanov
c59ba80335 nf: Use bool types for lock/unlock switch
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-18 00:00:26 +04:00
Andrey Vagin
522fa17071 iptables: use OUTPUT table to block locally-generated packet
We was going to block a connections in both directions (v0.6-97-g0a1b70b),
but both iptable rules are added in the INPUT table. It's wrong, because
the rule must be added to the OUTPUT table to block locally-generated packets

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-17 23:55:08 +04:00
Andrey Vagin
1fd180ca6c sockets: don't double buffer size for sockets
SO_SNDBUF and SO_RCVBUF sets a double input value, because
"Linux reserves half of te socket buffer for metadata."

So if a process is suspended/restored many times, a socket buffer
size is doubled on each iteration and in a one moment it is overflowed.
Very likely the program hangs in such situation, because the socket with
negative buffer size is unusable.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-17 22:46:55 +04:00
Alexander Kolesen
14f98abf8d Make gen-syscalls.pl compatible with perl < 5.13.2
An error occurs when trying to build crtools on ARM systems
with perl versions earlier than 5.13.2 due to lack of /r modifier.

% make
...
  GEN      arch/arm/syscalls.S
Bareword found where operator expected at arch/arm/gen-syscalls.pl line 8, near "s/.*include\///gr"
Bareword found where operator expected at arch/arm/gen-syscalls.pl line 10, near "s/.*include\///gr"
Bareword found where operator expected at arch/arm/gen-syscalls.pl line 13, near "s/.*include\///gr"
Bareword found where operator expected at arch/arm/gen-syscalls.pl line 16, near "tr/.-/_/r"
Bareword found where operator expected at arch/arm/gen-syscalls.pl line 17, near "tr/.-/_/r"
syntax error at arch/arm/gen-syscalls.pl line 8, near "s/.*include\///gr"
syntax error at arch/arm/gen-syscalls.pl line 10, near "s/.*include\///gr"
syntax error at arch/arm/gen-syscalls.pl line 13, near "s/.*include\///gr"
syntax error at arch/arm/gen-syscalls.pl line 16, near "tr/.-/_/r"
syntax error at arch/arm/gen-syscalls.pl line 17, near "tr/.-/_/r"
BEGIN not safe after errors--compilation aborted at arch/arm/gen-syscalls.pl line 60.
make[1]: *** No rule to make target `arch/arm/syscalls.S', needed by `arch/arm/syscalls.o'.  Stop.

Signed-off-by: Alexander Kolesen <kolesen.a@gmail.com>
Acked-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-17 22:45:45 +04:00
Pavel Emelyanov
44faa25d9d rpc: Mark that dump-resp restore is in the message
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-17 00:50:03 +04:00
Ruslan Kuprieiev
4eb2872b27 v2 crtools: write pidfile, when service/page server is run as daemon and "--pidfile" is set
When service/page server becomes daemon, we may need to know it's pid.

Signed-off-by: Ruslan Kuprieiev<kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-16 15:45:01 +04:00
Pavel Emelyanov
c6b79bd35f service: Don't forget to send dump-failed message
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-16 15:41:37 +04:00
Pavel Emelyanov
5f47e0a67f service: Simplify dump-responce sending
We need 2 parameters only to form it properly.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-16 15:40:04 +04:00
Pavel Emelyanov
e866b7c043 rpc: Split rpc req-s from rpc-resps
Now we don't have generic criu_msg thing -- instead, we have
explicit request (with per-type args) and explicit responce
(yet again -- with per-type args).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-16 15:36:12 +04:00
Pavel Emelyanov
d285be5ed7 rpc: Renumber dump-req fields
Put important things first, secondary last.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-16 15:23:00 +04:00
Ruslan Kuprieiev
98b5541492 v2 rpc: change some "required" fields to "optional"
The most of fields are to be changed to "optional", because they are
optional in fact.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-16 15:21:13 +04:00
Cyrill Gorcunov
551cd03290 version: Print git id if present
If criu is built from git repo print git commit id, convenient for debug.

For example

 | $ ./criu -V
 | Version: 0.7
 | GitID: 7985251

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-14 15:01:32 +04:00
Cyrill Gorcunov
5006ed5f7c version: Define version as a macro
Defining it as static char is a bad idea especially
if it get included and never used -- we will get
"unused" variable error.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-09-14 15:00:17 +04:00
Andrey Vagin
5aa409afcf crtools: handle -vv..vv propertly
-vv...v must increase logging level on a number of the 'v' symbols.

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