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

5765 Commits

Author SHA1 Message Date
Pavel Emelyanov
c405304fcc zdtm.py: Add inhfd tests for --inherit-fd option
This option cannot be tested using classic zdtm tests as it implies
some data created before restore and passed through criu restore down
to the restored process (descriptor in our case).

So add inhfd_test class that creates such.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-19 12:42:01 +03:00
Pavel Emelyanov
5193fa4a96 zdtm.py: Split per-test options into C and R ones
One for checkpoint another for restore.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-19 12:42:00 +03:00
Tycho Andersen
56eea20c2e unix: unlink_stale returns void
We don't check the return value here, so let's return void.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-19 12:39:20 +03:00
Tycho Andersen
d0f8f5e73c check: also check tun support in mainline
As of
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=fb7589a1
tun support is merged, so let's check it in ms as well.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-19 12:37:34 +03:00
Tycho Andersen
43d7e9ca80 check: do timerfd check on mainline kernel
As of
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=5442e9fbd
this feature is in mainline, so let's check for it in ms.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-19 12:37:32 +03:00
Tycho Andersen
33ebd47c98 check: mnt_id is now in mainline
As of
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=49d063cb3
the mnt_id field is in mainline, so let's check for it in --ms.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-19 12:37:31 +03:00
Laurent Dufour
da1be409cc test: rtc don't use hard coded major value
The /dev/rtc device major value may change depending on the
architecture, and kernel release. To ensure the test rtc is working
all the time, we no longer belong on hard coded major value but peek
it from /dev/rtc itself.

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-19 12:36:52 +03:00
Laurent Dufour
1ad78171ad ppc64: crtools no more use builtin mem operation
Since crtools is no more linked with object build for the
parasite/restorer blob, it no more needs the builtin memory services.

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-19 12:36:16 +03:00
Pavel Emelyanov
450fadb561 zdtm.py: Control whether or not to keep images after test
Tree ways are possible -- always, never and only for tests that failed. The
latter one is the default.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-19 12:35:57 +03:00
Pavel Emelyanov
0fdbffa10e zdtm.py: Run tests matching given regexp
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-19 12:35:38 +03:00
Ruslan Kuprieiev
85856e9d42 pycriu: add criu class
This class is essentially libcriu in python(yet for now it
has only some basic functions such as check/dump/restore).
It is needed to make life for python users even more easier,
i.e. hiding some nasty connection stuff. It is also using
criu swrk(COMM_BIN) communication method, instead of an old
system service, as we no longer recommend it.

Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-19 12:34:43 +03:00
Kir Kolyshkin
4456273738 restore_root_task(): fix calling try_clean_remaps
1. As pointed out by Coverity (CID 114629), mnt_ns_fd is closed,
but then the function calls try_clean_remaps(mnt_ns_fd)
which tries to close the file descriptor which is already closed.

To address this, let's use safe_close() which sets closed fd to -1.
As it also checks its argument, there's no need for explicit check
so let's remove "if" check before close().

2. As Pavel pointed out, "calling the whole try_clean_remaps()
is not required once we've passed the cleanup_mnt_ns() point".
This could be addressed by introducing yet another label, but
it's cleaner to just use a flag variable.

Note that since the second issue is being addressed, the first one
goes away, but let's keep the fix for it anyway, it might help in
the future.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-19 12:33:58 +03:00
Kir Kolyshkin
75fa3c6e29 tcp_read_sysctl_limits: hide a useless error, leave a warning
When running tests, there are a lot of errors like this:

 (00.000053) Error (sysctl.c:367): Can't open sysctl net/ipv4/tcp_rmem: No such file or directory

As Andrew explained, tests are running in a netns that lacks
this sysctl. Use CTL_FLAGS_OPTIONAL flag to hide the error message.

Since with this flag sysctl_op() will most probably return 0,
add an additional check for vect[0] == 0 to detect that the file
was not read and show an appropriate warning, i.e.
"TCP mem sysctls are not available. Using defaults."

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-19 12:32:22 +03:00
Kir Kolyshkin
b1599c3d1c tcp_read_sysctl_limits(): simplify vect
I spent some time trying to figure out why vect array
is declared as [2][3], also why vect[0] is not used.
The answer is commit 4bca68b that removed code using it.

Let's save a few bytes, and make the code more readable.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-19 12:32:15 +03:00
Ruslan Kuprieiev
86bb235b5c test: libcriu: switch to using swrk instead of service
As our tests serve as an example for people on how to preferably
use criu, we need to also switch to swrk.

Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-15 14:35:43 +03:00
Ruslan Kuprieiev
f39bb8f9f0 libcriu: use swrk by default
Not sure if it is okay, but this patch breaks backward compatibility,
as we now discourage people from using criu as a system service by default.
But it is better to be done rather sooner than later, considering criu service
is not widely used.

On a patch side, we just need to daemonize swrk if self-dump is requested.

Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-15 14:35:15 +03:00
Ruslan Kuprieiev
f4e9a1df40 make: don't install service and logrotate configs
As we've deleted them in previous two patches.

Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-15 14:34:28 +03:00
Ruslan Kuprieiev
ee0c401a8a criu: scripts: remove logrotate
We don't need it without systemd configs.

Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-15 14:34:16 +03:00
Ruslan Kuprieiev
10d5e9a43e criu: scripts: remove criu service files
As it is not recomended to run criu as a root system service, lets
remove service file to stop encouraging people to do it.

Signed-off-by: Ruslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-15 14:34:10 +03:00
Tycho Andersen
f415a693c8 unix: report errors from unlinking stale sockets
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-15 12:23:39 +03:00
Andrew Vagin
4c1ffde861 zdtm.py: print separators between tests
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-14 15:58:08 +03:00
Andrew Vagin
ed8a13b70f zdtm: show error messages in a error case
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-14 15:57:31 +03:00
Laurent Dufour
2f481f02fc Build pie objects separately
This patch change the build chain to not use pie objects in the crtools
executable.

This done by building the shared source files twice:
 1. for parasite/restorer as '<file>-pie-build.o'
 2. for crtools as '<file>.o'

Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Reviewed-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-14 15:53:07 +03:00
Cyrill Gorcunov
61859d1176 fsnotify: Filter out internal inotify bits when restoring marks
The kernel prior 4.3 is exporting FS_EVENT_ON_CHILD
bit via procfs fdinfo interface. This bit is kernel's
internal and should not be passed in inotify_add_watch
call. Thus simply filter it out when obtain from old
images for backward compatibility reason.

More details here https://lkml.org/lkml/2015/9/21/680

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-14 15:51:55 +03:00
Andrew Vagin
9f631ad5c9 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-14 15:51:05 +03:00
Andrew Vagin
14da0f780e 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-14 15:49:25 +03:00
Andrew Vagin
135659e0ed criu: restore blocked signals correctly
We need to use SIG_SETMASK instead of SIG_BLOCK.

SIG_SETMASK
      The set of blocked signals is set to the argument set.

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-12 13:17:23 +03:00
Andrew Vagin
a082f27b11 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-12 13:15:28 +03:00
Andrew Vagin
fee9021f5f zdtm: test inotifies in a sub mount namespace
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-12 13:14:49 +03:00
Andrew Vagin
addbc25550 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-12 13:08:32 +03:00
Pavel Emelyanov
1a6de2c643 zdtm.py: Support crlib flag for tests
This flag means that there's lib/ directory where a plugin is.
Currently rtc test is such. The wait_pid_die timeout is risen
since this test dies for more than 6 seconds :)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-12 13:06:27 +03:00
Pavel Emelyanov
388df2a103 zdtm.py: Support tests' hooks
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-12 13:06:20 +03:00
Pavel Emelyanov
edc19f139c zdtm.py: Print out file if it exists
Sometimes tests fail before generating .out file, so print its
contents only if it exists.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-12 13:06:10 +03:00
Pavel Emelyanov
b84642ff33 zdtm: Tune mountpoints test
I constantly have binfmt_misc off on my set ups :) Looks like this fs is
far from being default for systems, so to make the test work (we plan to
rewrite it anyway) let's make this fs being optional.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-12 13:06:04 +03:00
Pavel Emelyanov
bdb549c961 zdtm.py: Allow specifying the test suit description file
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-12 13:05:43 +03:00
Pavel Emelyanov
6d5635e360 zdtm.py: Lower zdtm keyword usage
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-12 13:05:33 +03:00
Pavel Emelyanov
f698be0a12 zdtm.py: Print tests info when listing them
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-12 13:05:28 +03:00
Pavel Emelyanov
9db8bd8cf4 zdtm.py: Rework tests list generation
Hand-made list of tests is not great. As Christopher suggested we can find
all executables in a directory and treat them as tests. This idea is good,
but requires a little bit more trickery.

First, some executables in directory are not tests, e.g. these are per-test
scripts, which should be skipped. Next, not all tests in zdtm can be right
now run in continuous manner (they fail), but we want to run them manually.
To fix that such tests are marked with 'noauto' flag in the description.

So we have the test test descriptor file, which states in which file to
look for tests (executable) and which of them to exclude. Maybe more, can
be added on demand.

And, finally, the per-test description goes in a ${test}.desc file in native
python eval/repr-able format. If the file is absent a default description
is used.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-12 13:05:02 +03:00
Pavel Emelyanov
526b7826d1 zdtm.py: Test the --restore-sibling option
The main difficulty here is that restored test becomes zdtm.py's kid
and after killing one we should wait() the test's zombie. W/o the
--restore-sibling test gets restored under existing init and gets
wait()-ed automagically.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-12 13:04:17 +03:00
Pavel Emelyanov
206acdf225 zdtm.py: Print criu action in logs
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-12 13:04:06 +03:00
Pavel Emelyanov
31944f33d6 zdtm.py: Print "test FAIL" early
In case t.kill() raises an exception (sometimes it can) it becomes unclear
what's going on.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-12 13:03:59 +03:00
Pavel Emelyanov
7cbb5e5a37 zdtm.py: Save existing environment for zdtm-in-ct
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-12 13:03:53 +03:00
Pavel Emelyanov
0cc628915d zdtm.py: Auto-reap all ns children
When test is run in pseudo-container (--parallel execution) the new namespace's
init is the python script itself. Thus all dying tests get reparent-ed to it and
sit as zombies forever.

Create pseudo-init for such containers ripping all the children.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-12 13:03:41 +03:00
Andrew Vagin
9841778fec Don't use strlcpy in libcriu (v2)
../../lib/libcriu.so: undefined reference to `strlcpy'

v2: don't include string.h

Reported-by: Mr Jenkins
Cc: Kir Kolyshkin <kir@openvz.org>
Fixes: e5654e586cf5 ("Use strlcpy")
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-09 18:32:19 +03:00
Kir Kolyshkin
15f914f20a pr_perror(): don't supply \n
pr_perror() is special, it adds \n at the end so there is
no need to supply one.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Andrew Vagin <avagin@odin.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-09 18:29:55 +03:00
Kir Kolyshkin
53f8c31459 ppc64/crtools.c: use pr_perror()
In places where we have errno value set, such as after calling ptrace(),
it makes sense to use pr_perror as it appends the errno string. This
also fixes missing '\n' at the end (as pr_perror() adds it).

In places where we keep using pr_err(), don't forget to have '\n'.

Cc: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Reviewed-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Acked-by: Andrew Vagin <avagin@odin.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-09 18:28:19 +03:00
Kir Kolyshkin
0f6b5d921c open_proc_sfd(): use pr_perror() after failed open()
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Andrew Vagin <avagin@odin.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-09 18:28:12 +03:00
Kir Kolyshkin
d638f57dff cgroup.c: use pr_err() with '\n'
Don't forget '\n' when using pr_err()

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Andrew Vagin <avagin@odin.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-09 18:28:07 +03:00
Kir Kolyshkin
17b92fa542 Append newline when using pr_err()
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Andrew Vagin <avagin@odin.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-09 18:28:00 +03:00
Kir Kolyshkin
572f152ea0 aarch64:get_task_regs(): use pr_perror()
As ptrace() sets errno, it makes sense to use pr_perror().
This also fixes the bug of missing '\n'.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Andrew Vagin <avagin@odin.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-10-09 18:27:48 +03:00