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

900 Commits

Author SHA1 Message Date
Kinsbursky Stanislav
acf604c60c restorer: close log file before detaching from crtools
v2: it's toom risky to jump to address equal to line numbet (there could be
valid executable code). So now jump is done to 0 address and %sp encodes line
number (32 most significant bits) and error code (32 least significant bits).

There is a race between log close by process being restoring and opened file
desctriptors check in zdtm test suite - crtools can exit and compare file
descriptors before detached restored process will perform all the rest tasks
(including close of the log) and execute final system call:

 |--- dump/sleeping00/8578/dump.fd        2012-02-20 14:31:31.246096000 +0300
 |+++ dump/sleeping00/8578/restore.fd     2012-02-20 14:31:31.418095999 +0300
 |@@ -1,4 +1,5 @@
 |
 | 0 -> /dev/null
 | 1 -> /dev/null
 |+1023 -> /root/crtools/test/dump/sleeping00/8578/restore.log
 | 2 -> /dev/null

The solution is to close log in restorer before final command received. But
this leads to another problem: we have to inform somehow about possible errors
afterwards This is done by forced segmentation fault and looks like this
(dmesg):

pipe00[4678]: segfault at 0 ip 00007f4c8ab77d02 sp 000002ed00000001 error 4

Where %sp encodes line number (32 most significant bits) and error code (32
least significant bits).

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-21 20:32:18 +04:00
Pavel Emelyanov
7f96ec68e2 show: Show blocked sigset
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-20 17:10:16 +04:00
Kinsbursky Stanislav
8c9c333eed restorer: Drop redundant sys_close
It's already closed in restore_mapping, just an unapplied
patch snippet from 389bd830f16203b7ac23b6eaf933b8a83b3ab1fd

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-20 15:33:13 +04:00
Kinsbursky Stanislav
69ac4cef83 restorer: make it 2 lines shorter
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-20 14:34:23 +04:00
Cyrill Gorcunov
c1aad883de zdtm: make zdtm to not fail if time changed in fd-list
In case if time is modified in ls -l output we should
not treat it as error, interrupting zdtm work

-lrwx------ 1 root root 64 Feb 17 14:52 0 -> /dev/null
-lrwx------ 1 root root 64 Feb 17 14:52 1 -> /dev/null
-lrwx------ 1 root root 64 Feb 17 14:52 2 -> /dev/null
+lrwx------ 1 root root 64 Feb 17 14:53 0 -> /dev/null
+lrwx------ 1 root root 64 Feb 17 14:53 1 -> /dev/null
+lrwx------ 1 root root 64 Feb 17 14:53 2 -> /dev/null

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-02-20 14:23:28 +04:00
Cyrill Gorcunov
e40d09d754 zdtm: Run crtools with debug logging mode
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-02-20 14:23:28 +04:00
Cyrill Gorcunov
68654479c6 crtools: Drop pr_debug from fdset ops
They are redundant, and simply overlog the output

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-02-20 14:23:28 +04:00
Cyrill Gorcunov
ef97467da9 log: Add log-levels
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-02-20 14:23:28 +04:00
Cyrill Gorcunov
fe99f501ef Move pr_ helpers to log.[ch]
This is a place where they should belong to.
util.c is too big already.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-02-20 14:23:28 +04:00
Cyrill Gorcunov
6a0b94e7d5 restore: Don't leak opened file descriptor in shmem_remap
Don't forget to close opened file in case of error.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-02-20 14:23:27 +04:00
Cyrill Gorcunov
85235af889 restore: Use %lx for map_files
map_files format defined as %lx-%lx in
kernel and while there should not be a
problem if it's written in %p-%p, still
better to be on a safe side and follow
kernel's notation.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-02-20 14:23:27 +04:00
Pavel Emelyanov
097bc0b967 dump: Collect mem+regs+sigmask atomically
The ptrace seize doesn't prevent signals from delivery. That said,
we should block the signals in the target task before dumping
anything which is signals-related, i.e. memory and registers.

But once we've blocked signals, we should dump registers before
unblocking them, since any postponed signal will screw things up.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-20 12:33:43 +04:00
Kir Kolyshkin
447388d79b open_proc() and friends: hide pid_dir
This patch tries to introduce lazy and hidden pid_dir support,
meaning one don't have to worry about pid_dir but the optimization
is still there.

The patch relies on the fact that we work with many /proc/pid files for
one pid, then for another pid and so on, i.e. not in a random manner.

The idea is when we call open_proc() with a new pid for the first time,
the appropriate /proc/PID directory is opened and its fd is stored.
Next call to open_proc() with the same PID only need to check that
the PID is not changed. In case PID is changed, we close the old one
and open/store a new one.

Now the code using open_proc() and friends:
- does not need to carry proc_pid around, pid is enough
- does not need to call open_pid_proc()

The only thing that can't be done in that "lazy" mode is closing the last
PID fd, thus close_pid_proc().

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-17 16:46:25 +04:00
Kir Kolyshkin
5661d806cb Move error reporting to inside open_proc and friends
...and make it correctly print the file name we were unable to open.
Also, error from fdopen[dir]() is now reported with file name as well.

Note that open_proc() and friends need to be macros in order for
pr_perror() to show actual file name and line number where error occured.

Historical note: the original version of this patch was way more radical,
changing openat() to open() and thus removing pid_dir (replacing with pid
when needed) and open_proc_dir(), changing openat() to open(). The word
from Pavel is he wants to keep the openat/pid_dir optimization because
it saves two dentry lookups in kernel code for each open(). Because of
this optimization (and desire to print correct file name in case
of error) we have to carry both pid and pid_dir everywhere.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-17 16:46:25 +04:00
Kir Kolyshkin
5434d99e9f parasite_infect_seized(): use open_proc_rw()
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-17 16:46:25 +04:00
Kir Kolyshkin
03294077af util.c: introduce open_proc_rw()
To be used by the next patch

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-17 16:46:25 +04:00
Kinsbursky Stanislav
389bd830f1 restorer: Don't close SYSV IPC vma fd
It's not a fd to open and map, but SYSV IPC id instead.
So don't close it - this may lead to unpredictable results
(in case of SYSV IPC id will match fd, opened by processes).

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-17 15:55:32 +04:00
Kinsbursky Stanislav
e1cac86bf8 restorer: Move vma flags ANON bit manipulations to restore_mapping()
This looks clearer, because this check has nothing with SYSV IPC
mappings. Also we don't modify the vma_entry itself anymore but
operate with local 'flags' copy.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
[gorcunov@: A few tune ups]
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-17 15:55:24 +04:00
Kinsbursky Stanislav
4fc8bb0a0e IPC: close image files after use
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-17 15:24:43 +04:00
Andrey Vagin
427349c737 zdtm.sh: clean up output
* Remove redundant messages
* Show which test will be executed

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-17 15:20:27 +04:00
Andrey Vagin
986fa1ab86 zdtm.sh: detect leaked descriptors
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-17 15:20:16 +04:00
Kir Kolyshkin
3116e3e930 dump_one_task(): do not leak opened pid_dir fd
Make sure we close it

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-17 10:46:37 +04:00
Kir Kolyshkin
ac5c297474 Makefile: test target should depend on crtools
Otherwise 'make test' fails on a clean tree because crtools is not built.

Side effect: if you have code modifications that are not yet compiled,
they will be compiled.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-17 10:44:02 +04:00
Cyrill Gorcunov
fb886b7de9 parasite: Print detailed error
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-16 22:05:55 +04:00
Cyrill Gorcunov
cf8b39d4aa util: Drop jerr macros
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-16 22:05:40 +04:00
Cyrill Gorcunov
dcb1cbfb82 Rework parasite code
- make control block to keep all information
   needed to run injected syscall and parasite
   blobs

 - add ptrace_swap_area helper

 - handle both parasite engine calls and injected
   syscalls by single __parasite_execute function

 - drop jerr() usage

 - bring back handling of inflight signals from
   original program inside parasite code

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-16 22:05:28 +04:00
Kinsbursky Stanislav
47ee1213f1 zdtm: add transition/ipc test to IPC ns tests list
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Andrey Vagin <avagin@gmail.com>
2012-02-16 18:13:49 +04:00
Kinsbursky Stanislav
a83b53d224 zdtm: transition/ipc test update
Added cloning to new IPC ns depends on built option.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Andrey Vagin <avagin@gmail.com>
2012-02-16 18:13:49 +04:00
Andrey Vagin
53ababc680 zdtm: print warning messages about test processes
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2012-02-16 18:13:25 +04:00
Kinsbursky Stanislav
63d10b6104 zdtm: add static/sem test to IPC ns tests list
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-15 13:33:46 +04:00
Kinsbursky Stanislav
f086010abd IPC: restore semaphores sets
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-15 13:33:46 +04:00
Kinsbursky Stanislav
4101487f87 IPC: show semaphores set
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-15 13:33:46 +04:00
Kinsbursky Stanislav
4141296ed7 IPC: dump semaphores set
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-15 13:33:46 +04:00
Kinsbursky Stanislav
90340f75ca IPC: remove prohibition of mapped shared memory segments migration
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-15 13:30:34 +04:00
Kinsbursky Stanislav
574302bf8d restore: support SYSV IPC vma
This patch introduces the following changes:
1) writing of shmid value into vma_area->fd instead of
   waiting for shared memory region is open by parent,
   reopen it and dump fd.
2) new syscall support: sys_shmat
3) use sys_shmat() to map memory region in restorer's
   mapping function if vma flag VMA_AREA_SYSVIPC is set.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-15 13:30:34 +04:00
Kinsbursky Stanislav
e967566565 restorer: move map code to separated function
SYSV IPC segment map will be added there in further patch in the series

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-15 13:30:34 +04:00
Kinsbursky Stanislav
a5c6c02f49 restore: shmid_id structure from find_shmem_id() function
Returning shmid value of not enough, because SYSV IPC shmid equal to zero is a
valid value.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-15 13:30:34 +04:00
Kinsbursky Stanislav
b3cfe73556 dump: support SYSV IPC vma
This patch introduces the following changes:

1) introduces new flag VMA_AREA_SYSVIPC to mark corresponding vma entries.
2) enhance task /proc/<pid>/maps parsing to obtain first 5 letters of mapped
   file. If device major file belong to ins equal to 0 (tmpfs) and it's name
   starts with "/SYSV", then this mapping is considered as SYSV IPC and
   corresponding vma entry status is updated with VMA_AREA_SYSVIPC flag.
3) omit dumping of mapping pages for SYSV IPC vmas.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-15 13:30:34 +04:00
Cyrill Gorcunov
40fc4d2122 Merge branch 'zdtm' of https://github.com/avagin/crtools
* 'zdtm' of https://github.com/avagin/crtools:
  zdtm: remove white spaces
  zdtm: transmit  to crtools dump
  zdtm: don't kill test processes in case an error
2012-02-15 11:59:45 +04:00
Andrey Vagin
9ad1de0a4f zdtm: remove white spaces
Signed-off-by: Andrey Vagin <avagin@gmail.com>
2012-02-15 10:51:57 +03:00
Andrey Vagin
3b2bc56e22 zdtm: transmit to crtools dump
This functionality is used to check that dump isn't destructive.

Signed-off-by: Andrey Vagin <avagin@gmail.com>
2012-02-15 10:51:52 +03:00
Andrey Vagin
9e41d474f3 zdtm: don't kill test processes in case an error
We want to have maximum info about an error.

Signed-off-by: Andrey Vagin <avagin@gmail.com>
2012-02-15 10:51:48 +03:00
Kir Kolyshkin
7c961a7b8f include/types.h cleanup: remove *_FILENO
These defines are already provided by unistd.h, and the only user
is log.c which already includes unistd.h.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-14 21:16:00 +04:00
Kinsbursky Stanislav
e999e9fa29 restore: fix "zobie" typo
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-14 21:13:33 +04:00
Kinsbursky Stanislav
9b73ad59e9 IPC: restore message queue
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-14 20:21:30 +04:00
Kinsbursky Stanislav
24c4381644 IPC: show message queue dump content
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-14 20:21:30 +04:00
Kinsbursky Stanislav
fa2ff60680 IPC: dump message queue
v2: New "MSG_STEAL" functionality is used

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-14 20:21:30 +04:00
Kinsbursky Stanislav
b60524abef zdtm: add static/msgque test to IPC ns tests list
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
2012-02-14 17:39:32 +04:00
Cyrill Gorcunov
c45e622480 Merge remote-tracking branch 'avagin/zdtm'
* avagin/zdtm:
  zdtm: transmit  to crtools dump
  zdtm: don't kill test processes in case an error
  zdtm: add static/shm test to IPC ns tests list
  zdtm: don't wait in IPC queue on message operations
2012-02-14 17:39:12 +04:00
Cyrill Gorcunov
293d999e4f parasite: Code grouping in parasite_infect_seized
- mmap_seized returns only NULL on error, drop
   redumdant test
 - setup control block in one group
 - no need for err_free label, xfree handles NULL easily
 - prepare registers for munmap_seized call on error path

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
2012-02-14 17:18:09 +04:00