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>
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>
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>
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>
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>
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>
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>
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>
@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>
* 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>