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

2322 Commits

Author SHA1 Message Date
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
Cyrill Gorcunov
24f33b86ea kernel: Add Ack and Review for a patch
So I wont forget.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-30 01:36:57 +04:00
Cyrill Gorcunov
5e2b5f098b kernel: Update kernel patches series
Tossing patches in git repo is a pure madness,
so stick back with quilt tool.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-30 01:13:38 +04:00
Cyrill Gorcunov
b8638a70ee Update README
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-30 01:11:00 +04:00
Cyrill Gorcunov
4dc0736697 dump,restore: Dump and restore vDSO area from userspace
There is no need to force kernel to remap vDSO area, we
can do that from the user-space as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-29 16:39:48 +04:00
Cyrill Gorcunov
f6ae59cdde test: Add trivial vDSO test
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-29 16:37:43 +04:00
Cyrill Gorcunov
3d55b9d125 dump: Drop VMA_DUMP_ALL flag
It has been used at very early stage when
no mincore call was implemented. Not needed
anymore -- so drop it out.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-25 18:39:58 +04:00
Cyrill Gorcunov
42a661f5e4 kernel: Update patch series
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-25 18:35:54 +04:00
Pavel Emelyanov
bb3d02c281 crtools: Take MINCORE_ANON pages into account
Reduce the pages-xxx.img file size significantly (from 2.1M to ~100K for simple counter test)
by not dumping private file pages, that have not yet changed from its file prototype.

If you'll have problems with it, just let me know and comment the definition of PAGE_ANON not
to block your work.

This uses the implemented earlier flag from mincore.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
2011-11-25 18:31:18 +04:00