2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 05:18:00 +00:00

2223 Commits

Author SHA1 Message Date
Pavel Tikhomirov
3a875cc4c7 zdtm: add test for socket buffer size locks
Just set all possible values 0-3 and chack if it persists.

Reviewed-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
2022-04-28 17:53:52 -07:00
Nicolas Viennot
37a8090d8c tests: improve the image streamer process control
When exceptions are raised during testing, the image streamer process
should be terminated as opposed to being left hanging.
This could lead to the whole test suite to be left hanging as it waits
for all child processes to exit.

Signed-off-by: Nicolas Viennot <Nicolas.Viennot@twosigma.com>
2022-04-28 17:53:52 -07:00
Radostin Stoyanov
bffaa7d072 ci: enable coredump tests
Signed-off-by: Radostin Stoyanov <radostin@redhat.com>
2022-04-28 17:53:52 -07:00
Radostin Stoyanov
8aa7694558 test/coredump: fix shellcheck errors
ShellCheck reports the following problems:

SC2086: Double quote to prevent globbing and word splitting.
SC2035: Use ./*glob* or -- *glob* so names with dashes won't become options.
SC1091: Not following: ../env.sh was not specified as input (see shellcheck -x).

Signed-off-by: Radostin Stoyanov <radostin@redhat.com>
2022-04-28 17:53:52 -07:00
Radostin Stoyanov
a92a7887a6 python: replace equality with identity test
PEP8 recommends for comparisons to singletons like None to always be
done with 'is' or 'is not', never the equality operators.

https://python.org/dev/peps/pep-0008/#programming-recommendations

Signed-off-by: Radostin Stoyanov <radostin@redhat.com>
2022-04-28 17:53:52 -07:00
AndreyVV-100
1c866dbb51 Add new files for running criu-coredump via python 2 or 3
Previous commit added support for python3 in criu-coredump. For convenience,
add two files (coredump-python2 and coredump-python3) that start
criu-coredump with respective python version. Edit env.sh accordingly.

Signed-off-by: Andrey Vyazovtsev <viazovtsev.av@phystech.edu>
2022-04-28 17:53:52 -07:00
Bui Quang Minh
abf6b15c14 zdtm: Dumping/restoring with --tcp-close on TCP_CLOSE socket
Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
2022-04-28 17:53:52 -07:00
Radostin Stoyanov
62b3779574 Makefile: add shellcheck test/others/libcriu/*.sh
Signed-off-by: Radostin Stoyanov <radostin@redhat.com>
2021-10-12 12:58:43 -07:00
Radostin Stoyanov
59d0dfba96 test/libcriu: print logs on fail
run_test was trying to read criu logs on build failure
instead of runtime error.

This patch also removes the unnecessary subfolder with name "i"
and resolves some of issues reported by shellcheck.

Signed-off-by: Radostin Stoyanov <radostin@redhat.com>
2021-10-12 12:58:43 -07:00
Radostin Stoyanov
53bf82bcfc test/libcriu: add test case for join-ns
This test case aims to verify that CRIU correctly
restores a process in IPC, UTS and Time namespaces
with criu_join_ns_add() libcriu API.

Signed-off-by: Radostin Stoyanov <radostin@redhat.com>
2021-10-12 12:58:43 -07:00
Radostin Stoyanov
a8c5efe4c1 libcriu: define log level constants
Replace magic numbers used to set log level in libcriu
with constants.

Signed-off-by: Radostin Stoyanov <radostin@redhat.com>
2021-10-12 12:58:43 -07:00
Zeyad Yasser
aa772bf286 zdtm: fix network lock tests when run with --norst
In test/jenkins/{crit.sh,criu-dump}, ZDTM is run with --norst,
Causing tests to only go through dump wihtout restoring.

The network locking tests are highly dependant on dump/restore hooks
causing them to hang when run with --norst.

We just add a reqrst flag to all network lock tests.

Signed-off-by: Zeyad Yasser <zeyady98@gmail.com>
2021-09-03 10:31:00 -07:00
Zeyad Yasser
ca3e3c50be inventory: save network lock method to reuse in restore
When the network is locked using a specific method like iptables
or nftables there is no need to require passing the same method
during restore.

We save the lock method during dump in the inventory image and
use that in restore.

This always overwrites the restore --network-lock option.

v2: store opts.network_lock_method directly to avoid dependency
    on rpc.proto's 'enum criu_network_lock_method'.
v3: fall back to iptables if image is generated with an older
    version of CRIU.
v4: remove --network-lock from netns_lock_* from restore

Signed-off-by: Zeyad Yasser <zeyady98@gmail.com>
2021-09-03 10:31:00 -07:00
Zeyad Yasser
cd1570b15e zdtm: add ipv6 variants of net_lock_socket_* tests
v2: remove unnecessary elif and else after return in
    wait_server_addr()
v3: use IOError instead of FileNotFoundError for python2
    compatibility

Signed-off-by: Zeyad Yasser <zeyady98@gmail.com>
2021-09-03 10:31:00 -07:00
Zeyad Yasser
212db1d9a6 zdtm: add nftables per-socket locking test
This is just a symlink to the original static/net_lock_socket_iptables
test with the right options passed to use nftables instead.

Signed-off-by: Zeyad Yasser <zeyady98@gmail.com>
2021-09-03 10:31:00 -07:00
Zeyad Yasser
6e59b2bd77 zdtm: add iptables per-socket locking test
When criu dumps a process with --tcp-established opt it locks
the open tcp connections so that no packets from peer enters
the stack, otherwise RST will be sent by a kernel causing the
connection to fail.

Post-start hook creates a connection with the test server and
creates a background thread that stays alive for the duration
of the test. This background thread sends data to the test
server at three stages:
- Pre-dump: Should send normally
- Pre-restore:
	If connection is locked properly, packets will be dropped
	and TCP will just retry, which will eventually be sent when
	the process is restored and the network is unlocked.
- Post-restore: Should send normally

Data sent at the three stages is then checked at the server's side.

v2:
	- remove unused imports and constants
	- delete sync file in wait_sync_file() instead of --clean
v3:
	- add comments

Co-developed-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
Signed-off-by: Zeyad Yasser <zeyady98@gmail.com>
2021-09-03 10:31:00 -07:00
Zeyad Yasser
c15327656a zdtm: add nftables network namespace locking test
This is just a symlink to the original static/netns_lock test with
the right options passed to use nftables instead.

v2:
	- make static/netns_lock test iptables explicitly
	- prevent netns_lock tests from running in parallel because
	  netns & sync files creation were conflicting in both tests.

Signed-off-by: Zeyad Yasser <zeyady98@gmail.com>
2021-09-03 10:31:00 -07:00
Pavel Tikhomirov
90e175d52f zdtm/pthread_timers: make sure glibc allocated SIGEV_THREAD's stack
On Virtuozzo7 jenkins we see a fail of criu-dev zdtm:

  ===================== Run zdtm/static/pthread_timers in ns =====================
  Start test
  ./pthread_timers --pidfile=pthread_timers.pid --outfile=pthread_timers.out
  Run criu dump
  =[log]=> dump/zdtm/static/pthread_timers/112/1/dump.log
  ------------------------ grep Error ------------------------
  (00.004817) netlink: Collect netlink sock 0x1cad6e21
  (00.004821) netlink: Collect netlink sock 0x1cad6e22
  (00.004831) Collecting pidns 9/112
  (00.004886) No parent images directory provided
  (00.004903) Warn  (criu/lsm.c:328): don't know how to suspend LSM 0
  ------------------------ ERROR OVER ------------------------
  Run criu restore
  4: Old maps lost: set([])
  4: New maps appeared: set([u'7fe4c54ca000-7fe4c54cb000 ---p', u'7fe4c0000000-7fe4c0021000 rw-p', u'7fe4c0021000-7fe4c4000000 ---p', u'7fe4c54cb000-7fe4c5ccb000 rw-p'])
  ############# Test zdtm/static/pthread_timers FAIL at maps compare #############

https://ci.openvz.org/job/CRIU/job/CRIU-virtuozzo/job/criu-dev/8032/consoleFull

First thing to mention is that this is not related to criu. I can manage
to reproduce it with "--nocr", problem is that some mapping appears a
bit later when we do pre-cr get_visible_state().

By debugging SIGEV_THREAD thread with gdb I can see that addresses from
this unexpectedly appearing mapping are used by glibc here as "struct
pthread *pd":

 clone()
  start_thread()
   timer_helper_thread()
    __pthread_create_2_1()

So the mapping looks allocated by allocate_stack(), and it is only
gets done after first timer trigger (we have glibc-2.17 on vz7):

https://github.com/bminor/glibc/blob/release/2.17/master/nptl/sysdeps/unix/sysv/linux/timer_routines.c#L92

So let's wait at least 1 timer trigger so that memory outfit of the test
become permanent and our check_visible_state zdtm check would not be
false negative.

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
2021-09-03 10:31:00 -07:00
Adrian Reber
dd0e66149f ci: fix 'crit.sh: 3: source: not found'
Jenkins test runs are failing with:

 ./test/jenkins/run_ct ./test/jenkins/crit.sh
 ./test/jenkins/crit.sh: 3: source: not found

Switch to bash which has 'source'.

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-09-03 10:31:00 -07:00
Christian Brauner
9422383b6b zdtm/apparmor_stacking: don't include optional AppArmor namespace separator
AppArmor namespaces are officially colon-separated. The double-slash
syntax is just convenience:

"The trailing : separates the namespace name from the profile name and
the optional / and // separators are provided as a convenience for those
familiar with ssh and protocol urls." (see [1])

[1]: https://gitlab.com/apparmor/apparmor/-/wikis/AppArmorNamespaces
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-09-03 10:31:00 -07:00
Tycho Andersen
06b5d2fa8d tests: add a test for apparmor_stacking
v2: use a profile that doesn't have "unix" to test the suspend feature too
v3: use "/" in the profile names to make sure this works

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-09-03 10:31:00 -07:00
Adrian Reber
70833bcf29 Run 'make indent' on header files
Acked-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Adrian Reber <areber@redhat.com>
2021-09-03 10:31:00 -07:00
Adrian Reber
93dd984ca0 Run 'make indent' on all C files
Acked-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Adrian Reber <areber@redhat.com>
2021-09-03 10:31:00 -07:00
Pavel Tikhomirov
cc2317ea48 zdtm: fix indentation in Makefile wait_stop target
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
2021-09-03 10:31:00 -07:00
Pavel Tikhomirov
918901439f zdtm/pthread_timers: require ns_pid feature and add non-ns test
Resolving real pid to vpid for notify thread ids requires NSpid feature
supported by kernel, though in simple non-pid-ns case we can deal
without it, so add a requirement and split out the host test without the
requirement.

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
2021-09-03 10:31:00 -07:00
Andrei Vagin
64f0012e44 zdtm: add a test for SIGEV_THREAD timers
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2021-09-03 10:31:00 -07:00
Zeyad Yasser
4a9bcd8844 zdtm: prioritize /lib/* dependencies in some tests
Prioritize /lib/* because iptables fails to search /usr/lib64/*
first on archlinux.

This change of 'deps' order prioritizes the default library location.

This affects:
	- zdtm/static/netns-nf
	- zdtm/static/netns-nft-ipt
	- zdtm/static/socket-tcp-closed-last-ack
	- zdtm/static/socket-tcp-reseted
	- zdtm/static/socket-tcp-syn-sent

Signed-off-by: Zeyad Yasser <zeyady98@gmail.com>
2021-09-03 10:31:00 -07:00
Pavel Tikhomirov
7ff785e1d4 zdtm: make --sbs also stop on each pre-dump/snap iteration
This is useful to investigate problems on pre-dump iterations. After
this patch test output with "--pre=2 --sbs" would have new usefull stop
points.

While on it let's remove confusion in sbs stop point naming. "Pause at
pre-dump" actually has nothing to do with pre-dump, let's better use
"before " instead of "at pre-", similar let's use "after " instead of
"at post-".

Result would look like:

========================== Run zdtm/static/env00 in h ==========================
Start test
./env00 --pidfile=env00.pid --outfile=env00.out --envname=ENV_00_TEST
Pause before pre-dump 0. Press Enter to continue.
Run criu pre-dump
Pause before pre-dump 1. Press Enter to continue.
Run criu pre-dump
Pause before dump. Press Enter to continue.
Run criu dump
Pause before restore. Press Enter to continue.
Run criu restore
Pause after restore. Press Enter to continue.

v2: improve sbs step naming; rename "iter" to more meaningfull
"pre-dump"/"snap".

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
2021-09-03 10:31:00 -07:00
Zeyad Yasser
d55f34ed78 test/ci: sync netns_lock test and its --post-start hook
The --post-start hook creates a netns which the test should enter
at the beginning of the test.

The test randomly failed in CI tests, it is most likely caused by
a race condition.

I suspect this flow is root cause:
	1. --post-start hook starts just after the test (in parallel)
	2. --post-start hook calls ip netns add to create the test netns
	3. ip creates the netns file
	4. netns_lock test opens that file and uses it in setns
	5. ip mounts the netns to the file

Of course test fails at step 4 because the netns is not yet mounted
to the file.

I made the test wait for SYNCFILE to be created by the --post-start
hook before it tries to open the netns file and call setns.

Signed-off-by: Zeyad Yasser <zeyady98@gmail.com>
2021-09-03 10:31:00 -07:00
Zeyad Yasser
b290df9a65 test/jenkins: fix netns_lock test multiple iterations failure
netns_lock is highly dependent on the order of the hooks, and
iterations causes the --pre-dump hook to be called multiple
times which expectedly caused the test to fail.

The server loop accommodates for multiple iterations.

https://ci.kernoops.org/job/CRIU/job/CRIU-iter/job/criu-dev/431/testReport/(root)/criu/zdtm_static_netns_lock/

Signed-off-by: Zeyad Yasser <zeyady98@gmail.com>
2021-09-03 10:31:00 -07:00
Adrian Reber
093fb0c878 Add test for new --lsm-mount-context option
Signed-off-by: Adrian Reber <areber@redhat.com>
2021-09-03 10:31:00 -07:00
Zeyad Yasser
fc7705a13f zdtm: add network namespace locking test
When criu dumps a process in a network namespace it locks
the network so that no packets from peer enters the stack,
otherwise RST will be sent by a kernel causing the connection
to fail.

In netns_lock.c we try to enter the netns created by post-start
hook so that criu locks the network namespace between dump and
restore.

A TCP server is started in post-start hook inside the test netns
and runs in the background detached from its parent so that
it stays alive for the duration of the test.

Other hooks (pre-dump, pre-restore, post-restore) try to
connect to the server.

Pre-dump and post-restore hooks should be able to connect
successfully.

Pre-restore hook client with SOCCR_MARK should also connect
successfully.

Pre-restore hook client without SOCCR_MARK should not be able
to connect but also should not get connection refused as all
packets are dropped in the namespace so the kernel shouldn't
send an RST packet as a result. Instead we check that the
connect operation causes a timeout.

This test would be useful when testing that the network is
locked using different ways (using iptables currently and
other methods later).

v2:
	- check that packets with SOCCR_MARK are allowed to
	  pass when the netns is locked.

v3:
	- fix pre-restore hook skipping non SOCCR_MARK
	  connection test due to early exit in SOCCR_MARK
	  variant.

Signed-off-by: Zeyad Yasser <zeyady98@gmail.com>
2021-09-03 10:31:00 -07:00
Adrian Reber
0cf79a3608 test: remove exec test
criu exec is deprecated for some time now and criu just exits with an
error if running 'criu exec'. This removes the test for that non-working
subcommand.

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-09-03 10:31:00 -07:00
Adrian Reber
45bde968a2 test: add tests for configuration file parsing
This adds a test run to ensure known (but fixed) configuration file
parser errors are not crashing CRIU anymore.

Based on missing test code coverage this script also tests code paths of
the option handling which have not been tested until now.

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-09-03 10:31:00 -07:00
Adrian Reber
24bc083653 ci: disable some tests on CentOS 7
Now that we are running CI on an actual CentOS 7 kernel different
tests are no longer working as they require newer kernels.

This commit disables a few tests only on CentOS 7.

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-09-03 10:31:00 -07:00
Adrian Reber
b4c7267b0e zdtm: allow ignore taint via environment variable
With this change tainted kernels can be ignored with setting
ZDTM_IGNORE_TAINT=1. This is just to simplify the CI script to not
require to change every call of zdtm. Setting the variable once should
be enough.

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-09-03 10:31:00 -07:00
Mike Frysinger
87ea13f6b7 add PKG_CONFIG default in a few more places
These files use $PKG_CONFIG before they include the common files that
setup a default, so set early defaults in them too.

Signed-off-by: Mike Frysinger <vapier@chromium.org>
2021-09-03 10:31:00 -07:00
Mike Frysinger
2967bed64e build: respect $PKG_CONFIG settings
The build needs to respect $PKG_CONFIG env var like other standard
build systems and the the upstream pkg-config project itself.  This
allows the package builder to point it to the right tool when doing
a cross-compile build.  Otherwise the host pkg-config tool is used
which won't have access to the packages in the cross sysroot.

Signed-off-by: Mike Frysinger <vapier@chromium.org>
2021-09-03 10:31:00 -07:00
Radostin Stoyanov
638e53c950 zdtm/tun_ns: add per-test dependencies
The tun_ns test was introduced with [1] and [2], however, these commits
didn't add per-test dependencies required for the test.

Per-test dependencies are listed in the .desc file as 'deps': [<list>]

These dependencies are made available inside the test namespace and without
the ip dependency, the tests fails on Fedora 34 with

   Error: ipv4: FIB table does not exist.

[1] https://github.com/checkpoint-restore/criu/commit/7e355e7
[2] https://github.com/checkpoint-restore/criu/commit/3ba0893

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
2021-09-03 10:31:00 -07:00
Adrian Reber
9d9ec73dd7 test: skip time namespaced tests on <= 5
Although CentOS 8 comes with 4.18 kernel it has time namespace patches
backported but not all the required once. This disables time namespaced
tests on everything older than 5.11.

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-09-03 10:31:00 -07:00
Radostin Stoyanov
2aa4185a6c test/others: refactor loop process
There are several problems with the loop.sh script. First, the code is
duplicated across tests in the so-called 'othres' category. Second, we
need to run it with the 'setsid' utility to make sure that it runs in
a new session. Third, we have to redirect the standard file descriptors
and use the '&' operator to make it run in the background. Finally,
obtaining the PID of the 'loop.sh' process resulted in race condition.

In this patch we replace the loop.sh script with a program that would
address all problems mentioned above. The requirements for this program
are as follows.
- It must be reusable across tests
- It must start a process that is detached from the current shell
- It must wait for the process to start and output its PID

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
2021-09-03 10:31:00 -07:00
Radostin Stoyanov
2b78d95e6b test/others: drop '_exit' function
The function name '_exit' is misleading as this function doesn't
actually exit when the status of the previous command is zero.
In addition, the behaviour of this function is not really needed.

This patch removes the '_exit' function and applies the correct
behaviour to stop the test on failure.

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
2021-09-03 10:31:00 -07:00
Andrei Vagin
34410b9e75 test: add a test to check that sigtrap handlers are restored
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2021-09-03 10:31:00 -07:00
Zeyad Yasser
1c08709cdb zdtm: add pidfd store based pid reuse test
This is just a symlink to the original transition/pid_reuse test with
the right options passed to trigger the pidfd store based pid reuse
detection code path.

Pidfd store based detection is supported only in RPC mode which
requires passing a unix socket fd to be used as pidfd store and
the kernel should support pidfd_open and pidfd_getfd syscalls
{'feature': 'pidfd_store'} for this test to work.

Signed-off-by: Zeyad Yasser <zeyady98@gmail.com>
2021-09-03 10:31:00 -07:00
Zeyad Yasser
ea0dc7807a zdtm: add --pidfd-store option in RPC mode
When testing pid reuse using pidfd_store feature in RPC mode we need
to pass a unix socket fd used to CRIU in the RPC option
pidfd_store_sk to store the pidfds between predump/dump iterations.

Signed-off-by: Zeyad Yasser <zeyady98@gmail.com>
2021-09-03 10:31:00 -07:00
Radostin Stoyanov
8c303d1a64 test/others/crit: add test for 'x'
This commit extends the CRIT tests to cover the 'x' command, which is
used to explore an image directory.

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
2021-09-03 10:31:00 -07:00
Andrei Vagin
c8973d426b test/zdtm: check that a penging SIGTRAP handled properly
Signed-off-by: Andrei Vagin <avagin@gmail.com>
2021-09-03 10:31:00 -07:00
Adrian Reber
ed58fb2214 test: create new tls certificates
The certificates expired again. This replaces the expired
certificates with test certificates which are valid for ever:

  echo -ne "ca\ncert_signing_key\nexpiration_days = -1\n" > temp
  certtool --generate-privkey > cakey.pem
  certtool --generate-self-signed \
           --template temp \
           --load-privkey cakey.pem \
           --outfile cacert.pem
  echo -ne "cn=$HOSTNAME\nencryption_key\nsigning_key\nexpiration_days = -1\n" > temp
  certtool --generate-privkey > key.pem
  certtool --generate-certificate \
           --template temp \
           --load-privkey key.pem \
           --load-ca-certificate cacert.pem \
           --load-ca-privkey cakey.pem \
           --outfile cert.pem
  rm cakey.pem temp

Signed-off-by: Adrian Reber <areber@redhat.com>
2021-09-03 10:31:00 -07:00
Alexander Mikhalitsyn
6beeabcd42 zdtm: add sk-unix-dgram-ghost test case
This testcase reproduces deadlock in "wait_fds_event" futex in open_fdinfos()
function (files subsystem).

Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
2021-09-03 10:31:00 -07:00
Alexander Mikhalitsyn
ddefbbff16 zdtm: add combined nftables/iptables netns-nft-ipt test
Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
2021-09-03 10:31:00 -07:00