flake8 --config=scripts/flake8.cfg test/zdtm.py
test/zdtm.py:66:1: E305 expected 2 blank lines after class or function definition, found 1
test/zdtm.py:127:1: E305 expected 2 blank lines after class or function definition, found 1
test/zdtm.py:971:1: E305 expected 2 blank lines after class or function definition, found 1
test/zdtm.py:1618:1: E305 expected 2 blank lines after class or function definition, found 1
Makefile:377: recipe for target 'lint' failed
travis-ci: success for zdtm: fix flake8 warnings
Signed-off-by: Andrei Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
When C/R-ing a net namespace with --empty-ns net option we should also
skip netfilter rules too (as per https://github.com/docker/docker/issues/27597).
However, there's one thing to be handled -- local TCP blocking rules are
expected to be there on restore by restore_iptables() which is no longer
the case, so put them back manually.
Test included, checked on zdtm/static/socket-tcpbuf-local :)
v2: Full scripts for empty netns setup.
https://github.com/xemul/criu/issues/246
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Travis sets up the GCOV variable to collect coverage and
provides an external mount for this. Thus handling this
option in RPC mode is essential.
travis-ci: success for tests: Add RPC testing to CI (rev2)
Acked-by: Andrey Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
travis-ci: success for tests: Add RPC testing to CI (rev2)
Acked-by: Andrey Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Now the --ext-mount-map is deprecated option, so fix it to
become the --external one.
travis-ci: success for tests: Add RPC testing to CI (rev2)
Acked-by: Andrey Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
It seems to me most of the clean hooks (used by cgroup*, macvlan* cr_veth*
and mnt_tracefs* were all designed to be run to clean up after the test, no
matter whether it failed or succeeded. Let's always run them, so Andrei
doesn't hate me :D
travis-ci: success for zdtm.py: run --clean hook on test failure
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
CC: Andrei Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
travis-ci: success for Fix a few issues to dump/restore Docker containers with userns
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
If userns_restore_one_link() is called outside of usernsd,
it switches into the criu namespace and switches back before exiting.
v2: rid of the include of linux/net_namespace.h in criu/include/net.h,
as well as the associated defines and feature checks
travis-ci: success for net: simplify restore of macvlan-s (rev2)
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
travis-ci: success for zdtm/cr_veth: use the --clean alias of the cleanup action
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Note, this depends on Pavel's patch here:
https://lists.openvz.org/pipermail/criu/2016-October/032499.html which is
not yet applied.
travis-ci: success for test: use .pid.inprogress file for macvlan test (rev2)
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Inspired by Tycho's macvlan test, here's the same thing for
--external veth option. In master we still have the --veth-pair
one, but the plan is to move this all under the --external opt.
v2:
* Travis doesn't have /usr/bin/sed
* Added .checkskip hook for older environments
v3:
* Delete bridge hanging around after previous flavor
* Wait for host veth end to die after dump
v4:
* Get the pid of task to move veth into from .pid.inprogress file
v5:
* Wait for host veth end to die after test stop too :\
Travised-by: https://travis-ci.org/xemul/criu/builds/170726663
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Note that this test doesn't run in uns mode, even though we have support
for that. Without a full container engine, I couldn't think of a nice way
to pass a macvlan device into the zdtm "container" when in UNS mode.
v2: use the nsid_manip feature flag
travis-ci: success for series starting with [v10,01/11] net: pass the struct nlattrs to dump() functions
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
The latter option should hide, the official API is the --external.
This patch tests the option, thus completing the deprecation.
The legacy -x|--ext-unix-sk test is still in zdtm/static/socket-ext.
travis-ci: success for unix: Test the --external instead of --ext-unix-sk
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
The same as for --ext-mount-map auto, but with manual key:val
setting in .desc file.
travis-ci: success for mnt: Deprecate --ext-mount-map for --external
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Done with python pprint module (indent = 4, width = 80)
for files with more than one field in and with length
exceeding 80 characters.
Travised-by: https://travis-ci.org/xemul/criu/jobs/171350152
travis-ci: success for zdtm: Split long .desc lines
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This is useful so that hooks can do a $(cat $pidfile) or [ -f $pidfile ]
and rely on the result.
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
It-makes-sence-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This one will contain pid of the task living in a sub-ns and
waiting for the rest of the test to get daemonized.
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Travised-by: https://travis-ci.org/xemul/criu/builds/170726663
On Ubuntu ppc64le, the libxt_standard.so is installed under a
different path.
Adding this path to the dependency list to make the test running on
ppc64le.
Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This hook runs after the test is started, in parallel with the actual test.
This can be used in case the test and the host need to coordinate somehow
in order to set something up (e.g. for a macvlan interface).
travis-ci: success for series starting with [v10,01/11] net: pass the struct nlattrs to dump() functions
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
* make sure that tracefs is actually loaded, and try and access it after
restore
* don't mount debugfs in /, leaving an ugly directory in /test
* clean up the debugfs mount point (with a hook, since the test can't
unmount it due to perms)
travis-ci: success for test: robustify mnt_tracefs test
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
When this code is compiled by clang, it optimizes two byte writes into
one word write, like this:
> fake_grow_down[0] = 'c';
> *(fake_grow_down - 1) = 'b';
> 401b60: 66 41 c7 46 ff 62 63 movw $0x6362,-0x1(%r14)
This is incorrect, as the stack is supposed to grow page by page,
so we need to touch one page then another, i.e. the order is important.
To fix, let's use volatile pointer. After this change, the following
(correct) code is generated:
> *p-- = 'c';
> 401b60: 41 c6 06 63 movb $0x63,(%r14)
> *p = 'b';
> 401b64: 41 c6 46 ff 62 movb $0x62,-0x1(%r14)
[v2: same fix for another similar place]
Cc: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Acked-by: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
CLang doesn't like explicit NULL pointer dereference:
> maps007.c:176:2: error: indirection of non-volatile null pointer will be deleted, not trap [-Werror,-Wnull-dereference]
> *((int *) 0) = 0;
> ^~~~~~~~~~~~
> maps007.c:176:2: note: consider using __builtin_trap() or qualifying pointer with 'volatile'
>
Apparently, we need to add volatile to make it happy.
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
clang complains:
> cmdlinenv00.c:35:11: error: comparison of unsigned expression < 0 is always false [-Werror,-Wtautological-compare]
> if (ret < 0) {
> ~~~ ^ ~
The fix is to use ssize_t not size_t.
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
clang complains:
> apparmor.c:86:20: error: too many arguments in call to 'checkprofile' [-Werror]
> if (checkprofile(0) == 0)
> ~~~~~~~~~~~~ ^
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
clang complains:
> clang -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -iquote ../lib/arch/x86/include -I../lib vdso01.c ../lib/libzdtmtst.a ../lib/libzdtmtst.a -lrt -o vdso01
> vdso01.c:305:6: error: absolute value function 'abs' given an argument of type 'long' but has parameter of type 'int' which may cause truncation of value
> [-Werror,-Wabsolute-value]
> if (abs(ts1.tv_sec - ts2.tv_sec) > TIME_DELTA_SEC) {
> ^
> vdso01.c:305:6: note: use function 'labs' instead
Let's use labs() indeed.
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
When compiling with clang, it complains like this:
> clang -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -iquote ../lib/arch/x86/include -I../lib inotify_system.c ../lib/libzdtmtst.a ../lib/libzdtmtst.a -o inotify_system
> inotify_system.c:323:50: error: comparison of unsigned expression < 0 is always false [-Werror,-Wtautological-compare]
> if ((common_desc.inot < 0) || (common_desc.file < 0) || \
> ~~~~~~~~~~~~~~~~ ^ ~
> inotify_system.c:324:21: error: comparison of unsigned expression < 0 is always false [-Werror,-Wtautological-compare]
> (common_desc.dir < 0) || (common_desc.link < 0)) {
> ~~~~~~~~~~~~~~~ ^ ~
> inotify_system.c:324:47: error: comparison of unsigned expression < 0 is always false [-Werror,-Wtautological-compare]
> (common_desc.dir < 0) || (common_desc.link < 0)) {
> ~~~~~~~~~~~~~~~~ ^ ~
> 3 errors generated.
Indeed these fields are uint32_t. As they are used to store the results of
inotify_init() and inotify_add_watch() function calls, the type should be int.
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
clang complains a number of times on our inline asm code, like this:
> fpu00.c:13:6: error: ambiguous instructions require an explicit suffix
> (could be 'flds', 'fldl', or 'fldt')
> "fld %0\n"
> ^
> <inline asm>:1:2: note: instantiated into assembly here
> fld -4(%rsp)
> ^
As floats are used, the suffix should be 's' ("short", 32-bit, float).
Add it where needed.
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
CLang doesn't like explicit NULL pointer dereference:
> zombie00.c:52:5: error: indirection of non-volatile null pointer will be
> deleted, not trap [-Werror,-Wnull-dereference]
> *(int *)NULL = 0;
> ^~~~~~~~~~~~
> zombie00.c:52:5: note: consider using __builtin_trap() or qualifying
> pointer with 'volatile'
> 1 error generated.
Apparently, we need to add volatile to make it happy.
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
clang complains about an unused function:
> clang -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
> -iquote ./arch/x86/include -c -o parseargs.o parseargs.c
> parseargs.c:12:1: error: unused function '__check_help'
> [-Werror,-Wunused-function]
> TEST_OPTION(help, bool, "print help message and exit", 0);
> ^
> ./zdtmtst.h:71:2: note: expanded from macro 'TEST_OPTION'
> param_check_##type(name, &(name));
> \
> ^
> <scratch space>:46:1: note: expanded from here
> param_check_bool
> ^
> ./zdtmtst.h:84:35: note: expanded from macro 'param_check_bool'
> #define param_check_bool(name, p) __param_check(name, p, int)
> ^
> ./zdtmtst.h:78:22: note: expanded from macro '__param_check'
> static inline type *__check_##name(void) { return(p); }
> ^
> <scratch space>:47:1: note: expanded from here
> __check_help
> ^
> 1 error generated.
> <builtin>: recipe for target 'parseargs.o' failed
As far as I can tell, the functions __check_##name are generated in
order to check the argument type by the compiler.
For gcc, the "inline" keyword is enough to suppress the "unused function"
warning even when -Wunused-function is used. For clang, it's not the
case (see https://llvm.org/bugs/show_bug.cgi?id=22712).
A way to "use" the function is to use its name as a pointer and cast it
to void. This is what this patch does.
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
[root@fc24 criu]# python test/zdtm.py run -t zdtm/transition/shmem --pre 3
=== Run 1/1 ================
======================== Run zdtm/transition/shmem in h ========================
cc -g -O2 -Wall -Werror -fno-strict-aliasing -iquote ../lib/arch/x86/include -I../lib shmem.c ../lib/libzdtmtst.a ../lib/libzdtmtst.a -o shmem
Start test
./shmem --pidfile=shmem.pid --outfile=shmem.out
Run criu pre-dump
Run criu pre-dump
Run criu pre-dump
Run criu dump
Run criu restore
Send the 15 signal to 33
Wait for zdtm/transition/shmem(33) to die for 0.100000
Test output: ================================
15:12:25.444: 33: FAIL: shmem.c:70: checksum mismatch: ea71000 109c9000
Cc: Eugene Batalov <eabatalov89@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Unfortunately, newer versions of protobuf check that the file suffix ends
in _pb2.py:
sudo ./zdtm.py run -t zdtm/static/apparmor_stacking
Traceback (most recent call last):
File "./zdtm.py", line 23, in <module>
import criu as crpc
File "/home/ubuntu/criu/test/criu.py", line 12, in <module>
import rpc
File "/home/ubuntu/criu/test/rpc.py", line 36, in <module>
type=None),
File "/usr/lib/python2.7/dist-packages/google/protobuf/descriptor.py", line 652, in __new__
_message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors should not be created directly, but only retrieved from their parent.
v2: fix up the clean target, and remove some comments that were about the
old rename
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
CC: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
The 'umount2: umount2' doesn't make sense as it's a circular dependency.
It came from commit e7b152fd and probably meant to say
"umount2: umount2.c" instead.
But it's not needed either as make has implicit rules like that.
Drop the "zdtm_ct: zdtm_ct.c" for same reason.
travis-ci: success for test/Makefile: rm bad code
Cc: Andrei Vagin <avagin@openvz.org>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
To mimic the environment that systemd is in when it causes the problem, we
preserve a prefix cgroup path across checkpoint and restore which the tasks
live below, and then we open a fd to this path. Without
--cgroup-root /prefix on dump, this test fails:
(00.030429) 32: Error (criu/files-reg.c:1487): File home/ubuntu/criu/test/zdtm/static/cgroup02.test/zdtmtst/prefix has bad mode 040600 (expect 040777)
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
In commit 07d259f365f2 ("cgroup: support --cgroup-root on dump too")
criu starts to understand --cgroup-root option on dump, but our
cgroup02 test in cgroup02.desc file sets these opt to /newroot
unintentionaly, as on dump we don't have /newroot dump fails:
https://ci.openvz.org/job/CRIU/job/CRIU-x86_64/branch/criu-dev/989
======================== Run zdtm/static/cgroup02 in h
=========================
Start test
Test is SUID
./cgroup02 --pidfile=cgroup02.pid --outfile=cgroup02.out
--dirname=cgroup02.test
Run criu dump
=[log]=> dump/zdtm/static/cgroup02/30/1/dump.log
------------------------ grep Error ------------------------
(00.023103) Error (criu/cgroup.c:620): cg: failed walking
/proc/self/fd/10/newroot for empty cgroups: No such file or directory
(00.023129) Error (criu/cr-dump.c:1359): Dump core (pid: 30) failed with
-1
(00.023944) Error (criu/cr-dump.c:1675): Dumping FAILED.
------------------------ ERROR OVER ------------------------
So fix this by using restore-only ropts instead of opts.
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
v2: add cgroup04.hook which removes the cgroups in between, so things are
actually restored :)
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
CC: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Before this patch vma sizes were hardcoded and weren't derived
from PAGE_SIZE value.
But all the actions with these vmas are based on PAGE_SIZE value.
That's why maps008 on PowerPC with "huge" PAGE_SIZE of 64k was simply
terminating due to invalid memory access.
This commit sets vma sizes to safe values derived from PAGE_SIZE.
New sizes are enough to perform all the actions test does with vmas.
Tested-by: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Signed-off-by: Eugene Batalov <eabatalov89@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This program doesn't parse /etc/fstab or /etc/mtab,
it just calls the umount2 syscall.
It is another attempt to fix the error:
subprocess.CalledProcessError: Command '['mount', '--make-private', '/tmp/criu-root-C7MZS9']' returned non-zero exit status 1
OSError: [Errno 16] Device or resource busy: '/tmp/criu-root-C7MZS9'
Signed-off-by: Andrei Vagin <avagin@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Add a new option to zdtm.py to run "criu dedup" after "criu dump"
or "criu pre-dump".
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
An atexit hook is executed for forked processes too,
clean_tests_root() has to be called only once.
v2: fix flak8 warnings
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>