2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-26 11:57:52 +00:00

1777 Commits

Author SHA1 Message Date
Andrei Vagin
1d5438310b test/other: add a test to check the --shell-job option
This test creates a pty pair, creates a test process and sets a slave
pty as control terminal for it.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-04-06 02:37:28 +03:00
Vitaly Ostrosablin
e19bd64876 zdtm: Add a test to check if we can C/R ghost files with no parent dirs.
This is test that triggers a bug with ghost files, that was resolved in
patch "Don't fail if ghost file has no parent dirs".

Signed-off-by: Vitaly Ostrosablin <vostrosablin@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-04-06 02:36:47 +03:00
Kirill Tkhai
0d11a50b95 zdtm: Actually add tun_ns test
Previous patch missed "git add", so simlink and .desc
file were not sent...

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
2018-03-28 20:38:34 +03:00
Andrey Vagin
251dad530b zdtm: check an exit code of a straced restore
Currently zdtm doesn't detect when restore failed, if it is executed
with strace. With this patch, fake-restore.sh creates a test file, and
zdtm is able to distinguish when restore failed.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-28 00:31:53 +03:00
Andrei Vagin
509fac32dd zdtm.py: fix a logic about determing a test flavor in a error case
The get() method requires a key and now we are using an index. That
will never work correctly as it is now.

Acked-by: Adrian Reber <adrian@lisas.de>
Reported-by: Adrian Reber <adrian@lisas.de>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-23 01:04:56 +03:00
Andrey Vagin
9a429e3de8 zdtm: check unix sockets in two mount namespaces
Unix file sockets have to be restored in proper mount namespaces.

Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-23 00:51:06 +03:00
Kir Kolyshkin
7953b4037e Fix zdtm with Ubuntu Bionic/arm/clang
In Ubuntu Bionic for armhf, clang is compiled for armv8l rather than
armv7l (as it was and still is for gcc) and so it uses armv8 by default.

This breaks compilation of tests using smp_mb():

> error: instruction requires: data-barriers

The fix is to add "-march=armv7-a" to CFLAGS which we already do,
except not for the tests.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2018-03-23 00:46:11 +03:00
Andrew Vagin
d5fe28da67 zdtm: Add tun_ns test
tun test in nested net ns wrapper.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
ktkhai: Makefile hunks
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
2018-03-16 08:41:17 +03:00
Kirill Tkhai
d38e8fe965 zdtm: Fix race in zdtm/transition/epoll.c test
Child may see close() result before it receives signal,
while it shouldn't see it. Instead of games with later
close(), just stop do it. sys_exit() after program finish
will close them all.

Reported-by: Andrey Vagin <avagin@virtuozzo.com>
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
2018-02-28 22:57:11 +03:00
Mike Rapoport
0c6dadf2f4 test/jenkins: add script for lazy migration testing
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
2018-02-19 20:37:49 +03:00
Andrei Vagin
4ef926192c zdtm: enable lazy migration testing
The --lazy-migrate option allows testing of lazy migration when running ns
or uns flavor.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
2018-02-19 20:37:49 +03:00
Dmitry Safonov
3a35c7fd86 zdtm/cgroup_ifpriomap: Fix Coverity warning
*** CID 185302:  Null pointer dereferences  (NULL_RETURNS)
/test/zdtm/static/cgroup_ifpriomap.c: 107 in read_one_priomap()
>>>     Dereferencing a pointer that might be null "out->ifname" when calling "strncpy".

There is also a warning about using rand(), but..
Not sure that we need to entangle everything just for pleasing Coverity:
>>>     CID 185301:  Security best practices violations  (DC.WEAK_CRYPTO)
>>>     "rand" should not be used for security related applications, as linear congruential algorithms are too easy to break.
Leaving that as-is and marking in Coverity as WONTFIX.

Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com>
2018-02-16 04:41:59 +03:00
Dmitry Safonov
1406eb92a1 zdtm/cgroup_ifpriomap: Find cgroup's controller's name to mount
I've also dropped `noauto' in this patch, reverting the
commit be98273cf137 ("zdtm: mark static/cgroup_ifpriomap as noauto")
Don't see any sense to separate it as another patch.

Fixes: #383

Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com>
2018-02-16 04:41:59 +03:00
Dmitry Safonov
1566bec9a6 zdtm/fpu02: Don't run the test on !x86 platforms
Fixes: commit 925451c12b2e ("zdtm/x86: Add a mxcsr preserving fpu test")

Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com>
2018-02-16 01:53:22 +03:00
Andrei Vagin
634703bb7d zdtm: fix gcc-8 warnings
fs.c:78:5: error: 'strncpy' specified bound 64 equals destination size [-Werror=stringop-truncation]
     strncpy(m->fsname, fsname, sizeof(m->fsname));
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-02-13 10:16:36 +03:00
Dmitry Safonov
925451c12b zdtm/x86: Add a mxcsr preserving fpu test
It helped a bit to debug Skylake ptrace() bug, let's put it in.

Signed-off-by: Dmitry Safonov <dima@arista.com>
2018-02-13 10:14:42 +03:00
Kirill Tkhai
e7449021bd zdtm: Add scm06 test
zdtm: Add scm06 test

From: Kirill Tkhai <ktkhai@virtuozzo.com>

This test makes looped unix sockets queues and tries
to iterate over them after the restore.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
2018-02-07 01:11:44 +03:00
Kirill Tkhai
8192507466 zdtm: Add scm05 test
Create socketpair and epoll. Add one end of the socketpair
to epoll and then twice send it over another end.

After restore check, that epoll can be received
via socket, and that it contains event.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
2018-02-07 01:11:44 +03:00
Andrei Vagin
4fa17310ba zdtm: fix a lint warning
$ make lint
flake8 --config=scripts/flake8.cfg test/zdtm.py
test/zdtm.py:323:19: F841 local variable 'e' is assigned to but never used

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-02-02 00:55:51 +03:00
Kirill Tkhai
e8210261e5 zdtm: Fix fd01 cleanup
waitpid() does not return child pid, when child has not exited.
So, we can't use it to find pids of children.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-02-01 21:12:48 +03:00
Andrei Vagin
a180cf7ee1 zdtm: suppress useless error messages
Start test
./mxcsr --pidfile=mxcsr.pid --outfile=mxcsr.out
Run criu dump
Unable to kill 44: [Errno 3] No such process <--------------- this one
Run criu restore
Run criu dump

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>
2018-01-31 21:13:51 +03:00
Pavel Tikhomirov
778d6d7b70 zdtm: check ghost restores on readonly fs if it is also a ghost in other writable bind
It is a test for convert_path_from_another_mp fix, it is a bit tricky as
we don't fully support ghosts on readonly fs, but only if the ghost can
be remaped on some _other_ bindmount (luckily we have same ghost on other
bind). Moreover wrong absolute path generated with old convert_path_from
_another_mp for lnkat don't always fail, only in case we want to do
linkat on mount in _other_ mountns and absolute path makes us do it in
local mountns and local path is readonly and we fail. =)

v2: remove unused headers

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
2018-01-25 03:34:57 +03:00
Kirill Tkhai
51c4dc7c25 zdtm: Add fd01 test
Fork tasks and create fds with different numbers.
Some children share file with parent (CLONE_FILES).
Check, than we can suspend and resume in this case.

v2: New

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
2018-01-16 20:43:22 +03:00
Kirill Tkhai
76b8ab3500 zdtm: Add zombie01 test
Create a zombie with specific pgid and check that
pgid remains the same after restore.

This test hangs criu restore without any of two previous patches:
1)without "restore: Call prepare_fds() in restore_one_zombie()"
  in 100% cases;

2)without "restore: Split restore_one_helper() and wait exiting
  zombie children" fail is racy, but you can add something like

criu/cr-restore.c:
## -1130,6 +1130,8 @@ static int restore_one_zombie(CoreEntry *core)

        if (task_entries != NULL) {
                restore_finish_stage(task_entries, CR_STATE_RESTORE);
+               if (current->parent->pid->state == TASK_ALIVE)
+                       sleep(2);
                zombie_prepare_signals();
        }

and it will fail with almost 100% probability.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-01-02 20:45:34 +03:00
Kirill Tkhai
75b46c9d05 zdtm: Export sys_clone_unified() to headers
Make it possible to use this function by tests.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-01-02 20:45:34 +03:00
Pavel Tikhomirov
b1a67f8572 zdtm: improve tempfs_overmounted test
Unchanged test provided by Andrew.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-12-26 21:11:45 +03:00
Pavel Tikhomirov
7ca51df5a8 zdtm: now tempfs_overmounted will pass so remove crfail
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-12-26 21:11:45 +03:00
Andrei Vagin
c767b11c54 test: check that corked udp sockets are not dumped
The kernel doesn't have an interface to get a sent queue for udp
sockets, so currently we can't dump them and criu dump has to fail in
such cases.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-12-15 09:14:03 +03:00
Andrei Vagin
514510ba87 zdtm/tempfs_subns: sync children with the main process
All static tests has to stop any activity before C/R.

./tempfs_subns --pidfile=tempfs_subns.pid --outfile=tempfs_subns.out --dirname=tempfs_subns.test
Run criu dump
Unable to kill 128: [Errno 3] No such process
Run criu restore
7: Old mounts lost: []
7: New mounts appeared: [('/rootfs/criu/test', '/'), ('/', '/proc'), ('/', '/dev/pts')]
:

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-12-07 19:55:23 +03:00
Andrei Vagin
b921ad2908 test: check a pipe with a custom size
CRIU doesn't handle correctly pipes with sizes which are bigger than a
default one.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-12-04 23:59:06 +03:00
Mike Rapoport
8c545089ed zdtm: use {read,write}_data in fifo tests
Reading and writing large buffers may result in short read/write. In cases
we expect the entire buffer to be transferred use {read,write}_data rather
than plain read/write syscalls.

Reported-by: Mr Jenkins
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 21:59:03 +03:00
Mike Rapoport
a76ff847d6 zdtm: lib: add {read,write}_data helpers
Some tests expect that all the data will be handled in a single invocation
of read/write system call. But it possible to have short read/write on a
loaded system and this is not an error.
Add helper functions that will reliably read/write the entire buffer.

Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 21:58:59 +03:00
Pavel Begunkov
369b56068b zdtm: Test inherited file leases
-- check childs' errors in file_leases03
-- test c/r of lease transfered to child process

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:36:15 +03:00
Andrei Vagin
d1ba8b8831 zdtm/maps006: modify test so that file and anon vma-s are mixed
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:36:14 +03:00
Pavel Begunkov
4986cdf225 zdtm: Add file lease tests
Test cases:
0. Basic non-breaking read/write leases.
1. Multiple read leases and OFDs with no lease for the same file.
2. Breaking leases.
3. Multiple fds (dup + inherited) for single lease (mutual OFD).

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:34:50 +03:00
Andrei Vagin
641d5ff987 alpine: cast addresses to struct sockaddr *
Otherwise we get errors like this:

/usr/include/sys/socket.h:315:5: note: expected 'const struct sockaddr *' but argument is of type 'struct sockaddr_un *'
 int bind (int, const struct sockaddr *, socklen_t);

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:34:50 +03:00
Andrei Vagin
7b8de6bce6 zdtm: don't mix images from dump with and without check_only
The idea of the check-only option is that criu dump and criu
restore is executed with this option to check whether c/r is
possible for a set of processes. This has to work faster than
without the check-only option.

Now we run criu restore --check-only for images which have
been generated by criu dump without --check-only, it is obviously wrong.

Cc: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:34:50 +03:00
Andrei Vagin
9c8d9f1f08 zdtm: don't overwrite logs if the check-only option is set
If the check-only option is set, dump and restore is executed twice,
and we need to set separate logs for both cases.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:34:50 +03:00
Andrei Vagin
f951a3cc92 zdtm: restore ns_last_pid before executing restore in a second time
Otherwise a criu process can get a pid of one of restored processes.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:34:50 +03:00
Andrei Vagin
14ab677ef2 restore: wait restored tasks in the check-only case
If the restore was exexuted with the check-only option,
after restoring all resources tasks waits children and
exits with the 0 code.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:34:50 +03:00
Pavel Tikhomirov
ab1eaad3c3 zdtm/session04: do cleanup on success and wait children in it
https://github.com/xemul/criu/issues/372
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2017-11-30 01:31:19 +03:00
Kirill Tkhai
5af3ca59eb utils: Add sys_clone_unified()
Cleanup fork() definition and make a generic function
for all archs. It may be useful, when you want to add
more clone flags to fork(), or if you want to pass more,
than one argument to child function (glibc's clone
alows only one).

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:31:19 +03:00
Dmitry Safonov
f5c11168d5 fault-inj: Silently dying helper's child
The restorer blob may die silently due to anything:
- Segmentation fault
- OOM killer
- User-sended SIGKILL
- Child CRIU restorer did't abort futex on error path (and exited)

We should terminate the restoring process and avoid locking
self up on waiting for died restoree.

Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:31:03 +03:00
Veronika Kabatova
18c22b77c5 Modify and add test for configuration file functionality
Creating a test for verifying configuration parsing feature. The
test is created by reusing already present inotify_irmap test.

Because of addition of default configuration files, --no-default-config
option is added to zdtm.py to not break the test suite on systems with
these files present.

Signed-off-by: Veronika Kabatova <vkabatov@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:29:44 +03:00
Michael Holzheu
7e01425766 s390: Fix clone() syscall parameters for s390
On s390 the first two paramters are swapped because we use
the CONFIG_CLONE_BACKWARDS2 kernel config option.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
Reviewed-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:29:44 +03:00
Kirill Tkhai
627ca7d13d zdtm: Add SIGCHLD flag to userns-leaked-sock test
wait() waits children created using SIGCHLD signal only.
Add it.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:29:44 +03:00
Dmitry Safonov
7d5ac8338d zdtm: Add infop to waitid() in pidns0{2,3}
As said in man page:
> The application shall ensure that the infop argument
> points to a siginfo_t structure.

While x86_64 ignores NULL, ia32 syscall returns error:
Test output: ================================
20:52:47.176:     4: FAIL: pidns02.c:158: Can't wait (errno = 14 (Bad address))
20:52:47.177:     4: FAIL: pidns02.c:183: Test failed (errno = 14 (Bad address))
20:52:47.177:     3: ERR: test.c:228: Test exited unexpectedly with code 255
 <<< ================================

Test output: ================================
20:53:27.835:     1: FAIL: pidns03.c:119: Can't wait (errno = 14 (Bad address))
20:53:28.207:     4: FAIL: pidns03.c:201: Can't wait or bad status: errno=0, status=32512 (errno = 0 (Success))
 <<< ================================

Cc: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com>
Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:29:44 +03:00
Kirill Tkhai
8df85f8c51 compel, x86_64: Fix sys_clone() definition
Commit 37e4c7bfc264 fixed arm, ppc, x86 (32bit),
while it made wrong definition of x86_64. Fix that.

Also, add commentary to raw fork() implementation.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:29:44 +03:00
Adrian Reber
4864af0d91 zdtm: also dump and restore tests with --check-only
This adds the option '--check-only' to zdtm.py. If specified each test
cases is first dumped with the '--check-only' option enabled before the
real dump. Also during restore the test case is first restored with
--check-only before doing the real restore.

Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:29:42 +03:00
Adrian Reber
bab458b0d6 zdtm: call getpid() during gone if pid is zero
If calling gone() without ever calling getpid() before leads to
backtrace. Just call getpid() to avoid that.

Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:28:57 +03:00