2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-09-02 07:15:31 +00:00
Commit Graph

2223 Commits

Author SHA1 Message Date
Alexander Mikhalitsyn
4696e61edb zdtm: skip static/netns-nft test if nftables feature isn't supported
Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
2021-09-03 10:31:00 -07:00
Kir Kolyshkin
96b7178bab Whitespace at EOL cleanup and check
My editor (vim) auto-removes whitespace at EOL for *.c and *.h files,
and I think it makes sense to have a separate commit for this, rather
than littering other commits with such changes.

To make sure this won't pile up again, add a line to Makefile under
the linter target to check for such things (so CI will fail).

This is all whitespace except an addition to Makefile.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-09-03 10:31:00 -07:00
Kir Kolyshkin
10c619adb9 test/zdtm: pr_err / pr_perror fixes
1. Use pr_perror where errno needs to be shown.

2. Use pr_err in cases where errno is not set
   by the previous failed call.

3. Make sure pr_err's first argument do not have \n.

4. While at it, fix some error messages.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-09-03 10:31:00 -07:00
Kir Kolyshkin
dca0eb5b4a test/others/bers: use pr_perror
When errno is set, it makes sense to use pr_perror.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-09-03 10:31:00 -07:00
Kir Kolyshkin
4cd23083be test/zdtm: don't pass errno to fail()
Macro fail() already prints the value of errno, so there's no need to
explicitly add it.

Found by git grep '^\s*\<fail\>.*errno'

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-09-03 10:31:00 -07:00
Kir Kolyshkin
12a2bd0edd test/zdtm: don't use %m with fail
Macro fail already appends errno and strerror(errno) to the error
message, so there's no need to do it explicitly.

Brought to you by

	for f in $(git grep -l fail test/zdtm); do
		test -f $f || continue
		echo $f
		sed -i '\|^[[:space:]]*fail(.*[ (]%m)*"|s/:*[ (]*%m)*//' $f
	done

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-09-03 10:31:00 -07:00
Kir Kolyshkin
b20694835d test/zdtm: don't use \n with fail()
Macro fail already appends \n to the message, so there's no need to do
it explicitly.

Brought to you by

	for f in $(git grep -l fail test/zdtm); do
		test -f $f || continue
		echo $f
		sed -i '\%^[[:space:]]*fail(.*\\n"%s/\\n"/"/' $f
	done

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-09-03 10:31:00 -07:00
Kir Kolyshkin
9cbcaaed39 test/zdtm: don't use errno for pr_perror
Macro pr_perror already adds errno and its string representation to the
error message, so there's no need to explicitly do it.

While at it, fix some error messages.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-09-03 10:31:00 -07:00
Kir Kolyshkin
865a5e9511 test/zdtm: don't use pr_perror where errno is unset
pr_perror should be used for cases where the failed operation sets
errno. For cases where errno is not set, pr_err is preferable.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-09-03 10:31:00 -07:00
Kir Kolyshkin
f3be776ccc Drop \n from pr_perror
Another pr_perror spring cleaning time!

As pr_perror adds a semicolon, an strerror(errno), and a newline,
there's no need to add one manually.

Brought to you by

	for f in $(git grep -l pr_perror); do
		test -f $f || continue
		echo $f
		sed -i '\%^[[:space:]]*pr_perror(.*\\n"%s/\\n//' $f
	done

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-09-03 10:31:00 -07:00
Andrei Vagin
5e3b07b95d test/zdtm: check that restore can handle precreated veth devices
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2021-09-03 10:31:00 -07:00
Adrian Reber
b78c4e071a test: fix crit test and extend it
This fixes the others/crit test to work again and extends it to make
sure all possible input and output options are correctly handled by
crit.

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-09-03 10:31:00 -07:00
Adrian Reber
bb5bad5326 test: move vt test to minor 65 on s390x
Our Jenkins s390x vt test fails with

./vt --pidfile=vt.pid --outfile=vt.out --filename=vt.test
make: *** [Makefile:432: vt.pid] Error 1
 Test zdtm/static/vt FAIL at ['make', '--no-print-directory', '-C', 'zdtm/static', 'vt.pid']
Test output: ================================
08:08:15.556:    54: ERR: vt.c:38: Open virtual terminal vt.test failed (errno = 6 (No such device or address))
08:08:15.556:    53: ERR: test.c:316: Test exited unexpectedly with code 1

Because the host has no ttyS0 as used previously. This changes the test
to use 'ttysclp0'. That seems to exist on multiple s390x we checked.

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-09-03 10:31:00 -07:00
Dmitry Safonov
c66ca3aa23 zdtm/fpu03: Add .desc file to omit running on !x86
I managed to forget .desc file and ppc on Jenkins now fails with:

> === Run 177/394 =======--------- zdtm/static/fpu03
> timens isn't supported on 5.8.18-100.fc31.ppc64le
> ========================== Run zdtm/static/fpu03 in h ==========================
> Start test
> ./fpu03 --pidfile=fpu03.pid --outfile=fpu03.out
> make: *** [Makefile:430: fpu03.pid] Error 1
>  Test zdtm/static/fpu03 FAIL at ['make', '--no-print-directory', '-C', 'zdtm/static', 'fpu03.pid']
> Test output: ================================
> 08:56:48.325:    56: SKIP: fpu03.c:116: Unsupported arch
> 08:56:48.325:    55: ERR: test.c:316: Test exited unexpectedly with code 0
>
>  <<< ================================

Signed-off-by: Dmitry Safonov <dima@arista.com>
2021-09-03 10:31:00 -07:00
Dmitry Safonov
39b7252c6f fault-injection: Run fpu corruption tests
For the thread leader and for subthreads too.

Signed-off-by: Dmitry Safonov <dima@arista.com>
2021-09-03 10:31:00 -07:00
Dmitry Safonov
7af06af10d zdtm/fpu03: Add a test to check fpu C/R in a thread
CRIU dumps main thread and sub-threads differently, so there needed
a test to check if fpu is preserved across C/R in sub-threads.

Signed-off-by: Dmitry Safonov <dima@arista.com>
2021-09-03 10:31:00 -07:00
Dmitry Safonov
6c879c3c83 zdtm/fpu00: Simplify ifdeffery
..to introduce a new one! ;-D

Signed-off-by: Dmitry Safonov <dima@arista.com>
2021-09-03 10:31:00 -07:00
Adrian Reber
4eb43dc4de test: fix test compilation on rawhide
The latest glibc has redefined SIGSTKSZ as 'sysconf (_SC_SIGSTKSZ)' and
this breaks a static char[] definition.

Hardcoding TESTSIGSTKSZ to 16384 in the test. This fixes:

 sigaltstack.c:17:13: error: variably modified 'stack_thread' at file scope
   17 | static char stack_thread[SIGSTKSZ + TEST_MSG_BUFFER_SIZE] __stack_aligned__;
      |             ^~~~~~~~~~~~
sigaltstack.c:18:13: error: variably modified 'stack_main' at file scope
   18 | static char stack_main[SIGSTKSZ + TEST_MSG_BUFFER_SIZE] __stack_aligned__;
      |             ^~~~~~~~~~

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-09-03 10:31:00 -07:00
Radostin Stoyanov
6f8e671351 zdtm: Add javaTests output to .gitignore
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
2021-09-03 10:31:00 -07:00
Radostin Stoyanov
ae143161b8 javaTests: Add --file-locks option
Resolves #1370

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
2021-09-03 10:31:00 -07:00
Andrey Zhadchenko
2dc65a6360 zdtm: add second fifo_upon_unix test
This differs from the previous one by
1. using relative path instead of absolute
2. chdir() after setup

Reviewed-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
2021-09-03 10:31:00 -07:00
Andrey Zhadchenko
1f2e10771a zdtm: add fifo upon unix socket test case
Create unix socket and unlink it. Make fifo in this place.

Reviewed-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
2021-09-03 10:31:00 -07:00
Andrey Zhadchenko
7c5c813661 sk-unix: rework unix_resolve_name
Use SIOCUNIXFILE ioctl approach to get socket fd opened with O_PATH. Utilise it
for detecting deletion and resolving relative name. Preserve old method as
fallback if this new IOCTL fails.

Also remove overmount_sock crfail in zdtm. With the unix_resolve_name
reworked to use SIOCUNIXFILE criu can now pass this test.

Reviewed-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
2021-09-03 10:31:00 -07:00
Andrei Vagin
6be56e92c8 test/zdtm: check that locks are not dumped if --file-locks isn't set
If criu finds a file lock and the --file-locks option isn't set, it
stops dumping processes, resumes them and exits with an error.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
2021-09-03 10:31:00 -07:00
Andrei Vagin
fc5ba7de72 zdtm: handle a case when a test vma is merged with another one
Fixes: #1346
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2021-09-03 10:31:00 -07:00
Pavel Tikhomirov
95df2524cc zdtm: cleanup thread-bomb test error handling and printing
1) Let's do test_init earlier so that max_nr test_msg is now visible in
thread-bomb.out.

2) Also lets check errors from malloc and pthread_...  functions, print
messages about their errors and do proper deallocation at least.

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
2021-09-03 10:31:00 -07:00
Andrei Vagin
fabd5be384 zdtm: look up iptables in /sbin and /usr/sbin
On Ubuntu 20.04, iptables is in /usr/sbin/.

Reported-by: Mr Jenkins
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2021-09-03 10:31:00 -07:00
Andrei Vagin
797f41e8aa test/zdtm_ct: Run zdtm.py in the host time namespace
Before the 5.11 kernel, there is a known issue.

start_time in /proc/pid/stat is printed in the host time namespace,
but /proc/uptime is shown in a current namespace, but criu compares them
to detect when a new task has reused one of old pids.

Fixes: #1266

Signed-off-by: Andrei Vagin <avagin@gmail.com>
2021-09-03 10:31:00 -07:00
Pavel Tikhomirov
371d9c83d7 others/ns_ext: restore a process out of PID namespaces into the host PID namespace
It is quiet a common case to move the process from one pidns to another
existing pidns with criu (only restriction is pids should not
intersect). Let's check it works.

v2: - use pipe-s to synchronize processes
    - run the test in a pid namespace to avoid pid conflicts in the host
      pid namespace
    - grep errors in restore.log
    - add some more comments
v3: use 1000 for ns_last_pid so that test works on systems with low
pid_max; remove excess ';'s.

Co-Developed-by: Andrei Vagin <avagin@gmail.com>
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
2021-09-03 10:31:00 -07:00
Tim Gates
6a7bb0b9f6 docs: fix simple typo, clietn -> client
There is a small typo in test/zdtm/static/socket_aio.c, test/zdtm/static/socket_listen.c, test/zdtm/static/socket_listen4v6.c, test/zdtm/static/socket_listen6.c, test/zdtm/static/socket_udp-corked.c, test/zdtm/static/socket_udp.c, test/zdtm/static/socket_udplite.c.

Should read `client` rather than `clietn`.

Signed-off-by: Tim Gates <tim.gates@iress.com>
2021-09-03 10:31:00 -07:00
Pavel Tikhomirov
b023f0ab5a vim: remove wrong 8-space tabs indent from python files
Probably all vim users can setup their desired indent in their vimrc by
themselfs.

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
2021-09-03 10:31:00 -07:00
Pavel Tikhomirov
2c89954cc6 zdtm: on fail with no error also print the tail of the log
We see strange cases there page-server or lazy-pages are exiting with
non-zero but print no errors, probably the tail of the log can help us
to understand what happened.

There are some other uses of grep_errors but let's only change cases
where we explicitly through an exeption on bad ret. For others I'm not
sure if we need extra output, e.g. for validly failing fault injections.

To debug #1280

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
2021-09-03 10:31:00 -07:00
Adrian Reber
5bb4406e94 ci: use graviton2 for arm64 tests on Travis
Using travis-ci.com instead of travis-ci.org offers access to bare metal
aarch64 based systems and thus enabling us to run the full CRIU CI test
suite.

Switch arm64 based tests to arm64-graviton2 for tests.

This is the first non x86_64 architecture running tests and not just
compile in Travis.

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-09-03 10:31:00 -07:00
Andrey Zhadchenko
c7726b7f35 zdtm: add alternative socket filter
A little rework of sock_filter test to be able to use it with different
filters

Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
2020-10-20 00:18:24 -07:00
Abhishek Vijeev
82cd3bb0d0 zdtm: update and refactor tests for BPF array and hash maps
This commit achieves the following:
a) Refactors ZDTM tests bpf_array.c and bpf_hash.c to make use of the
BPF ZDTM library functions. In addition, these tests now verify whether
information obtained from both procfs and BPF_OBJ_GET_INFO_BY_FD are
the same before and after c/r.
b) Updates ZDTM tests bpf_array.c and bpf_hash.c to include a BPF map's
name and also to freeze maps

Source files modified:

* zdtm/static/bpf_array.c
* zdtm/static/bpf_hash.c

Source files added:

* zdtm/static/bpf_array.desc
* zdtm/static/bpf_hash.desc

Note: ${test_name}.desc files have the 'suid' flag set because
BPF_MAP_FREEZE requires the global (root-userns) CAP_SYS_ADMIN or
CAP_BPF. Hence, only test flavors 'h' and 'ns' are executed ('uns'
is skipped) because BPF_MAP_FREEZE can't be used from non-root user
namespaces.

Signed-off-by: Abhishek Vijeev <abhishek.vijeev@gmail.com>
2020-10-20 00:18:24 -07:00
Abhishek Vijeev
97ab725db1 zdtm: adding BPF helper functions as a new library
This commit adds BPF helper functions needed by tests in a new library.
It defines new functions that allow verifying BPF map meta-data from
the procfs as well as using the bpf() system call with
BPF_OBJ_GET_INFO_BY_FD. It is necessary to verify from procfs and using
BPF_OBJ_GET_INFO_BY_FD because the information available from both
these places is disjoint (for example, checking whether a map is frozen
cannot be performed with BPF_OBJ_GET_INFO_BY_FD).

Source files modified:

* test/zdtm/lib/Makefile - Generating build artifacts

Source files added:

* test/zdtm/lib/bpfmap_zdtm.c - Provides definitions for 3 new
functions:
    (a) parse_bpfmap_fdinfo() - Parses information about the BPF map
    from procfs
    (b) cmp_bpf_map_info() - Compares the attributes of a BPF map file
    obtained from BPF_OBJ_GET_INFO_BY_FD. This function is typically
    used to verify that the attributes of a BPF map remain the same
    before checkpoint and after restore
    (c) cmp_bpfmap_fdinfo() - Compares the attributes of a BPF map file
    obtained from procfs. This function is typically used to verify
    that the attributes of a BPF map remain the same before checkpoint
    and after restore

* test/zdtm/lib/bpfmap_zdtm.h - Structure and function declarations.
Declares struct bpfmap_fdinfo_obj, which stores information about BPF
maps parsed from procfs

Signed-off-by: Abhishek Vijeev <abhishek.vijeev@gmail.com>
2020-10-20 00:18:24 -07:00
Andrei Vagin
9acca8df9b tcp: add a separate test for listen sockets
In addition, it checks that an unconnected socket can be connected after
C/R.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-10-20 00:18:24 -07:00
Andrei Vagin
e42f5e032e tcp: allow to specify --tcp-close on dump
In this case, states of established tcp connections will not be dumped
and they will not be blocked. This will be useful in case of snapshots,
when we don't need to restore tcp connections.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-10-20 00:18:24 -07:00
Andrei Vagin
4f7c480413 test/zdtm: write in a tcp socket has to fail if tcp-close was set
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-10-20 00:18:24 -07:00
Radostin Stoyanov
80672c9f34 zdtm: Add test for SO_LINDER
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2020-10-20 00:18:24 -07:00
Radostin Stoyanov
0aeddba7cc socket: c/r support for SO_OOBINLINE
This patch enables checkpoint/restore of the SO_OOBINLINE socket option.
When the SO_OOBINLINE option is used, out-of-band data is placed in the
normal input queue as it is received. This permits it to be read using
read or recv without specifying the MSG_OOB flag.

Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2020-10-20 00:18:24 -07:00
Pavel Tikhomirov
5c11b0e440 zdtm: check that unbindable mount flag does not affect restore
Make two mounts, binds of the same file system, the first has root "/"
and the second has a cut root "/auxiliary". This insures that on restore
criu will mount the first mount first and latter bind the second from
it. After set the first mount unbindable to check if restoring these
flag does not interfere with restoring mounts.

Before the fix in these series we had the error:

(00.031286)      1: mnt: 	Mounting tmpfs @/tmp/.criu.mntns.wGroPU/12-0000000000/zdtm/static/unbindable.test/bind_of_unbindable (0)
(00.031298)      1: mnt: 	Bind /tmp/.criu.mntns.wGroPU/12-0000000000/zdtm/static/unbindable.test/unbindable/auxiliary to /tmp/.criu.mntns.wGroPU/12-0000000000/zdtm/static/unbindable.test/bind_of_unbindable
(00.031329)      1: Error (criu/mount.c:2298): mnt: Can't mount at /tmp/.criu.mntns.wGroPU/12-0000000000/zdtm/static/unbindable.test/bind_of_unbindable: Invalid argument

https://bugs.openvz.org/browse/OVZ-7116

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
2020-10-20 00:18:24 -07:00
Pavel Tikhomirov
ed74c9e058 zdtm: add new epoll01 test
This adds three epoll targets on tfd 702 and then adds two epoll targets
on tfd 701. This test is for off calculation in dump_one_eventpoll, the
reverse order makes qsort to actually work.

v2: update test_doc with longer explanation, remove unused DUPFDNO

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
2020-10-20 00:18:24 -07:00
Abhishek Vijeev
372782d8ac zdtm: adding tests for BPF maps
This commit adds ZDTM tests for c/r of processes with BPF maps as open
files

Source files added:

* zdtm/static/bpf_hash.c - Tests for c/r of the data and meta-data of
BPF map type BPF_MAP_TYPE_HASH

* zdtm/static/bpf_array.c - Tests for c/r of the data and meta-data
of BPF map type BPF_MAP_TYPE_ARRAY

Source files modified:

* zdtm/static/Makefile - Generating build artifacts for BPF tests

Signed-off-by: Abhishek Vijeev <abhishek.vijeev@gmail.com>
2020-10-20 00:18:24 -07:00
Andrei Vagin
f92948ccaf zdtm: make cgroup_yard to be aware of cgroup2
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-10-20 00:18:24 -07:00
Andrei Vagin
f96cd8c749 tests: skip cgroup04 and cgroup_ifpriomap on pure cgroup2 systems
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-10-20 00:18:24 -07:00
Andrei Vagin
5f160811aa zdtm.py: add the cgroup2 freezer support
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-10-20 00:18:24 -07:00
Adrian Reber
a93df9eb9b pidns: fixup
I pushed the wrong branch to the pidns PR

https://github.com/checkpoint-restore/criu/pull/1056

which resulted in the wrong patches getting merged.

This is the actual result from the review.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-10-20 00:18:24 -07:00
Andrei Vagin
62d70bd482 test/zdtm/autofs: use sigaction instead of the deprecated siginterrupt
Reported-by: Mr Travis
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2020-10-20 00:18:24 -07:00
Adrian Reber
3490d997be test: test external namespace support
Adapt netns_ext tests to also work with pid namespaces and move it from
test/others/netns_ext/ to test/others/ns_ext/.

Also enable ns_ext tests in Travis runs.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-10-20 00:18:24 -07:00