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

2812 Commits

Author SHA1 Message Date
Pavel Emelyanov
757f9c570f page-read: New abstraction for restoring pages
Now we have 2 forms of storing pages -- legacy pages.img and
new pagemap + pages image. We'll have one more (ovz) and the
pagemap + pages will be stacked (snapshot restore). Thus it's
handy to have this as an page-reader object.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-12 19:45:12 +04:00
Pavel Emelyanov
eb5a378855 page-xfer: Write holes and non-holes in sorted way
The pagemap.img contains sorted iovs. Need to keep this array also
sorted even if holes are in there for simpler read on restore.

Separate ->write_hole callback since dump of hole and non-hole
will differ significantly.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-12 19:45:10 +04:00
Pavel Emelyanov
e5e537954c page-pipe: Support holes in page-pipe iov map
Holes are regions, that don't have pages in them (i.e. -- no
pages in pipes). These holes are in separate iovs array since
we should have straight arrays of iovs for non-holes, which is
in turd required to push it into vmsplice in _one_ chunk.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-12 19:45:07 +04:00
Pavel Emelyanov
6ff0edadcd img: Open images "at" functionality
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-12 19:45:03 +04:00
Andrey Vagin
82ac1ae325 zdtm: add fanotify00 in the default list
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-11 22:06:55 +04:00
Andrey Vagin
13a8e60bca cr-dump: collect mount points in the target namespace
Information about mount points is used for dumping fanotify.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-11 22:06:48 +04:00
Pavel Emelyanov
18dee445f5 tcp: Restore creds after turning off tcp repair mode
The tcp repair manipulations require CAP_SYS_NET_ADMIN on
a calling task. Thus, if the task to restore is run from
non-root user, the tcp socket repair off will fail, but
restoration wouldn't abort.

Fix this by moving creds restore after tcp restore finish.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-11 21:39:50 +04:00
Pavel Emelyanov
2ab06c9c5a tcp: Schedule tcp socket for repair-off with proper fd
The fd in -> open callback is temporary (the files restoring
engine will re-open one under some other fd). But since we
add this fd to future repair off, this off will fail working
on wrong fd.

Move scheduling for repair-off into port-open where the corrent
fd is known.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-11 21:10:37 +04:00
Alexander Kartashov
4498dffce3 zdtm.sh: fixed shared libraries retrieval
The pipe retrieving shared libraries the test depends on

ldd $test_path $ps_path | awk '/^\s/{ print $1 }'

doesn't actually produce any output so all NS tests fail
bacause the system linker fails to locate shared libraries
the test program depends on. This patch fixes the pipe
to retrieve the list of libraries properly.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-11 19:59:49 +04:00
Alexander Kartashov
91b48d1297 cr-dump.c: fixed a format string warning on ARM
Use a PRI* format specifier to convert an integer of known size
to a string.

Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-11 19:59:39 +04:00
Cyrill Gorcunov
3c3a249e29 test: zdtm -- Fix fanotify00 test
@mnt_id do change on remount so exclude it from
compare.

Reported-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Tested-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-11 19:58:40 +04:00
Andrey Vagin
d3975e4454 parasite: fix error paths in parasite_init
* Call restore_ns on error paths.
* Use close_safe for the socket, because it can be reused

CID 996194 (#1 of 3): Resource leak (RESOURCE_LEAK)
6. leaked_handle: Handle variable "rst" going out of scope leaks the
handle.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-11 19:57:46 +04:00
Pavel Emelyanov
64d039dc29 tcp: Print error reported from sys_setsockopt
We use pr_perror, but after direct syscall calling the
errno is not initialized (and in PIE it doesn't even exists).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-11 19:50:08 +04:00
Pavel Emelyanov
84a0cabbd5 log-simple: Fix off-by-one when printing numbers
And simplify the code at the same time.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-11 19:40:34 +04:00
Pavel Emelyanov
babc9c617c tcp: Print message when scheduling socket for repair off in pie
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-11 19:36:06 +04:00
Pavel Emelyanov
6948c4199c files: Print unsupported files' mode in %o format
The constatns are in octal in all headers.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-11 18:56:11 +04:00
Andrey Vagin
6a54f17411 zdtm: don't create loops of bind mounts
Before this patch crtools/test is bound to crtools/test/dump/crtools.XXXXXXX

It's a main reason why "make clean" deletes all content from crtools/test.

Always when you have a test bind mount. You have a test bind mount, when
a test is executed. You execute a test sometimes. So "make clean"
deletes all content sometimes;).

This patch fixes this problem.

Actually this patch fixes more significan problem. If / is a shared
mount (it's defult in FC19),
$ mount --bind crtools/test crtools/test/dump/crtools.XXXXXXX
will recursively copy all previous bind mounts.

E.g:

cd crtools/test
make -j 4
/dev/mapper/vg-lv_root /root/crtools/test/dump/crtools-root.b86wVA ext4 rw,relatime,data=ordered 0 0
/dev/mapper/vg-lv_root /root/crtools/test/dump/crtools-root.DMoEZv ext4 rw,relatime,data=ordered 0 0
/dev/mapper/vg-lv_root /root/crtools/test/dump/crtools-root.b86wVA/dump/crtools-root.DMoEZv ext4 rw,relatime,data=ordered 0 0
/dev/mapper/vg-lv_root /root/crtools/test/dump/crtools-root.oLnVTw ext4 rw,relatime,data=ordered 0 0
/dev/mapper/vg-lv_root /root/crtools/test/dump/crtools-root.DMoEZv/dump/crtools-root.oLnVTw ext4 rw,relatime,data=ordered 0 0
/dev/mapper/vg-lv_root /root/crtools/test/dump/crtools-root.b86wVA/dump/crtools-root.DMoEZv/dump/crtools-root.oLnVTw ext4 rw,relatime,data=ordered 0 0
/dev/mapper/vg-lv_root /root/crtools/test/dump/crtools-root.b86wVA/dump/crtools-root.oLnVTw ext4 rw,relatime,data=ordered 0 0
/dev/mapper/vg-lv_root /root/crtools/test/dump/crtools-root.7zQrDs ext4 rw,relatime,data=ordered 0 0
/dev/mapper/vg-lv_root /root/crtools/test/dump/crtools-root.oLnVTw/dump/crtools-root.7zQrDs ext4 rw,relatime,data=ordered 0 0
/dev/mapper/vg-lv_root /root/crtools/test/dump/crtools-root.DMoEZv/dump/crtools-root.oLnVTw/dump/crtools-root.7zQrDs ext4 rw,relatime,data=ordered 0 0
/dev/mapper/vg-lv_root /root/crtools/test/dump/crtools-root.b86wVA/dump/crtools-root.DMoEZv/dump/crtools-root.oLnVTw/dump/crtools-root.7zQrDs ext4 rw,relatime,data=ordered 0 0
/dev/mapper/vg-lv_root /root/crtools/test/dump/crtools-root.b86wVA/dump/crtools-root.oLnVTw/dump/crtools-root.7zQrDs ext4 rw,relatime,data=ordered 0 0
/dev/mapper/vg-lv_root /root/crtools/test/dump/crtools-root.DMoEZv/dump/crtools-root.7zQrDs ext4 rw,relatime,data=ordered 0 0
/dev/mapper/vg-lv_root /root/crtools/test/dump/crtools-root.b86wVA/dump/crtools-root.DMoEZv/dump/crtools-root.7zQrDs ext4 rw,relatime,data=ordered 0 0
/dev/mapper/vg-lv_root /root/crtools/test/dump/crtools-root.b86wVA/dump/crtools-root.7zQrDs ext4 rw,relatime,data=ordered 0 0

make -j 32 generates ~2^32 mounts.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-11 15:31:25 +04:00
Andrey Vagin
6a49f82fb6 mount: free all parts of mnt entries
mnt_entry contains a few strings and they should be release too

CID 996198 (#4 of 4): Resource leak (RESOURCE_LEAK)
20. leaked_storage: Variable "pm" going out of scope leaks the storage
it points to.

CID 996190 (#1 of 1): Resource leak (RESOURCE_LEAK)
13. leaked_storage: Variable "new" going out of scope leaks the storage
it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-10 01:26:59 +04:00
Andrey Vagin
edc865361e zdtm: print an error message and exit if exec failed
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-10 01:24:08 +04:00
Cyrill Gorcunov
4dac517b00 util: read_fd_link -- Drop redundant \n in pr_perror message
pr_perror adds \n on its own, fix this typo.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-10 01:23:15 +04:00
Cyrill Gorcunov
41b2b29edc files: Print resource IDs in hex format
We usually print resources IDs in hex format,
so fix the places where we don't (it confuses
otherwise).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-10 01:23:09 +04:00
Andrey Vagin
7d63375505 sk-packet: fix memory leak
CID 996188 (#1 of 1): Resource leak (RESOURCE_LEAK)
13. leaked_storage: Variable sd going out of scope leaks the storage it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-10 00:56:29 +04:00
Andrey Vagin
17e2daddf2 sk-tcp: fix memory leak
CID 996187 (#1 of 1): Resource leak (RESOURCE_LEAK)
10. leaked_storage: Variable "buf" going out of scope leaks the storage it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-10 00:56:20 +04:00
Cyrill Gorcunov
7c02f65b98 check: Drop \n from pr_perror
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-10 00:55:24 +04:00
Pavel Emelyanov
5cae819d8c img: Get rid of open_image_ro helper
O_RSTR flag should be used instead for regular open_image

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-09 19:22:21 +04:00
Pavel Emelyanov
ba0ed60368 dump: Reshuffle arguments for dump_task_mm
Will need vpid there soon, so switch to using ctl instead.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-09 19:21:23 +04:00
Pavel Emelyanov
2f7a7bbd8d mem: Use ctl's vpid, not the one from arguments
This saves some space on stack.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-08 17:59:29 +04:00
Pavel Emelyanov
fb9b0f500a parasite: Use struct pid on parasite_ctl
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-08 17:56:48 +04:00
Pavel Emelyanov
69db54d8d6 parasite: Fix regs restore message pid
We work on pid, not ctl->pid in that place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-08 17:52:32 +04:00
Pavel Emelyanov
64249d5a8a mem: Move memory dump routines from parasite-syscall.c into mem.c
There's going to be a LOT of code in there.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-08 17:39:21 +04:00
Pavel Emelyanov
e44f10a6b4 parasite: Externalize some parasite-executing fns
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-08 17:38:49 +04:00
Pavel Emelyanov
4edabd3d4f mem: Don't export parasite_mptotect_seized
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-08 17:28:30 +04:00
Cyrill Gorcunov
f6303de7ca sysctl: Don't forget to close fds
In case if openat/open call returned fd = 0,
don't forget to close it on routine exit,
ie just use close_safe macro.

Not a big deal since the descriptors get closed
once program finish execution but still.

#CID 996183 Resource leak

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-05 08:23:17 +04:00
Andrey Vagin
a520b1b8cd namespaces: close fd on the source netns in restore_ns
It's opened in switch_ns.

CID 996194 (#3 of 5): Resource leak (RESOURCE_LEAK)
11. leaked_handle: Handle variable rst going out of scope leaks the handle.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-05 08:22:36 +04:00
Andrey Vagin
055b937226 page-pipe: fix memory leak on error path
CID 996197 (#1 of 1): Resource leak (RESOURCE_LEAK)
8. leaked_storage: Variable ppb going out of scope leaks the storage it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-05 08:21:45 +04:00
Andrey Vagin
c518d47ad3 files-reg: don't forget to close fd in case of error
CID 996201 (#1 of 1): Resource leak (RESOURCE_LEAK)
9. leaked_handle: Handle variable "fd" going out of scope leaks the handle.

CID 996202 (#1 of 1): Resource leak (RESOURCE_LEAK)
6. leaked_handle: Handle variable "fd" going out of scope leaks the handle.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-05 08:21:30 +04:00
Andrey Vagin
510b0dacb4 cr-restore: fix error handling and memory leak in read_vma
CID 996203 (#1 of 1): Resource leak (RESOURCE_LEAK)
15. leaked_storage: Variable "vma" going out of scope leaks the storage it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-05 08:21:05 +04:00
Andrey Vagin
c9c1ec7b44 cr-dump: fix memory leak in fill_zombies_pids
CID 996204 (#1 of 1): Resource leak (RESOURCE_LEAK)
11. leaked_storage: Variable "ch" going out of scope leaks the storage it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-05 08:20:36 +04:00
Andrey Vagin
50e94780f4 cr-dump: core_entry_free should free core
CID 996205 (#1-2 of 2): Resource leak (RESOURCE_LEAK)
14. leaked_storage: Variable "core" going out of scope leaks the storage it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-05 08:19:47 +04:00
Andrey Vagin
30a7de3513 cr-dump: move core_entry_free closer to core_entry_alloc
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-05 08:19:24 +04:00
Andrey Vagin
5d244ca1bd cr-check: don't forget close a test socket
CID 996206 (#3 of 3): Resource leak (RESOURCE_LEAK)
8. leaked_handle: Handle variable "sk" going out of scope leaks the handle.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-05 08:19:05 +04:00
Andrey Vagin
4ef152447c proc_parse: allocate memory for the terminating null of the string
CID 996207 (#1 of 1): Out-of-bounds access (OVERRUN)
5. alloc_strlen: Allocating insufficient memory for the terminating null of the string.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-05 08:18:57 +04:00
Cyrill Gorcunov
9c3a88c7b1 mnt: Add simfs entry to a list of supported fs
simfs is used in OpenVZ containers, so lets understand it
and don't fail on its meeting.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:08:33 +04:00
Cyrill Gorcunov
396a08eb95 make: Don't generate tags/cscope for tools/ and test/
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:08:32 +04:00
Cyrill Gorcunov
c0771a01f6 arch: x86 -- Include only asm/int.h in fpu.h
No need to include all types here. And this allows
to reuse this header outside of crtools code.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:08:31 +04:00
Alexander Kartashov
4200d42ee6 session02: hard-code the value of the macro CLONE_STACK_SIZE
The macro PAGE_SIZE is declared in the following way in Debian:

 #define PAGE_SIZE               (sysconf(_SC_PAGESIZE))

that makes it impossible to use the macro as the size of
the array clone_args::stack since this generates the following error:

cc -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -iquote ../../lib/arch/arm/include -I../../lib   session02.c ../../lib/libzdtmtst.a   -o session02
session02.c:70:7: error: variably modified 'stack' at file scope

Cc: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:07:20 +04:00
Alexander Kartashov
3ca29f7046 sk-packet.c: fixed a format string warning on ARM
Use a PRI* format specifier to convert an integer of known size
to a string.

Cc: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Alexander Kartashov <alekskartashov@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:07:10 +04:00
Andrey Vagin
0b6548229a pstree: fix error handling
pstree.c:273:3: warning: Value stored to 'ret' is never read
                ret = 0;
                ^     ~

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:00:31 +04:00
Andrey Vagin
9f994b8179 files: handle errors from fcntl()
files.c:159:21: error: comparison of unsigned expression < 0 is always
false [-Werror,-Wtautological-compare]
        if (p->fown.signum < 0) {
            ~~~~~~~~~~~~~~ ^ ~

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2013-04-04 14:00:30 +04:00
Andrey Vagin
0ebc4f058c cr-restore: remove extra initialization of variables
cr-restore.c:1795:2: warning: Value stored to 'restore_task_vma_len' is
never read
        restore_task_vma_len    = 0;
        ^                         ~
cr-restore.c:1796:2: warning: Value stored to 'restore_thread_vma_len'
is never read
        restore_thread_vma_len  = 0;

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