Commit graph

4924 commits

Author SHA1 Message Date
Saied Kazemi
54081aff7b tests: Pipe.c Test Program
Hi Saied,

This patch adds your test in the criu test system.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-10 18:52:23 +03:00
Andrey Vagin
e12fd8f98e zdtm/cwd00: avoid resolving an abs path
We may not have permissions for this.

Reported-by: Ruslan Kuprieiev <kupruser@gmail.com>
Cc: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-10 12:57:49 +03:00
Ruslan Kuprieiev
8f71344ce2 zdtm: add ip.dump and ip.rst to gitignore
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-10 12:55:27 +03:00
Saied Kazemi
0412152fc5 Add inherit fd support
There are cases where a process's file descriptor cannot be restored
from the checkpoint images.  For example, a pipe file descriptor with
one end in the checkpointed process and the other end in a separate
process (that was not part of the checkpointed process tree) cannot be
restored because after checkpoint the pipe will be broken.

There are also cases where the user wants to use a new file during
restore instead of the original file at checkpoint time.  For example,
the user wants to change the log file of a process from /path/to/oldlog
to /path/to/newlog.

In these cases, criu's caller should set up a new file descriptor to be
inherited by the restored process and specify the file descriptor with the
--inherit-fd command line option.  The argument of --inherit-fd has the
format fd[%d]:%s, where %d tells criu which of its own file descriptors
to use for restoring the file identified by %s.

As a debugging aid, if the argument has the format debug[%d]:%s, it tells
criu to write out the string after colon to the file descriptor %d.  This
can be used, for example, as an easy way to leave a "restore marker"
in the output stream of the process.

It's important to note that inherit fd support breaks applications
that depend on the state of the file descriptor being inherited.  So,
consider inherit fd only for specific use cases that you know for sure
won't break the application.

For examples please visit http://criu.org/Category:HOWTO.

v2: Added a check in send_fd_to_self() to avoid closing an inherit fd.
    Also, as an extra measure of caution, added checks in the inherit fd
    look up functions to make sure that the inherit fd hasn't been reused.
    The patch also includes minor cosmetic changes.

Signed-off-by: Saied Kazemi <saied@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-10 12:48:30 +03:00
Oleg Nesterov
0affd5bc19 criu/testing: caps00: don't hang if PR_CAPBSET_DROP fails
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-10 12:42:17 +03:00
Oleg Nesterov
40ae0fa35a criu: check: don't leak the child if PTRACE_ATTACH fails
PS: never ever use PTRACE_KILL.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-10 12:41:49 +03:00
Ruslan Kuprieiev
5d9c83cf88 arch:aarch64: add atomic_cmpxchg
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-08 15:55:55 +03:00
Ruslan Kuprieiev
3a2d171976 arch:arm: add atomic_cmpxchg
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-08 15:55:53 +03:00
Ruslan Kuprieiev
424162b075 arch:x86: add atomic_cmpxchg
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-08 15:55:52 +03:00
Andrey Vagin
4bca68ba49 tcp: don't split packets for restoring a send queue
The kernel can do it better. The problem exists only for recv queues.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-08 15:46:44 +03:00
Ruslan Kuprieiev
5ecb7b7ccd zdtm: don't forget to remove ip.dump and ip.rst when performing cleanup
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-08 15:45:46 +03:00
Vladimir Davydov
888cae434d zdtm/pty02: never close master before reading slave
We may close the master before reading the slave if the child runs first
when the parent wakes it up using task_waiter_complete. In this case the
subsequent read from the slave will return 0 resulting in a false
positive test failure:

13:23:42.194: 30914: ERR: pty02.c:89: read(slave) failed (errno = 11 (Resource temporarily unavailable))

Fix this by waking the child, which closes the master, only after the
read has been completed.

Also note errno = EAGAIN in the failure report above, which looks really
confusing. Let's print the actual number of bytes read/written along
with the errno while reporting a read/write failure to make the error
reporting clearer in this test.

Signed-off-by: Vladimir Davydov <vdavydov@parallels.com>
Cc: Cyrill Gorcunov <gorcunov@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Acked-by: Cyrill Gorcunov <gorcunov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-08 15:39:58 +03:00
Andrey Vagin
d64a49fdc6 zdtm/maps007: don't use signed values in calculations
maps007 segfaults on i386, because "size" is calculated bigger than allowed.

This occurs when the result of lrand48() * PAGE_SIZE is negative.
In this case the % operation returns a negative value too, what is unexpected.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-08 15:37:18 +03:00
Pavel Emelyanov
bda033e1e9 criu: Version 1.4
So, according to the recently accepted plan we have 1.4.

Biggest achievement here is that we've finally started with
user namespaces, fixed CRIU to work smoothly with the p.haul
project and optimized images and /proc files IO.

And a bunch of bugs, of course.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-01 15:50:35 +03:00
Andrew Vagin
50977c40a4 test: return the iteration number to the end of the test path
When we generate a path to the previous images, we take a directory name
and the previous iteration number.

Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-01 14:59:22 +03:00
Andrew Vagin
80ed2f3955 test: clean up pages immediately after restore
We see big load-avarage for the CRIU-iter job, because the host is
writing images for the maps04 test. If we will remove images after retore,
they will live in a page cache. Curretly we collect images for three
iterations and their size is too big to live in a cache.

[root@jenkins workspace]# time bash test/zdtm.sh  -i 3 ns/static/maps04
real	2m23.765s
user	0m0.719s
sys	0m4.006s
[root@jenkins workspace]# time bash test/zdtm.sh -C -i 3 ns/static/maps04
real	1m34.884s
user	0m0.200s
sys	0m4.191s

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-01 13:48:06 +03:00
Andrew Vagin
ef351aba03 test: use an origin test name to generate uniq name for test files
Currently ns/test and test may have the same test directory,
especially if zdtm.sh is executed with --ct.

Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-12-01 13:44:38 +03:00
Andrey Vagin
c7fafff448 jenkins: reduce number of jobs for executing tests
32 is too many for our test server

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-29 19:33:15 +03:00
Andrey Vagin
2559572a91 check: don't lead fd
CID 83243 (#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>
2014-11-29 19:33:00 +03:00
Andrey Vagin
71a0b5dc31 mem: check existence of parent images before dumping pages (v2)
When we are doing pre-dump, we splice pages in pipes and only then open
images and dump pages. But when we are splicing pages, we need to know
about existence of parent images. This patch adds a new call to determin
existence of parent images.

In addition this patch fixes a following issue:
CID 83244 (#1 of 1): Uninitialized pointer read (UNINIT)
14. uninit_use: Using uninitialized value xfer.parent.

v2: initialize unused field of struct page_server_iov, because it sends
in network.

CID 83451 (#1 of 1): Uninitialized scalar variable (UNINIT)
2. uninit_use_in_call: Using uninitialized value pi. Field pi.nr_pages
is uninitialized when calling write.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-29 19:32:40 +03:00
Andrey Vagin
0fc19cf7d2 tcp: don't fail if send eats only a part of data
For stream sockets it's possiable and we should not fail in this case.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-26 22:30:00 +03:00
Pavel Emelyanov
0c33452723 page server: Don't hide error from flush request
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-11-26 22:29:30 +03:00
vkonyashkin
6678fbb334 zdtm/inotify_system_nodel.c: need to print mask of events for UNKNOWN event
Need to print a mask of events for UNKNOWN event in inotify_system_nodel.c
and inotify_system.c tests. The current error message in this case is too vague:
inotify_system_nodel.c:266: got unexpected event UNKNOWN

Signed-off-by: vkonyashkin <vkonyashkin@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-19 13:18:50 +04:00
Cyrill Gorcunov
02b2f197ed check: Implement F_GETOWNER_UIDS
It is in mainline and required for proper CRIU work.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-19 13:17:45 +04:00
Pavel Emelyanov
199619791d mnt: Factor out find-mount-by-s_dev code
And move the 2nd piece lower to avoid fwd declaration and
keep similar calls close to each other.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-19 13:17:30 +04:00
Cyrill Gorcunov
b6c3270b2f scripts: Exit early if no scripts passed
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-14 15:51:28 +04:00
Andrey Vagin
61b8c9dac3 zdtm: execute mntns_shared_bind* only if mnt_id is in fdinfo
Reported-by: Mr Jenkins
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-13 15:53:18 +04:00
Andrey Vagin
f07e25c62b zdtm: add a test to check non-root shared bind-mounts
Here is an example from a fedora container:
65 64 252:0 /vz/private/1 / rw,relatime shared:29 - ext4 /dev/mapper/centos_pcs-root rw,data=ordered
77 65 252:0 /vz/private/1/var/tmp/systemd-httpd.service-XLnJPNc/tmp /var/tmp rw,relatime shared:41 - ext4 /dev/mapper/centos_pcs-root rw,data=ordered

We can see non-root shared mount, which is mounted to the root
mount from the same shared group. The test emulates this situation.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-12 12:55:17 +04:00
Andrey Vagin
104d3b84d5 mount: rework can_mount_now() to support bind-mounts of shared mounts
Fedora bind-mounts a part of the root mount to itself. Currently we
don't allow to mount children of a shared mount, if other mount from
this shared group are not mounted.

This patch adds an exclusion for cases, when a child has the same
group. We allow to mount a child, if wider mounts are mounted.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-12 12:54:39 +04:00
Andrey Vagin
beeabc3b2b mount: add the mnt_roots mount in the mount tree on restore
Currently we connect roots of sub-namespaces to the root of the root
mount namespace. And we get problems, if the root of the root mntns is
shared, because all children of a shared mount must be propagated to
other mounts in this group.

Actually we mount tmpfs in mnt_roots and here is nothing wrong to add it
in a tree.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-12 12:54:37 +04:00
Pavel Emelyanov
4e7064cd7e mount: Remove the len variable
And use the expression for it, it's quite short. This
makes the amount of variables in the code fit into brains.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-11-12 12:54:33 +04:00
Pavel Emelyanov
0fbee68f26 mount: Add helper for searching for shared peer
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-11-12 12:54:32 +04:00
Pavel Emelyanov
cedd10254c mount: Sanitize the path recalculation between submounts
Do paths conversions and checks step-by-step and add many comments
what we do in each step and why.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-11-12 12:54:31 +04:00
Pavel Emelyanov
991c02874a mount: Use pre-calculated ct->mountpoint + t_mpnt_l value
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-11-12 12:54:30 +04:00
Pavel Emelyanov
ffe5f9b422 mount: Use issubpath() when checking for submount visibility
When we check whether a submount of a mount is visible in another
mount (shared peer of the latter), we can and should use the new
issubpath helper.

Should because the used strncmp may scan beyond ct_mpnt_rpath if
its length is smaller (no checks for this in the code).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-11-12 12:54:29 +04:00
Pavel Emelyanov
e9512502d1 mount: Move some variables out of search loop
These are constant for given m, so calculate them outside
of the loop. Also rename them to reflect what they are.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-11-12 12:54:28 +04:00
Pavel Emelyanov
028d6355e6 mount: Rename paths' lengths to reflect whose lengths they are
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-11-12 12:54:27 +04:00
Pavel Emelyanov
6b0059049d mount: Add helper for path length calculations
The path lenght is zero for the "/" one and strlen(path)
for all the others. This is done so to make it possible
to use this length to get tail-paths: if path_1 starts
with path_2 and both are absolute, then

   path_1 + path_length(path_2)

would give the tail of the tail of path_1 relative to
path_2 even if the path_2 is just "/".

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-11-12 12:54:26 +04:00
Pavel Emelyanov
64c95bf586 mount: Add helper to search for widest shared peer
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-11-12 12:54:25 +04:00
Andrey Vagin
1cf5168cab mntns: rework validation to support non-root shared bind-mounts (v2)
A problem which is solved in this path is that some children can be
unaccessiable (unvisiable) for non-root bind-mounts

root	mount point
-------------------
/	/a (shared:1)
/	/a/x
/	/a/x/y
/	/a/z
/x	/b (shared:1)
/	/b/y

/b is a non-root bind-mount of /a
/y is visiable to both mounts
/z is vidiable only for /a

Before this patch we checked that the set of children is the same for
all mount in a shared group. Now we check that a visiable set of mounts
is the same for all mounts in a shared group.

Now we take the next mount in the shared group, which is wider or equal
to current and compare children between them.

Before this patch validate_shared(m) validates the m->parent mount.
Now it validates the "m" mount. So you can find following lines in the
patch:
-               if (m->parent->shared_id && validate_shared(m))
+               if (m->shared_id && validate_shared(m))

We doesn't support shared mounts with different set of children.
Here is an example of such case can be created:
mount tmpfs a /a
mount --make-shared /a
mkdir /a/b
mount tmpfs b /a/b
mount --bind /a /c

In this case /c doesn't have the /b child. To support such cases,
we need to sort all shared mounts accoding with a set of children.

v2: If root is equal to "/", its len should be zero. We expect that the
last symbol in a path is not "/".

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-12 12:54:21 +04:00
Andrew Vagin
022094db40 zdtm: typo fix
expr ns/user/static/env00 ns/user
expr: syntax error

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-11 20:21:08 +04:00
Cyrill Gorcunov
98d9264563 bfd: Use LOG_PREFIX
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-11 20:19:36 +04:00
Cyrill Gorcunov
88031bf89e proc_parse: Convert parse_pid_status to BFD engine
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-11 20:18:27 +04:00
Pavel Emelyanov
8f937e0461 zdtm: Don't test userns tests if no required APIs found
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-11 20:17:57 +04:00
Pavel Emelyanov
a7bfa05a21 collect: Rename children/threads collecting routines
Make their name look similar.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-11 20:16:43 +04:00
Pavel Emelyanov
ac1c74fc5b collect: Don't check for zombie before collecting
We have sanity check for zombie-with kids below, no
need in additional.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-11 20:16:29 +04:00
Pavel Emelyanov
8078e38774 collect: Factor out recurring collection of threads and children
We scan threads and children list several times while freezing
the tree, this is done to avoid race with new threads/kids
appearing.

Factor out the iterations code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-11 20:16:22 +04:00
Pavel Emelyanov
83df36e731 collect: Move parse_threads into collect_threads
To make the threads collect code be structured similar to
children collect. This will also help in further patching.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-11 20:16:13 +04:00
Pavel Emelyanov
13a628df95 collect: Clean children collect code variables usage
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-11 20:16:05 +04:00
Pavel Emelyanov
009c173be5 collect: Clean children and threads recurring collect checks
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-11-11 20:15:57 +04:00