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

4796 Commits

Author SHA1 Message Date
Andrey Vagin
deeea1d221 zdtm/socket-tcpbuf: heartbeat should not read all data
Currently we fill as much as posible data in a socket and then use
half of these data to make a flow in the connection.

These data is send and recv buffers. When a connection is dumped and
restored, it needs time to go back to the normal work. In this time we
can reliably fill only send buffers. So at the result the sockets may
contain less data than required for heartbeating and the test will
block.

The test with this patch will monitor actuall size of data in a test
socket.

Cc: Konstantin Neumoin <kneumoin@parallels.com>
Reported-by: Konstantin Neumoin <kneumoin@parallels.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-27 21:31:09 +04:00
Cyrill Gorcunov
5676383729 scripts: Add ACT_MAX limit and make @action_names being const
@action_names is rather a const array, so make
sure we never access some data outside of it
defining its size.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-27 21:30:37 +04:00
Andrey Vagin
02d9bd1093 zdtm: check that process w/o file descriptors can be dumped and restored
In addition it checks that criu closes all its descriptors

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-27 21:29:21 +04:00
Cyrill Gorcunov
4135f6cd1c proc_parse: parse_smaps -- Use @file_path instead of strstr helper
strstr is a really heavy one, lets use already defined
and filled @file_path variable instead.

Reported-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-27 21:28:18 +04:00
Cyrill Gorcunov
d7865bee7a test: shm -- Make sure SysV memory restored properly
In criu we carry SysV memory via @VMA_AREA_SYSVIPC
attribute but to the test must have a live reference
to real memory area to check that shmem address was
restored correctly. Add it.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-27 21:26:45 +04:00
Cyrill Gorcunov
c2cae35870 prctl: check -- Try new interface as well
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-27 21:25:36 +04:00
Cyrill Gorcunov
1a2ed27bdb prctl: restore -- Use new PR_SET_MM_MAP if kernel supports
This would allow to restore parameters with user namespaces
enabled.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-27 21:25:28 +04:00
Cyrill Gorcunov
8c40f43018 prctl: Add new interface constants
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-27 21:25:25 +04:00
Cyrill Gorcunov
a9c724142d tty: Fix path inversion for /dev/pts/ptmx
Need to compare the /pts/ part in the
former path, otherwise it will produce
bogus /dev/pts/pts/index form.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 22:14:41 +04:00
Pavel Emelyanov
fb54345e08 parasite: Don't keep code_orig on parasite_ctl
We need this only once -- while calling the mmap from remote
context -- so it's enough to have on-stack variable.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
2014-10-23 20:30:34 +04:00
Cyrill Gorcunov
a90172df43 reg-files: Don't mangle ghost directories
Because directories are opened via direct mkdir
call with name taken from ghost path don't postfix
it with cr.%x.ghost, otherwise that's the name
directory will have after restore complete causing
cwd01 test to fail.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 20:27:38 +04:00
Andrey Vagin
406b6b4237 zdtm: always show errors
Users don't like errors even if criu returns zero.
So I suggest to start looking at them.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 20:15:11 +04:00
Andrey Vagin
f32fa08d0f zdtm/Makefile: show output for each test
In this case we have another chance to not skip errors.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 20:13:50 +04:00
Cyrill Gorcunov
b12072b979 mount: Allow to c/r empty mqueues
We don't support posix mqueues at the moment
but in case if this fs is simply mounted and
not used lets proceed without errors.

In case if someone is using it we detect it
because fs won't be empty and refuse to dump.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 20:06:43 +04:00
Konstantin Neumoin
3ecd7f2d14 zdtm:Makefile increase wait timeout
This timeout is too small for tcp test cases.
This timeout should be bigger than TCP_RTO_MAX 120 seconds

Signed-off-by: Konstantin Neumoin <kneumoin@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 20:03:21 +04:00
Andrey Vagin
6084e1d08b zdtm/static/xids00: print more information about errors (v2)
v2: typo fix
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 20:02:29 +04:00
Andrey Vagin
1a3fc94c57 zdtm/maps01: extend maps01
It's bad idea to have only one target object.
In addition I add a shared region to the second process,
which is not mapped in the first.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 19:57:14 +04:00
Andrey Vagin
901c8754d4 shmem: use memfd_create() to restore shared memory reqions (v2)
/proc/PID/map_files are protected by the global CAP_SYS_ADMIN, so we
need to avoid using them to support user namespaces.

We are going to use memfd_create() to get the first file descriptor and
then all others processes will able to open it via /proc/PID/fd/X.

In this patch memfd_create() is used to get a file descriptor, which is
associated with a shared memory region.

If memfd_create() isn't supported, the old scheme will be used.

v2: don't set a name for memfd. It isn't required.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 19:57:13 +04:00
Andrey Vagin
2c65748f74 shmem: rework getting file descriptors for shared memory regions (v2)
/proc/PID/map_files are protected by the global CAP_SYS_ADMIN, so we
need to avoid using them to support user namespaces.

We are going to use memfd_create() to get the first file descriptor and
then all others processes will able to open it via /proc/PID/fd/X.

This patch reworks slave processes to not use map_files.

v2: add more comments
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 19:57:12 +04:00
Andrey Vagin
de71c48079 syscall: add memfd_create() (v3)
v2: Follow the kerndat style that "features" are described
just by global boolean variables.

v3: give NULL as a name to get EFAULT if memfd_create is supported
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 19:57:10 +04:00
Cyrill Gorcunov
caa64d974d tty: Use regular files engine to save paths to the peers, v5
Currently we're using predefined format for master/slave pty peers:
masters are always /dev/ptmx, while slaves are /dev/pts/$index,
where $index is the peer number.

While fitting most of distros this is not always correct and slave peers
might be mounted to an arbitrary place, so that we need to somehow
carry paths with ourself in image.

Instead of bloating current tty image lets use regular file engine instead
and on checkpoint stage save a path to the link in regfiles set, then on
restore simply fetch it from the image.

Such approach will help in future when we need to support multiple
instances of devpts filesystem.

To support backward compatibility with images where no regfile
records are present we generate new one on the fly in
pty_alloc_reg() helper.

Because of the need to restore dead slave peers and restore of
the controlling terminal we need to generate that named "fake
inverted" pty_alloc_fake_reg() helper: in particular if
we need to open dead slave peer we generate fake master peer,
open it and the close out. Almost the same situation in
restoring contolling terminal -- we get master peer, generate
appropriate fake slave object, open it, manipulate, then
close it out and free.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 17:54:23 +04:00
Cyrill Gorcunov
8644d2ba83 files-reg: Add try_collect_special_file
The idea is to be able to lookup for special id
which might be not present and we should not
yield the error.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 17:51:49 +04:00
Cyrill Gorcunov
cb546f8448 files-reg: Don't generate ghost files for hanged out slave pty peers
We will use reg-files engine for tty c/r so lets prepare scaffolds
here preventing the engine to generate ghost files for PTY peers
(mostly because one can't create slave peers without opening
 master peers first which is a sole part of tty engine itself).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 17:51:37 +04:00
Cyrill Gorcunov
4b9406eae2 files-reg: Strip off "(deleted)" postfix on ghost files
Otherwise this postfix will be accumulated on
subsequent checkpoints.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 17:51:35 +04:00
Cyrill Gorcunov
a944a78ce9 files-reg: Export do_open_reg_noseek_flags
We will need it for tty restore.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 17:51:33 +04:00
Cyrill Gorcunov
81c598cc05 files: Add file_desc_init helper
To use it in tty code even when file
descriptor is not added into files chain.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 17:51:32 +04:00
Cyrill Gorcunov
09aa15c7a3 tty: Parse slave peer index from fd_parms
We will use this path in reg-files engine anyway
so simply switch to this ability now.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 17:51:30 +04:00
Cyrill Gorcunov
d6e231ae09 tty: parasite -- Don't call for TIOCGPKT/TIOCGPTLCK on non-ptys
We will have to support more tty types in future so
make calls depending on type of ttys.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 17:51:27 +04:00
Cyrill Gorcunov
bcc1f4eb72 tty: Introduce tty types
Instead of calling case() with majors all over the places lets
introduce own enum for tty types and use it instead.

Because we're using not @major numbers now but taking @minors
into account as well, this brings more strict check of which
kind of terminals we can dump now thus it's potentially should
fix the cases when we're trying to c/r terminals which we don't
understand yet (in particular /dev/console [5:1]).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-23 17:51:26 +04:00
Andrey Vagin
9498609f89 dump: don't play with a function exit code
We should not have a chance to exit with a wrong code on error paths.

Now dump_one_task() returs zero, if allocation of dfds failed:

ret = collect_mappings(pid, &vmas);
if (ret) {
	pr_err("Collect mappings (pid: %d) failed with %d\n", pid, ret);
	goto err;
}

if (!shared_fdtable(item)) {
	dfds = xmalloc(sizeof(*dfds));
	if (!dfds)
		goto err;

...
err:
	return -1;

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-17 17:22:49 +04:00
Pavel Emelyanov
198c93656c pstree: Add helper for adding helpers to pstree
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-14 18:02:36 +04:00
Pavel Emelyanov
87d68fcafd mnt: Use ns walking helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-14 18:01:56 +04:00
Pavel Emelyanov
a36917d4f2 mnt: Clean up namespaces walking code
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-14 18:01:44 +04:00
Pavel Emelyanov
2d3fa5e7d0 net: Use ns walking helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-14 18:01:38 +04:00
Pavel Emelyanov
16971e47cd ns: Introduce ns walking helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-14 18:01:27 +04:00
Andrey Vagin
e1072b935a travis: add compilation of tests
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-14 14:22:01 +04:00
Tycho Andersen
2b5d06817f dump: pre-load kernel modules
See the comment below for an explanation of what is going on. We will
ultimately need to handle dumping the netlink data, but I think it is good to
prevent injecting events into the stream during a dump. So we pre-load the
modules, even though it isn't very pretty.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-14 14:21:05 +04:00
Andrey Vagin
8764e7450c check: make check_ptrace_peeksiginfo and check_sigqueuinfo as static
They are not used outside.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-14 10:50:54 +04:00
Andrey Vagin
434879c043 restore: clear breakpoints only for alive tasks
We don't set breakpoints for zombies.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-14 10:44:50 +04:00
Andrey Vagin
21d1b2fdb9 mount: don't create a temporary directory for pivot_root()
I found this solution in the LXC code. We can open the old root, call
pivot_root(".", "."), call fchdir to the old root and call umount(".").

Now restore will not fail, if the root is read-only.
In addition it's a bit faster.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-09 19:19:28 +04:00
Konstantin Neumoin
c4a06a2a26 zdtm/stopped: fix stopped test
The main problem with the
test that it's never 'fail'.
Test can only 'pass' or hangs.

Signed-off-by: Konstantin Neumoin <kneumoin@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-09 19:17:59 +04:00
Pavel Tikhomirov
ffe3d5cfda add int(CTL_32)
Signed-off-by: Pavel Tikhomirov <ptikhomirov@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-08 19:23:24 +04:00
Tycho Andersen
66d1a60ed4 restore: don't race when closing cg yard
TASK_HELPERs are created with CLONE_FILES, so if we always close the cg yard
here, it will close it for the other helpers and cause problems. Instead, we
close it much later, in code only called by alive tasks, to ensure that there
is no conflict.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-08 19:08:12 +04:00
Cyrill Gorcunov
8c1a35b8d5 tty: proto -- Add comments on some fields
Actually these @locked and @packet_mode are
valid for unix98 ptys only so since moving
them into @tty_pty_entry is impossible at
least lets comment this.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-08 18:53:52 +04:00
Cyrill Gorcunov
bc5fcaa777 tty: collect_one_tty -- Use tty_is_master helper
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-08 18:53:34 +04:00
Cyrill Gorcunov
87418490e5 tty: Rename helpers to reflect the type of peers
- parse_index -> parse_pty_index since it's PTY specific
 - pty_is_master -> tty_is_master because it will test
   not only PTY peers but other types as well
 - pty_is_hung -> tty_is_hung for same reason

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-08 18:52:23 +04:00
Cyrill Gorcunov
d311fd3e46 tty: Add some comments about console and bsd terminals
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-08 18:50:33 +04:00
Cyrill Gorcunov
9b5e050906 tty: Instead of BUG_ON exit out with error early
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-08 18:50:04 +04:00
Cyrill Gorcunov
b708a7d549 tty: Align members in assignments
For readability sake.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-08 18:49:47 +04:00
Christopher Covington
f3afc1da12 AArch64: Remove TASK_SIZE from mmap_seized
TASK_SIZE for AArch64 may be any of several options between (1 << 39)
and (1 << 48), inclusive, depending on kernel configuration. Go back
to just checking the most significant bit, as was done before commit
3f12d688ae563b91d8a738d68902ea2e23f2b59c was made to accomodate 32-bit
ARM (before mmap_seized got architecture-specific implementations).

This fixes the following error for AArch64 kernels with
CONFIG_ARM64_64K_PAGES=y.

Error (parasite-syscall.c:1105): Can't allocate memory for parasite blob (pid: 104)

Signed-off-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-10-07 15:46:47 +04:00