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

1830 Commits

Author SHA1 Message Date
Andrey Vagin
650318f4b2 crtools: add options to specified a log file
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-08 18:55:13 +04:00
Andrey Vagin
ecc2776fc9 pipe: fix deadlock
Probably all of you know about "lock inversion". There was a similar
problem on restoring pipes.

One process try to restore pipe1 and waits when another process attached
to it.  In this time another process restores pipe2 and waits too.

I know two solves.
1. Open all pipes -> attach to them -> close unnecessary ends.
This method has a problem, if only one end belongs to the process.  In
this cases another end occupies a descriptor, which may be needed to
another pipe.

2. Restore pipes in the same order. This patch does that.
A sorted list of pipe entries are constructed.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelianov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-08 17:17:04 +04:00
Andrey Vagin
c53972cdc0 pipe: change calculation of pipes users
This patch removed stange logic about minusers.
Now we calculate foreign users only.

The main idea of this patch, that we bind a pipe ends to correct
descriptos immediately.

When a process X creates a pipe, we have two cases:
1. Both ends belongs to this process. It's simple, we bind both ends
   to their descriptors and we go further.
2. Only one end of a pipe belongs to this process. In this case we are
   waiting all foreign users and we go futher.
In second case we should wait, because a end which doesn't belong to
this process occupies a file descriptor, which may be used by another
pipe.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelianov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-08 17:17:00 +04:00
Andrey Vagin
4c479da259 Dump and restore current work directory (v2)
CWD is saved as file descriptor with number -1.

v2: use dump_regular_file

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-07 17:16:41 +04:00
Andrey Vagin
d261cf7958 Use absolute path for image files
Now I try to restore CWD and a relative path will be invalid.

Add new options -D to set image files directory.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-07 17:16:37 +04:00
Andrey Vagin
a5439d5fed zdtm: add new test case for "pipe inversion"
Probably all of you know about "lock inversion". We have a similar
problem on restoring pipes.

This test case creates two process and two pipes.
process 1:
	11: pipe1 (w)
	12: pipe2 (r)
process 2:
	11: pipe2 (r)
	12: pipe1 (w)

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-06 23:41:36 +04:00
Cyrill Gorcunov
d924a240ff make: Drop redundand dependency on parasite.h
There is no such file at all and it forced build
process to re-build every make command passed.

Reported-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-05 20:36:57 +04:00
Cyrill Gorcunov
f0b8a3a63b make: Drop restorer.o from program deps list
It's already in OBJS

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-05 16:38:08 +04:00
Cyrill Gorcunov
485c4b50d1 show: Rework show procedure
Added

 - ability to parse every single file crtools
   understands via magic number

 - dumped memory pages can be rendered in two
   modes -- as a simple set of pages' virtual addresses
   or in hexdummp fashion (via -c command line key).

For example

  ./crtools -s -c -f pages-2557.img

CR_FD_PAGES: pages-2557.img
----------------------------------------
    7fffb44ace20: 00 00 00 00 00 00 00 00  00 00 00 74 65 73 74 2f  |. . . . . . . .  . . . t e s t / |
    7fffb44ace30: 74 65 73 74 2d 73 69 67  61 63 74 69 6f 6e 00 48  |t e s t - s i g  a c t i o n . H |
    7fffb44ace40: 4f 53 54 4e 41 4d 45 3d  6c 6f 63 61 6c 68 6f 73  |O S T N A M E =  l o c a l h o s |
    7fffb44ace50: 74 2e 6c 6f 63 61 6c 64  6f 6d 61 69 6e 00 54 45  |t . l o c a l d  o m a i n . T E |

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-05 15:59:01 +04:00
Cyrill Gorcunov
c06227ff3b Add COPYING file
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-05 14:11:05 +04:00
Cyrill Gorcunov
da61f73263 dump: Test errors on xrealloc result
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2011-12-05 13:36:08 +04:00
Cyrill Gorcunov
29e66613cb dump: Drop redundant pr_debug
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-05 13:21:43 +04:00
Andrey Vagin
2c237b6973 Don't use standard descriptors for logging
The standard descriptors may be redirected.

crtool dumplicates stderr in rlimit.maxfileno-1 and this descriptor
is inherited by all children and will be closed before sigreturn.

Known issues:

 - The logging descriptor may be used by a target process and
   a resume will fail.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-05 12:07:52 +04:00
Andrey Vagin
e57a4c2945 Use stderr for debug messages (v2)
Many programs use stdout for transferring data.

v2: remove debug code

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-05 12:01:23 +04:00
Cyrill Gorcunov
53c611b630 dump,restore: Use rt_sigaction_t for sys_sigaction
Since we operate with syscalls directly we are
to convert signal's structures between image and
kernel formats, without intermediate glibc layer.

Note this involves chaging sa_entry::flags to u64
(since it's long int value in kernel).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-03 17:24:05 +04:00
Cyrill Gorcunov
8557e39bef test: Add sigaction test
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-03 01:48:57 +04:00
Cyrill Gorcunov
8a647a582e dump/restore: signals -- Use struct sa_entry for managing the signals
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2011-12-02 23:17:30 +04:00
Cyrill Gorcunov
9be4034048 image: Introduce struct sa_entry
It's needed to keep singnal handlers on
disk with predefined format.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2011-12-02 23:06:51 +04:00
Cyrill Gorcunov
2907bb2258 Move rt_sigset_t to include/types.h
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-02 23:03:03 +04:00
Pavel Emelyanov
ec8cdcd7cf crtools: Cleanup pstree entry code
After all the child/threads stuff is moved to helpers it is
possible to remove some unneeded code paths and local variables.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-02 18:39:35 +04:00
Pavel Emelyanov
8340bff864 crtools: Cleanup children stuff parsing
Move all the parsing of /proc/pid/children into a helper to be symmetrical
with the threads parsing.

Error from xrealloc is ignored as well.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-02 18:39:22 +04:00
Pavel Emelyanov
5e47e233df crtools: Cleanup threads stuff parsing
Move the whole code dealing with parsing threads at collect_pstree
stage into one function.

The nr_threads calculation is performed inside it based on the amount
of directories in /proc/pid/task, not the Threads: count in status.

Error from xrealloc is ignored by now.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-02 18:37:59 +04:00
Andrey Vagin
04f36aed0a Set descriptors to restart a current syscall
If a task is sleep in syscall, it should be restared.
This logic is moved from kernel do_signal().

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-02 17:50:55 +04:00
Andrey Vagin
5a49b9e216 zdtm: Zero Downtime Migration Test Suite
This test suite contains many small test cases for different subsystems.

Example of execution:
 # make busyloop00.pid
 # ../../../../crtools -d -t `cat busyloop00.pid`
 # kill -9 `cat busyloop00.pid`
 # ../../../../crtools -r -t `cat busyloop00.pid`
 # cat busyloop00.out
PASS

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-02 17:49:08 +04:00
Andrey Vagin
315b798182 Block all signals before sigreturn
sigactions are restored before memory and if a parent get a signal
which has a handler, it will get segmentation fault.

This problem will disappear, when we add a freezer, because
all processes will be resumed after restoring.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-02 16:11:41 +04:00
Andrey Vagin
cbb6b2da3d PROT_WRITE isn't need for a mapping of a file with MAP_SHARED
A file destriptor is opened for read-only and mmap with PROT_WRITE fails.
We don't need PROT_WRITE for this case, because a file contains up to date
data.

lr-x------ 1 root root 64 Dec  1 19:10 20 -> /usr/lib64/gconv/gconv-modules.cache
pos:    0
flags:    0100000
41155 mmap(0x7f2c3d6cf000, 28672, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, 20, 0 <unfinished ...>
41155 <... mmap resumed> )              = -1 EACCES (Permission denied)

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-02 15:43:48 +04:00
Cyrill Gorcunov
fa28f40aaa restore: Tune up the resident code to restore threads via last-pid concept
v2:
 - Pavel reported there is no need to lock/unlock
   last-pid file in cycle, just lock it once before
   threads creation and unlock at the end.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2011-12-02 13:41:34 +04:00
Cyrill Gorcunov
20b0e29698 syscall: Add sys_gettid helper
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-02 12:07:47 +04:00
Cyrill Gorcunov
b9febd52bc syscall: Add sys_flock helper
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-02 12:07:33 +04:00
Cyrill Gorcunov
8d36f08765 restore: Switch to the new ns_last_pid kernel facility while forking children
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2011-12-01 18:53:20 +04:00
Cyrill Gorcunov
762a5a16a7 kernel: Drop no longer needed CLONE_CHILD_USEPID functionality
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-01 18:51:56 +04:00
Cyrill Gorcunov
63fea93076 dump: Switch to /proc/$pid/children parsing to obtain children set
This also depends on kernel's inteface being changed,
so kernel/ is updated as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2011-12-01 18:51:40 +04:00
Andrey Vagin
baf69d6757 Don't overwrite sigaction magic
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2011-12-01 18:26:35 +04:00
Cyrill Gorcunov
9a544596fe Update README
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-01 11:16:37 +04:00
Cyrill Gorcunov
523cd85198 kernel: Add kernel.ns_last_pid control patch and update prctls
The patch "sysctl: Add the kernel.ns_last_pid control" is not
yet handled by crtools, still it's staged here to not loose
it and collect all Acks in place.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-12-01 00:08:01 +04:00
Cyrill Gorcunov
794b491a3d Fix potential memory leak in parasite_dump_sigacts_seized
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-11-30 23:44:15 +04:00
Cyrill Gorcunov
173c749da7 Fix potential memory leak in parasite_dump_pages_seized
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-11-30 23:37:37 +04:00
Cyrill Gorcunov
8324db69ee Fix comment on CR_FD_SIGACT
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-11-30 23:33:28 +04:00
Cyrill Gorcunov
5e829c8292 parasite: Unify error reporting scheme
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-11-30 22:57:36 +04:00
Cyrill Gorcunov
6661b555b9 dump: Don't forget to close opened file on error path
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-11-30 22:30:53 +04:00
Andrey Vagin
555efbb374 Set MAP_GROWSDOWN flag for stacks
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-11-30 22:04:29 +04:00
Andrey Vagin
146735f933 Dump direcory descriptor as a file descriptor
If I understand correct, they don't differ in linux.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-11-30 22:04:24 +04:00
Andrey Vagin
c04cffb7ce Restore pipe flags
pipe_loop00 passed with this patch.

When we restore a regular fd (not pipe) we do use flags
directly in open() call.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-11-30 22:04:20 +04:00
Andrey Vagin
6949e0f09f Dump memory character devices as a file.
It's work for /dev/zero, /dev/null and other simple devices.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-11-30 22:04:16 +04:00
Andrey Vagin
7553620298 Dump SigBlk instead of SigCgt
It's because this mask will be restored as rt_sigframe->uc.uc_sigmask.
uc_sigmask will be set as current->blocked in sigreturn, so we should
dump SigBlk in this case.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-11-30 22:04:12 +04:00
Andrey Vagin
25434884e1 Dump and restore sigactions (v2)
A parasite code dumps all sigactions in sigact.pid.

v2: remove hard code for sizeof(sigset_t)

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-11-30 22:04:09 +04:00
Andrey Vagin
287b7d2aa9 Generalization execution of parasite code.
It will be used for dumping sigactions too.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-11-30 22:04:05 +04:00
Andrey Vagin
bc1f9d728a Skip a standard destriptor only if it's tty (v2)
ZDTM tests redirect standart descriptors to /dev/null

v2: * Skip tty only if it's a standard descriptor.
    * No strcmps on names.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2011-11-30 22:04:00 +04:00
Cyrill Gorcunov
89dde261c2 kernel: Add rewviewed tag
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-30 10:07:10 +04:00
Cyrill Gorcunov
82fe01c35d kernel: Update prctl patch
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-30 01:41:43 +04:00