Commit graph

5574 commits

Author SHA1 Message Date
Pavel Emelyanov
505652ef86 page-server: Fine grained corking control (v3)
When live migrating a container with large amount of processes
inside the time to do page-server-ed dump may be up to 10 times
slower than for the local dump.

The delay is always introduced in the open_page_server_xfer()
when criu negotiates the has_parent bit on the 2nd task. This
likely happens because of the Nagel algo taking place -- after
the write() of the OPEN2 command happened kernel delays this
command sending waiting for more data.

v2:
Fix this by turning on CORK option on memory transfer sockets
on send side, and NODELAY one once on urgent data. Receive
side is always NODELAY-ed. According to Alexey Kuznetsov this
is the best mode ever for such type of transfers.

v3:
Push packets in pre-dump's check_parent_server_xfer too.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@odin.com>

Conflicts:
	include/util.h
	util.c
2015-11-11 19:13:57 +03:00
Pavel Emelyanov
2bf517ed75 criu: Version 1.7.2
Fixes for IPC in userns, venet C/R, socket buffers overflow
and unix sockets name off-by-one.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-28 10:30:29 +03:00
Andrew Vagin
a0e835fa1b socket: values of snd and rcv buffer should be divide into two
This values will be doubled in kernel to account for
"struct sk_buff" etc. overhead.

Currently criu restores snd and rcv buffer limits incorrectly,
they become bigger on each iteration.
$ ../crit show dump/zdtm/live/static/socket-tcp/6299/1/inetsk.img | grep buf
                "so_sndbuf": 2626560,
                "so_rcvbuf": 1060720,
                "so_sndbuf": 16384,
                "so_rcvbuf": 87380,
$ ../crit show dump/zdtm/live/static/socket-tcp/6299/2/inetsk.img | grep buf
                "so_sndbuf": 5253120,
                "so_rcvbuf": 2121440,
                "so_sndbuf": 32768,
                "so_rcvbuf": 174760,
$ ../crit show dump/zdtm/live/static/socket-tcp/6299/3/inetsk.img | grep buf
                "so_sndbuf": 10506240,
                "so_rcvbuf": 4242880,
                "so_sndbuf": 65536,
                "so_rcvbuf": 349520,

With-help-of: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-28 10:23:23 +03:00
Cyrill Gorcunov
2467a30fe2 net: Treat venet device as a separate complete device
When restoring venet device we need to restore its
index as well, which actually possible with new iproute2
package but the problem is that the index itself lays
inside image file. We could use crit tool to extract
it but this would slowdon procedure signifantly (need
to run python which would parse the image, or need
to pass the index into environmnet from inside of
the CRIU itself).

So lets do a trick and simply created venet device
inside container by criu itself (thanks we support
creating venet via netlink interface now).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@odin.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-28 10:23:12 +03:00
Andrew Vagin
8f0f75a6d6 ipc: save local user and group id-s for ipc objects
5468  semctl(0, 1, IPC_SET, 0x7ffd25bcb590) = -1 EINVAL (Invalid argument)

Reported-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-26 12:24:58 +03:00
Cyrill Gorcunov
4e99a6b542 sk-unix: Fix typo in name length estimation
Name with up to UNIX_PATH_MAX in length is
allowed value.

Reported-by: Nikita Spiridonov <nspiridonov@odin.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-26 12:24:40 +03:00
Pavel Emelyanov
61f37ab1fd criu: Version v1.7.1
Fixes in mounts, notifies and userns found while testing openvz

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-23 16:34:14 +03:00
Cyrill Gorcunov
8bcc219c87 sk-unix: Don't affect cwd for relative named sockets
When we restore sockets with relative names we change
current working directory into the one provided by
socket image data. This actually affects current
criu state because the rest of code doesn't know
about such tricks and may rely on working dir
consistency.

So remember the current working dir and restore it
back once socket cwd operations are complete.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-22 17:32:19 +03:00
Andrew Vagin
f4c0028e01 userns: print uid-s as unsigned values
Reported-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-22 17:21:23 +04:00
Andrew Vagin
6a400cd73a freezer: don't catch kernel threads
OpenVZ creates per-container kernel threads and they live in
container's cgroups. CRIU should skip these threads, it's impossiable to
get any state of them.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.org>
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-22 17:20:57 +04:00
Andrew Vagin
e36dbef13d restore: wait while processes are dying
If criu restore failed, criu should wait all processes because they
hold files, namespaces and other stuff that caller might want to
have released (in our case it was ploop device).

Here we do this only for cases when processes are restored in a pid
namespace. We'd like to do the same for non-ns case, but there's
no simple way to wait for a bunch of unconnected processes.

Another good side effect is that "Restoring FAILED." will be printed
at the end of the log (now after we kill init tasks still have time
to do smth and write log messages).

Cc: Nikita Spiridonov <nspiridonov@odin.com>
Reported-by: Nikita Spiridonov <nspiridonov@odin.com>
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-22 17:20:07 +04:00
Cyrill Gorcunov
275740a71e mnt: Export __open_mountpoint
We gonna need it for inotify handle testing.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-22 17:13:31 +04:00
Cyrill Gorcunov
78c72b62a0 fsnotify: Always provide the path for inotify watchees
In debian-8 container we faced the problem -- systemd creates nested
mount namespaces and inotify watchee are resolved into a path which
is inaccessbile on restore, the same happens when pathes where
watchees are living are bind-overmounted. Thus when we try to
restore such watchees we can't open the paths.

Lets do a trick here (thanks a huge to Andrew Vagin for idea and
overall help) -- walk over all mount points which device match
the handle's device and open handle first and test if the path
provided is openable as well for tmpfs and devtmps which do not
save inodes between remounts. After all the inotify objects are
bound to inode so it's irrelevean via which path it's assigned.

https://jira.sw.ru/browse/PSBM-39957

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-22 17:13:26 +04:00
Andrew Vagin
d2762ddf77 mnt: Use ns_mountpoint to open a mount point
open_mountpoint helper is called when mount namespace are
already restored so we have to use local paths.

This is a continuation to patch a082f27b -- we keep mount
point id in fsnotify, thus we should use the namespace's
path for open.

https://jira.sw.ru/browse/PSBM-39957

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-22 17:13:21 +04:00
Andrew Vagin
00acf5228f fsnotify: save mnt_id with path
Otherwise it's impossible to understand from which namespace
this path should be opened.

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-22 17:13:15 +04:00
Andrew Vagin
dfef4e05d5 mnt: Fix slave mounts order estimation in can_mount_now
For slave mount we need to make sure that all childrent
mountpoints of the master peer is mounted before we can
proceed otherwise there gonna be duplicated mountpoints
after the restore.

https://jira.sw.ru/browse/PSBM-39957

Signed-off-by: Andrew Vagin <avagin@odin.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-22 17:13:08 +04:00
Cyrill Gorcunov
ad56fb3c81 mnt: Don't treat ns roots as special when restoring
Namespace roots might be slave ones from another
namespace roots, so we should not treat them as
"always ready" for mounting but rely on general
logic in can_mount_now which tests slaves relations.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-22 17:13:02 +04:00
Andrey Vagin
c3e88444d8 mount: use absolute paths for pivot_root
When we initialize a sub-mount namespace, we need to use absolute paths.
For example we change cwd in prep_unix_sk_cwd()

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-22 17:12:57 +04:00
Pavel Emelyanov
f1e8a9ce6b criu: Version 1.7
We have quite a lot of new stuff this time. More flexibility
in cgroup management code (and this story far from being over)
in the library and in the crit command line, preparations to
x66 32bit, that also helped the PPC port, freezer cgroup
filannly found its place in the code. We also had our first
CVE-s found :) and a LOT of bugs fixed.

So the plan for the 1.8 is: cgroups, secured containers and
bugfixes. x86 32bit is tempting too.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-07 12:26:32 +03:00
Cyrill Gorcunov
a85b54ab54 zdtm: Fix building for @_BSD_SOURCE redefinition
Travis testing engine complained about @_BSD_SOURCE
which is not the case on my build environment.
Anyway lets do a safe thing -- conditional definition.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-04 22:01:00 +03:00
Cyrill Gorcunov
eb02c8c1fd test: file_locks -- Use device from mountinfo for BTRFS
BTRFS uses own device numbering scheme so lets do a trick
close one to what we have in CRIU itself -- mangle
device to match mountinfo output.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@odin.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-04 19:36:27 +03:00
Cyrill Gorcunov
954ba48d1d zdtm: Add filesystem specific helpers
In particular we have to find out if we're
running on btrfs filesystem for proper device
number mangling.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@odin.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-04 19:35:59 +03:00
Andrey Vagin
ec31527be1 jenkins: include criu-lib.sh and call prep()
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-04 18:46:25 +03:00
Andrey Vagin
50d4d07367 netlink: increase the receive buffer size
Currently the buffer size is 4096. It always works because
we use hosts where PAGE_SIZE is 4096. PowerPC64 has a bigger PAGE_SIZE.

Here is a comment from the kernel code.
/*
 *      skb should fit one page. This choice is good for headerless malloc.
 *      But we should limit to 8K so that userspace does not have to
 *      use enormous buffer sizes on recvmsg() calls just to avoid
 *      MSG_TRUNC when PAGE_SIZE is very large.
 */

We set the buffer size to 16384, because it's the max length of recvmsg()
for this case. We will need less iterations to collect all data, so
the perfomance should be better.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Cc: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-04 18:26:51 +03:00
Cyrill Gorcunov
675a84fbc9 mount: Rename get_widest_peer to find_widest_shared
It lookups over shared entries and finds widest.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-04 18:23:41 +03:00
Cyrill Gorcunov
f7d550323b mount: Fix comment style
We don't use C99 comments.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-04 18:20:52 +03:00
Andrey Vagin
2971fb187f jenkins: add a script to execute tests on PowerPC
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-04 18:18:43 +03:00
Andrew Vagin
f20dfbdd95 zdtm: skip linux-vdso64.so when a new root is contructed
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-04 18:18:12 +03:00
Andrew Vagin
edd552619e zdtm: fix compilation on PowerPC
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-04 18:18:11 +03:00
Cyrill Gorcunov
eb6dcc4070 mount: Fix restore deleted bindmounts for regfiles
- make sure it doesn't exist using O_EXCL
 - don't forget to close it

Reported-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-02 18:51:01 +03:00
Pavel Emelyanov
92fcb8691b Fix compilation after previous commit
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-02 15:53:31 +03:00
Hui Kang
19dbe25918 Skip root cgroup directories when restoring with manage-cgroup=full
Signed-off-by: Hui Kang <hkang.sunysb@gmail.com>
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-02 15:40:59 +03:00
Cyrill Gorcunov
911bb68283 test: mntns_deleted -- Add bindmount for regular files
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-02 15:33:58 +03:00
Cyrill Gorcunov
d27f5391d5 mount: Handle deleted bindmounts for regular files
1) Deleted bindmount for files should be restored
   by creating temp file. The kernel doesn't permit
   to mix bindmount in terms of file/dir relationship:
   either both source and target should be files or
   directories.

   Thus we can call stat on the target and figure out
   what kind of source we had.

2) Even for deleted entries better to use permissions
   from the target's stat call, this makes result close
   to how would it look if program hadn't been checkpointed.

Reported-by: Andrey Wagin <avagin@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-02 15:33:46 +03:00
Andrew Vagin
bee835ebeb zdtm/file_locks01: fix testing devices
Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-02 13:18:28 +03:00
Andrey Vagin
4b0c0c5828 zdtm/file_locks03: don't use pipe for synchronization
Reported-by: Mr Jenkins
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-01 15:20:36 +03:00
Andrew Vagin
2ce6a6a2af file_locks02: don't use pipe for synchronization
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-01 13:14:06 +03:00
Laurent Dufour
f2bc172f67 ppc64: fixing build issue
The commit 69d008d567 ("Use run-time page_size() for mremap")
introduces the use of dynamic page size in rst-malloc.c.

The commit also add the include of unistd.h in
arch/aarch64/include/asm/page.h to allow the build to succeed on this
architecture.  Since ppc64 is also using the same way to deal with page
size, the same include is required in arch/ppc64/include/asm/page.h

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
CC: Christopher Covington <cov@codeaurora.org>
Reviewed-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-01 12:30:56 +03:00
Andrey Vagin
83f79c7e8c ptrace: print error code for PTRACE_DETACH
*** CID 139494:  Error handling issues  (CHECKED_RETURN)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-01 12:26:03 +03:00
Andrey Vagin
35ec944304 file: reserve one byte in a string buffer for the null byte
*** CID 139492:  Memory - illegal accesses  (BUFFER_SIZE_WARNING)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-01 12:25:39 +03:00
Andrey Vagin
f62fd61709 seize: fix used after free case
*** CID 139496:  Memory - illegal accesses  (USE_AFTER_FREE)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-09-01 12:25:33 +03:00
Andrew Vagin
8189eda7b9 zdtm/file_locks1: compare devices in addition to inodes
You can see two equal inode numbers with differen devices and
it was a reason why the test failed.

4: C: 12491/12495/12496
4: c: 1: POSIX  ADVISORY  WRITE 0 fc:03:12468 0 EOF
4: c: 2: POSIX  ADVISORY  READ  0 fc:03:12421 0 EOF
4: c: 3: POSIX  ADVISORY  WRITE 0 00:14:16285 0 EOF
4: c: 4: FLOCK  MSNFS     READ  4 fc:03:12496 0 EOF
4: c: 5: FLOCK  ADVISORY  WRITE 4 fc:03:12495 0 EOF
4: c: 6: FLOCK  ADVISORY  READ  4 fc:03:12491 0 EOF
4: c: 7: POSIX  ADVISORY  WRITE 0 00:14:16280 0 EOF
4: c: 8: POSIX  ADVISORY  WRITE 0 00:14:12677 0 EOF
4: c: 9: FLOCK  ADVISORY  WRITE 0 00:14:12520 0 EOF
4: c: 10: FLOCK  ADVISORY  WRITE 0 00:14:12495 0 EOF
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-08-25 16:01:40 +03:00
Andrey Vagin
439de67a4b test/rpc: don't use the shell_job option
It isn't required.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-08-25 16:00:37 +03:00
Andrey Vagin
5075f278f6 test/rpc: don't call criu_resp__free_unpacked for NULL
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-08-25 16:00:29 +03:00
Andrey Vagin
bba4000c40 test/rpc: import the errno module
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-08-25 16:00:20 +03:00
Andrey Vagin
31475ffa6d test/rpc: track changes of the criu binary
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-08-25 16:00:13 +03:00
Andrey Vagin
f837310e13 zdtm/fdt_shared: wait until children finish the preparation stage
Reported-by: Mr Jenkins
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-08-25 15:59:59 +03:00
Cyrill Gorcunov
e6e56a6294 test: mount -- Add simple testcase for deleted bindmounts
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-08-21 21:26:25 +03:00
Cyrill Gorcunov
80ef8fd2fb mount: Handle deleted bindmounts
To handle deleted bindmounts we simply create
the former directory bindmount lived at, mount
the target and remove the directory back.

For this sake we add @deleted entry into the image.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-08-21 21:26:17 +03:00
Cyrill Gorcunov
60f6ec7dd6 files-reg: Rework strip_deleted helper
Make it handle both postfixes and return
non-zero code if stipping happened.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-08-21 21:26:01 +03:00