2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00
Commit Graph

6324 Commits

Author SHA1 Message Date
Tycho Andersen
7209c4ec28 inet: remember ipv6 connections' ifindex for restore
For some ipv6 scope types (link local, amongo others), we need to tell the
kernel the ifindex of the interface whose address we want to bind to as
well as the address itself.

v2: use SO_BINDTODEVICE to get the ifname, and pass that through instead of
    using netlink to grab all the ipv6 sockets via rtnetlink.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-30 11:46:16 +03:00
Pavel Emelyanov
c1b1880b34 zdtm: Check how auto-dedup works
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-30 11:44:57 +03:00
Andrew Vagin
df006762f0 check: don't use uninitialized variables
CID 154853 (#1 of 1): Uninitialized scalar variable (UNINIT)
7. uninit_use_in_call: Using uninitialized value c when calling write.

Reported-by: coverity
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-30 11:40:29 +03:00
Andrew Vagin
d1ee2801c6 files-reg: don't leak a file descriptor
CID 154850 (#1 of 1): Resource leak (RESOURCE_LEAK)
9. leaked_handle: Handle variable cwd_fd going out of scope leaks the handle.

Reported-by: coverity
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-30 11:40:07 +03:00
Andrew Vagin
d55e13d4f3 seccomp: don't leak info on an error path
CID 154852 (#1 of 3): Resource leak (RESOURCE_LEAK)
32. leaked_storage: Variable info going out of scope leaks the storage it points to.

Reported-by: coverity
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-30 11:39:43 +03:00
Tycho Andersen
1bd799ef30 tests: remove unused bpf.h
This header is unused, and not present on kernels w/o CONFIG_BPF_SYSCALL,
so let's not require it.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-27 15:50:41 +03:00
Andrew Vagin
af956f45ac mount: close mnt.ns_fd only for sub-namespaces (v3)
nsid->mnt.ns_fd is initialized into 0, so currently
fini_restore_mntns() closes the 0 descriptor if processes
lives in a current mount namespace (NS_CRIU).

Without this patch I get the following error:
(00.166444)   4109: Inherit fd tty:[8800:d] -> 0 has been closed

v2: typo fix
v3: do nothing when processes are restored in the local mntns
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-27 15:50:09 +03:00
Andrew Vagin
973731037e zdtm: compile stopped12
stopped03 is an old name of stopped12

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-27 15:49:08 +03:00
Tycho Andersen
c399e72d43 gitignore: ignore more test binaries
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-26 21:09:01 +03:00
Andrew Vagin
7828bbc351 seize: don't use wait4() to check whether or not a task is traced
If a task is stopped, waitpid() will return its status, but
wait4() in seize_wait_task will hang forever, because a stopped
state is reported only once.

v2: don't like a file object

Reported-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-26 21:08:54 +03:00
Andrew Vagin
708e2b37b3 seize: increase timeout of freezing processes
The timeout between iterations should be the save oder
with scheduler timeslice, which is about 100 msec.

Currently we wait for inly 10 msec, which is obviously not enough.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-26 21:08:35 +03:00
Pavel Emelyanov
bf039b7735 zdtm: Fix compilation after vfork test adding
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-26 17:25:19 +03:00
Andrew Vagin
49448676ac util: don't leak cr-img objects (v2)
We need to call close_image() for "empty" images.

v2: don't touch generic functiuons
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-26 17:04:37 +03:00
Andrew Vagin
490021ef9c restore: remove an unused label
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-26 17:04:01 +03:00
Pavel Ganyushin
22d4ec3ae1 Migration with vfork
This is old missed test. Fail expected.

Signed-off-by: Pavel Ganyushin <pganyushin@odin.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-26 17:03:31 +03:00
Andrew Vagin
5df2358f95 zdtm/stopped: check more cases
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-26 09:05:15 +03:00
Andrew Vagin
fa79ffd6ed ptrace: skip all sigstop (v2)
A task can be stopped and has a queued SIGSTOP, in this case we need
to resume the task twice to skip "both" signals.

v2: detect SIGSTOP in shared and per-process queues
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-26 09:05:13 +03:00
Andrew Vagin
fde1116fee proc: parse sigpnd and shdpnd separatly
We found that we want to know whether SIGSTOP is queue
in both or is in one of this queues.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-26 09:05:12 +03:00
Andrew Vagin
32452b2111 zdtm.py: umount root only if it was mounted
We get the stack trace if a test failed:

Test output: ================================
09:11:34.584:     4: PASS

 <<< ================================
Traceback (most recent call last):
  File "zdtm.py", line 922, in <module>
    do_run_test(tinfo[0], tinfo[1], tinfo[2], tinfo[3])
  File "zdtm.py", line 696, in do_run_test
    t.kill()
  File "zdtm.py", line 302, in kill
    self.__flavor.fini()
  File "zdtm.py", line 168, in fini
    subprocess.check_call(["mount", "--make-private", self.root])
  File "/usr/lib64/python2.7/subprocess.py", line 540, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['mount', '--make-private', '/tmp/criu-root-YN1t3X']' returned non-zero exit status 32
umount: /tmp/criu-root-YN1t3X: not mounted

Cc: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-25 15:30:32 +03:00
Andrew Vagin
6cc316615c ptrace: send SIGSTOP to restore the stopped state
If a task was in a stopped state before we started to ptrace-seize
it, this stopped state will be restored by kernel upon detach.

If SIGSTOP was only in a task queue, we need to send it by hands
again bedore detaching. Otherwise we clean stop from queue (to
run parasite) and seize will restore task as running.

And, since SIGSTOP doesn't affect states of already stopped tasks,
we can send it to then safely and not distinguish stopped from
stop-queued ones.

Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-25 15:28:56 +03:00
Pavel Emelyanov
8135e26ae3 jenkins: Fix path to zdtm.py in criu-fault
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-23 13:22:08 +03:00
Andrew Vagin
46daab0baf zdtm: check that the IP_FREEBIND is restored correctly
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-23 12:42:53 +03:00
Pavel Emelyanov
e6859679cd jenkins: Mark criu-fault test as executable
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-23 12:42:22 +03:00
Pavel Emelyanov
2b5a11a7a3 jenkins: Add job for known fault injections (v2)
v2: Add --report for report generation

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
2015-11-23 11:48:23 +03:00
Tycho Andersen
e6a3aef43e remap: don't allocate dead pids in wrong context
Closes #87

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
CC: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-23 11:47:29 +03:00
Andrew Vagin
73a739b8d3 inet: set IP_FREEBIND before binding socket to an ipv6 address (v2)
When we restore ipv6 addresses, they go through a “tentative” phase
and sockets could not be bound to them in this moment.

v2: add more comments in code

Reported-by: Ross Boucher <boucher@gmail.com>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-23 11:46:38 +03:00
Andrew Vagin
c9a61a205f sk-inet: handle the IP_FREEBIND option (v2)
v2: set has_freebind
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-23 11:46:29 +03:00
Tycho Andersen
c2ad6f3a68 check: drop bpf.h include
This include is actually unused (probably leftover from an old version of
the kernel API when I was porting the patchsets); we can delete it.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-23 11:45:05 +03:00
Tycho Andersen
cc9587ffc5 seccomp: is optional when parsing /proc/pid/status
Also define some constants for people who don't have them in their headers.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-23 11:44:50 +03:00
Pavel Emelyanov
3364992dc1 thread-bomb: Do not run automatically by .py
This teat crashes the ptrace-based freezer, need freeze-cgroup

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-20 21:58:17 +03:00
Tycho Andersen
f10de707a2 --freeze-cgroup: should also seize tasks in sub-cgroups
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
CC: Andrew Vagin <avagin@virtuozzo.com>
Acked-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-20 21:30:11 +03:00
Tycho Andersen
db92ce7b98 typo: fix double indentation
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-20 21:30:09 +03:00
Andrew Vagin
6e94eb5bdf files: restore cwd after switching mntns
Cc: Stanislav Kinsbursky <skinsbursky@openvz.org>
Reported-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-20 21:21:04 +03:00
Cyrill Gorcunov
9e96f138ac protobuf: tun.proto -- Drop unused import
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-20 21:20:39 +03:00
Pavel Emelyanov
0a8667dfd7 zdtm: Make thread-bomb be bomb
In current implementation of thread bomb effectively only one
thread runs, the rest sit in the read from pipe.

Fix this by making threads constantly creating new ones and
just exiting.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@virtuozzo.com>
2015-11-20 21:17:34 +03:00
Andrew Vagin
0135291f21 ptrace: wait when queued SIGSTOP signals will be handled (v2)
SIGSTOP can't be blocked, so we need to wait when it will be handled.

v2: don't duplicate the same code twice

Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-20 21:13:33 +03:00
Andrew Vagin
028998c588 proc_parse: parse pending signals
It's required to check the SIGSTOP signal, which can't be blocked.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-20 21:13:31 +03:00
Andrew Vagin
61b8fc264f net: block all traffic in internal network (v4)
Let's imagine that we have two local interconnected sockets.
Whe we are restoring tcp sockets, we need to disable the repair mode
to restore data in sending queues.

If traffic isn't blocked, a socket starts operating, but
in this time another end can be not restored yet.

$ test/zdtm.sh -r ns/static/socket-tcpbuf-local
...
(00.274632) 5: Error (sk-tcp.c:485): Can't restore 2 queue data (-1), want (1780919:1780919): Connection reset by peer

We create a separate chain to avoid conflicts with other rules.

https://bugs.openvz.org/browse/CRIU-96

v2: use iptables-restore to apply whole configuration for one call
v3: add a comment why we use iptables-restore instread of iptables.
v4: remove unused headers
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-19 17:17:07 +03:00
Cyrill Gorcunov
7de345d6b7 net: Move node's net fd reference into service fd
So we keep it and dont close inside close_old_fds()
helper but pass into veth creation so the kernel
can fetch the net namespace of the veth peer.

v2 (by avagin@):
 - don't forget to close opened descriptor

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-19 16:46:36 +03:00
Andrew Vagin
3db63c4297 parasite-syscall: print an error message only in error cases
This patch suppresses these fake errors:

./socket-tcp6-local --pidfile=socket-tcp6-local.pid --outfile=socket-tcp6-local.out
Dump 5921
(00.041988) Error (parasite-syscall.c:388): si_code=1 si_pid=5936 si_status=0
(00.051210) Error (parasite-syscall.c:388): si_code=1 si_pid=5937 si_status=0
(00.070800) Error (parasite-syscall.c:388): si_code=1 si_pid=5938 si_status=0
(00.077582) Error (parasite-syscall.c:388): si_code=1 si_pid=5939 si_status=0
(00.091313) Error (action-scripts.c:59): One of more action scripts failed
Check results 5921
18:39:14.451:  5921: PASS
Test: zdtm/live/static/socket-tcp6-local, Result: PASS
ZDTM tests PASS.

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-19 15:34:14 +03:00
Andrew Vagin
9d59bc14ef restore: always kill tasks in error cases
Reported-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Cc: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-19 15:23:49 +03:00
Andrew Vagin
2f7407342a zdtm: clean up *.init.pid
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-19 15:22:08 +03:00
Andrew Vagin
1e8a0594db net: dump iptables for ipv6 (v2)
v2: don't dump iptables if ipv6 isn't supported
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-19 15:19:01 +03:00
Andrew Vagin
1648db970c kerndat: check whether ipv6 is supported or not (v2)
v2: use a cached value to dump ipv6 interface addesses
    call get_ipv6() from kerndat_init_rst too

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-19 15:18:08 +03:00
Andrew Vagin
c0bc79d92e zdtm: allow to execute tcp tests in network namespaces
Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-19 15:17:50 +03:00
Andrew Vagin
a2780c6131 lock: futex() with timeout isn't restarted after signals (v2)
It returns EINTR, so we need to handle it.

$ bash test/zdtm.sh --restore-sibling ns/static/env00
...
futex(0x7fc20ec92010, FUTEX_WAIT, 1, {120, 0}) = ? ERESTART_RESTARTBLOCK (Interrupted by signal)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-19 15:15:39 +03:00
Pavel Emelyanov
8f36b7af2f zdtm.py: Ability to generate criu strace-s for sat.py
There's a sat.py script in criu-scripts repo that analyzes the strace
outputs. It's useful to check the amount of system calls criu takes to
do dump or restore of certain apps.

So add the --sat key to zdtm.py that would generate sat-able logs for
individual tests.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-17 13:13:52 +03:00
Pavel Emelyanov
8e30ef722c zdtm.py: Properly report FAIL if test dependency file doesn't exist
Right now report looks like generic python exception about
inability to copy some file.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-17 10:54:13 +03:00
Cyrill Gorcunov
fa902be145 cr-service: Use xmalloc helpers
It's safer than alloca() calls.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-17 10:53:03 +03:00
Cyrill Gorcunov
da429bd433 lib: Don't use alloca over net received size
Better to obtain error if there is no free memory
than smashing the stack.

A rule of thumb for alloca() based functions is to
use them with predefined small sizes (such as we
do in swapping builtin sizes for parasite engine).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2015-11-17 10:53:02 +03:00