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

4796 Commits

Author SHA1 Message Date
Pavel Emelyanov
0a11aa1ff9 locks: When checking for lock being ours handle mand-locks
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 19:09:45 +04:00
Pavel Emelyanov
180005645c locks: Split lock-in-fd check in a helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 19:09:43 +04:00
Andrey Vagin
3a6f57cbce fsnotify: fix exit code of dump_inotify_entry()
Return 0 in a success case

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 17:56:48 +04:00
Pavel Emelyanov
d58aafc447 dump: Don't allocate dfds in case we dump shared fdtable
After patches, that dump locks w/o dfds array, we can even
not allocate one when we don't need it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 17:45:29 +04:00
Pavel Emelyanov
2c765509f5 test: Check that criu's donwgrading quirk works
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 17:44:58 +04:00
Pavel Emelyanov
96e6ea5ae7 test: Check that overlapping locks work
If we open a file, lock one, fork, then close and
open the file in parent again, lock should 'slide'
to the child process anyway.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 17:44:54 +04:00
Pavel Emelyanov
92a7cf59ad test: Check that inherited flocks work
Inherited flock is the one that a task got from its parent.
In case parent closes the corresponding fd, the /proc/locks
still shows the parent pid, while the lock is owned by child.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 17:44:53 +04:00
Pavel Emelyanov
b593024dd6 test: Check that shared locks work
Shared here means that a flock is visible from two tasks -- the
owner one and its child.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 17:44:50 +04:00
Pavel Emelyanov
53537f52c8 locks: Don't dump locks in per-task manner (v3)
We have a problem with file locks (bug #2512) -- the /proc/locks
file shows the ID of lock creator, not the owner. Thus, if the
creator died, but holder is still alive, criu fails to dump the
lock held by latter task.

The proposal is to find who _might_ hold the lock by checking
for dev:inode pairs on lock vs file descriptors being dumped.
If the creator of the lock is still alive, then he will take
the priority.

One thing to note about flocks -- these belong to file entries,
not to tasks. Thus, when we meet one, we should check whether
the flock is really held by task's FD by trying to set yet
another one. In case of success -- lock really belongs to fd
we dump, in case it doesn't trylock should fail.

At the very end -- walk the list of locks and dump them all at
once, which is possible by merge of per-task file-locks images
into one global one.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 17:44:46 +04:00
Pavel Emelyanov
efac9ed8b3 locks: Parse lock type earlier
Same reason as for previous patch.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 17:44:39 +04:00
Pavel Emelyanov
0095b40a29 locks: Parse lock kind earlier
Currently we keep the lock type (posix/flock) till the
time we dump it, then "decode" it into binary value.
I will need the easy-to-check one early, so parse the
kind in proc_parse.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 16:39:09 +04:00
Pavel Emelyanov
8ef0f6b7e6 locks: Remove unused arg from dump_one_file_lock
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 16:38:52 +04:00
Andrey Vagin
961655dc02 util: add a function to check output data in a file descriptor
We can't dump netlink socket, inotify, fanotify, if they have queued
data, so lets add a function to chech this.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 16:25:50 +04:00
Ruslan Kuprieiev
9089ce89c4 service: use setproctitle
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Acked-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 16:15:20 +04:00
Ruslan Kuprieiev
5e58a5dc9f crtools: check for setproctitle_init
Check for setproctitle_init, as old versions of libbsd don't have one.

Reported-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Acked-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 16:14:39 +04:00
Ruslan Kuprieiev
2144583732 include: add setproctitle.h
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Acked-by: Kir Kolyshkin <kir@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 16:14:37 +04:00
Andrey Vagin
c5d238ef66 zdtm/fanotify00: use /tmp instead of /
Usually /tmp is a mount point.

Recently we found a bug in criu, when it restore mount fanotify on "./"
instead of "/". The test didn't find it, because they are pointed on the
same mount point.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 16:12:32 +04:00
Andrey Vagin
473a81df74 zdtm: chech that a mark is restored on a correct mount point
We try to remove mark on the correct mount point and
if the mark is restored on a wrong mount point, we will get ENOENT.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 16:12:16 +04:00
Andrew Vagin
6e3028fa52 fsnotify: open mount point relative to a proper root
Each mountpoint belongs to a mount namespace, so we need to
find a root of the mount namespace and open mountpoint
ralative to this root.

The same logic is used in get_mark_path().

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 16:12:11 +04:00
Andrew Vagin
dd63975bdc test: don't clean up submounts (v2)
I'm scared, when I see smth like that:
rm: cannot remove ‘/var/lib/jenkins/jobs/CRIU/workspace/test/dump/static/cgroup00/31195/1/.criu.cgyard.6qctPl/systemd/tasks’: Operation not permitted

v2: do that only in the "test" directory

Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 16:11:02 +04:00
Andrey Vagin
5d9b3612a6 test: clean the "test" directory from test/Makefile
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 16:10:55 +04:00
Andrey Vagin
5ed2004733 dump: clean up shared_fdtable
It's cleaned up accoding with following statements:
* files_id can't be zero (look at dump_task_kobj_ids)
* item->ids is allocated for all non-dead tasks
* a parent can't be dead

In addition here is a tiny coding stype fix.

Fixes: 475bb1e77522 ("rst: Evaluate per-task clone mask early")
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 16:10:14 +04:00
Andrey Vagin
33c75d0df9 eventpoll: parse_fdinfo_pid_s() returns allocated object for eventpol tfd
We are going to collect all objects in a list and write them into
the eventpoll image. The eventpoll tfd image will be depricated.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 16:08:17 +04:00
Andrey Vagin
78a54bd87c fsnotify: parse_fdinfo_pid_s() returns allocated object for fanotify marks
We are going to collect all objects in a list and write them into
the fanotify image. The fanotify mark image will be depricated.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 16:07:44 +04:00
Andrey Vagin
7079bb1086 fsnotify: parse_fdinfo_pid_s() returns allocated object for inotify wd (v2)
We are going to collect all objects in a list and write them into
the inotify image. The inotify wd image will be depricated.

v2: cb() must always free an entry
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-09-02 16:07:43 +04:00
Pavel Emelyanov
c716f6b8a3 criu: Version 1.3
It's been a long delay since 1.2, but we did it :)

The greatest new acheivement is finally support for Docker
and LXC on CRIU side. Some work is still to be don on the
other, but here in CRIU everything is ready.

Another notable things are AArch64 support and, of course,
a lot of bugfixes.

Further plan is to make releases be not so rare :)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
v1.3
2014-09-01 14:18:37 +04:00
Tycho Andersen
4b4ec8ff61 restore: die properly if restore_one_task fails
This is really just the last bit of c32046c9; if restore_one_task() fails, we
need to do the same futex wakeup we do everywhere else in this function.

v2: use err instead of err_fini_mnt after mount has been finalized normally

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-29 19:34:59 +04:00
Pavel Tikhomirov
59c968a3bf zdtm: test that UNIX socket owner/group don't change
In container c/r(OVZ) UNIX socket uid and gid restored from
connected peer credentials instead of inode once.

https://bugzilla.openvz.org/show_bug.cgi?id=2969

changes:
v2 - cleanup headers, close socket, use err instead fail,
print id's on error.
v3 - wrong patch
v4 - move to sockets00, correct patch-message
v5 - minor cleanup

Signed-off-by: Pavel Tikhomirov <ptikhomirov@parallels.com>
Acked-by: Andrey Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-29 16:53:07 +04:00
Tycho Andersen
dd375cebc9 restore: don't restore cg props if task restore fails
Once the task restore has failed, we can just abort, no need to restore the cg
props.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-28 18:54:22 +04:00
Tycho Andersen
c32046c9a4 restore: die if init fails in --restore-detached mode
When in --restore-detached (i.e. root_as_sibling) mode, we ptrace(PTRACE_SEIZE)
the root task to receive its SIGCHLD in case one of its child tasks dies.
However, we don't receive a SIGCHLD if the root task itself dies, so we must
explicitly abort.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-28 18:53:35 +04:00
Filipe Brandenburger
2e5e3e4b18 zdtm: fallback to mknod(/dev/ptmx) when CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
A kernel without that option configured does not have /dev/pts/ptmx, so
fallback to the previous way of creating it using mknod instead.

The previous code was trying to bind mount ptmx on top of a symlink, which does
not actually work... Keep only the symlink call and use a relative symlink
instead. Adjust the error message of the symlink case to mention symlink()
instead of mknod() and also /dev/ptmx instead of /dev/pts.

Tested:
- zdtm test suite runs on ^ns/static/.* before and after the change.
- Same on a kernel with CONFIG_DEVPTS_MULTIPLE_INSTANCES unset.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
Acked-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-27 15:06:21 +04:00
Saied Kazemi
9eec8b03af Use --root instead of --aufs-root
When dumping Docker containers using the AUFS graph driver, we can
use the --root option instead of --aufs-root for specifying the
container's root.  This patch obviates the need for --aufs-root
and makes dump CLI more consistent with restore CLI.

Signed-off-by: Saied Kazemi <saied@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-27 14:31:40 +04:00
Andrey Vagin
457a70dabb zdtm: don't hide errors in cgroup02.hook
rmdir is executed for non-existent directories, so we don't check
an exit code of this operation.

This patch executs rmdir only for existent directories and check
an exit code of rmdir.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-26 21:34:58 +04:00
Andrey Vagin
02ecc82287 jenkins: exclude static/cgroups02 from the criu-dump job (v2)
In this job tests are dumped and resumed. The cgroup02 test checks,
that it is moved in another set of cgroups, but this is done on restore.

Output file: test/zdtm/live/static/cgroup02.out>
------------------------------------------------------------------------------
14:35:55.127:    85: found cgroup at cgroup02.test/zdtmtst>
14:35:55.127:    85: found cgroup at cgroup02.test/defaultroot>
14:35:55.127:    85: FAIL: cgroup02.c:132: oldroot not rewritten to zdtmtstroot!

v2: typo fix
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-26 14:54:09 +04:00
Filipe Brandenburger
104eeb7eb6 zdtm: add missing entries to zdtm .gitignore
Signed-off-by: Filipe Brandenburger <filbranden@google.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-26 13:09:11 +04:00
Filipe Brandenburger
f1015d6c58 zdtm: sort .gitignore entries
Signed-off-by: Filipe Brandenburger <filbranden@google.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-26 13:09:03 +04:00
Filipe Brandenburger
3b9e9b84f2 test: enhance library lookup when building mntns root
Use a single awk script to parse the ldd output. Filter out other cases that
are clearly not libraries, such as static builds ("not a dynamic executable")
and linux-gate.so. Make the grep for vdso more specific into linux-vdso.so.

Tested:
- sudo test/zdtm.sh '^ns/.*'

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-26 13:08:56 +04:00
Filipe Brandenburger
3a8cf03d94 test: replace use of pcre grep with awk
Unfortunately, grep -P is not ubiquitous, so use awk with two regexps to
simulate the negative forward lookup in the grep -P expression.

Using awk doesn't really make it too unreadable, as using boolean operators
such as && and || might actually make it more intuitive than the extended
regexp.

Tested:
- sudo make -C test zdtm_ns
- sudo make -C test zdtm_nons

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-26 13:08:49 +04:00
Pavel Emelyanov
ee8cd3c261 test/cgroup02: Clean newroot dir from all controllers in hooks
From avagin@:
  And here is one more problem. the newroot directory is created for all
  controllers, but currently test cleans up it only for the zdtmtst
  controller. We need to find a way to clean up all other conntrollers.
   Tests are executed on a node, which is rebooted only for updating
  kernel, so if we will not clean up all other controllers, we can eat all
  memory.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Tested-by: Andrew Vagin <avagin@openvz.org>
2014-08-26 12:54:40 +04:00
Andrey Vagin
6eab073c07 zdtm: fix compile errors of zdtm_ct
When "make test" is executed, CFLAGS is exported from the root Makefile.
These flags define _GNU_SOURCE, so we don't need to define it in the
souce file.

In addition unistd.h isn't included, so a few functions are shown as undeclared.

make zdtm_ns
make[3]: Entering directory `/root/criu/test'
gcc  -O2 -Wall -Werror -DCONFIG_X86_64 -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE    zdtm_ct.c   -o zdtm_ct
zdtm_ct.c:1:0: error: "_GNU_SOURCE" redefined [-Werror]
 #define _GNU_SOURCE
 ^
<command-line>:0:0: note: this is the location of the previous definition
zdtm_ct.c: In function ‘main’:
zdtm_ct.c:21:2: error: implicit declaration of function ‘fork’ [-Werror=implicit-function-declaration]
  pid = fork();
  ^
zdtm_ct.c:23:3: error: implicit declaration of function ‘setsid’ [-Werror=implicit-function-declaration]
   if (setsid() == -1) {
   ^
zdtm_ct.c:49:3: error: implicit declaration of function ‘execv’ [-Werror=implicit-function-declaration]
   execv(argv[1], argv + 1);
   ^
zdtm_ct.c:62:3: error: implicit declaration of function ‘getpid’ [-Werror=implicit-function-declaration]
   kill(getpid(), WTERMSIG(status));
   ^
cc1: all warnings being treated as errors

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Tested-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-26 12:52:39 +04:00
Andrew Vagin
28b0e16d73 cgroup: call fin_cgroup() on error paths
fini_cgroup umounts a cgyard directory, which is mounted
in prepare_cgroup().

Reported-by: Mr Jenkins
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-26 12:51:42 +04:00
Andrew Vagin
c5c7272c50 cgroups: don't take into account a leading / for the "/" parent
Without this patch, we dump somethin like this:
{
	cnames: "hugetlb"
	dirs: 	{
		dir_name: ""
		children: 		{
			dir_name: "ewroot"
			children: <empty>
			properties: <empty>
		}

		properties: <empty>
	}

}

It's obvious, that dir_name should be newroot.

The problem is reproduced, if a task leaves in "/" and has a subgroup.
This issue was caught by a chance. The cgroup02 test doesn't clean up
controllers and leaves the "newroot" there. So when we executed a cgroup
test after cgroup02, we could find many directories like "ewroot",
"wroot", etc. This patch fixes this issue.

Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-26 12:51:06 +04:00
Filipe Brandenburger
601e5bb485 crtools: bump up the getopt return values to outside the ascii range
The return values were getting dangerously close to the range of meaningful
values, in particular the next candidate 63 is equal to '?' which is the
typical return value in case of error.

The return values for long options may be any integer, so bump them up to
outside the ascii range, start above 1000. For ease of review this patch, keep
the existing range (41-62) and increment each value by 1000.

Tested:
- Ran "criu --help", works fine.
- Manual dump and restore with some of the options, worked fine.
- Ran the zdtm test suite, tests passed.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-26 12:49:42 +04:00
Andrey Vagin
8f17b34abb criu: Drop redundant newline from pr_perror
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-22 19:22:39 +04:00
Pavel Emelyanov
f74ed43d0f libcriu: Add criu_add_cg_root() call
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
2014-08-22 19:20:06 +04:00
Pavel Emelyanov
070757c142 rpc: Add "cgroup root" fields to criu_opts
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
2014-08-22 19:20:04 +04:00
Pavel Emelyanov
7947ea7111 crtools: Make new_cg_root_add setup global root too
This is to make it convenient for service to setup the same thing.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
2014-08-22 19:20:03 +04:00
Pavel Emelyanov
ad4d91241a Revert "zdtm: Remove cgroup02 out of runlist"
This reverts commit 4778cb30bbd47e4ddcf9587498c540d651575e2a.
2014-08-22 19:17:42 +04:00
Tycho Andersen
8323e21458 cg: restore special cpuset properties
cpuset.cpus and cpuset.mems can't be written to for the first time after they
have tasks, so the traditional mechanism of restoring properties after
restoring the tasks won't work here. Instead, we copy the parent values of the
properties into them, restore the tasks, and then restore via the traditional
mechanism the actual values of these properties.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-22 19:17:32 +04:00
Tycho Andersen
d76f3ad386 cg: allow properties that aren't integers
In particular, cpuset.cpus and cpuset.mems can both be "lists" (strings), as
well as hex integers. We don't use the result of this parse, so it is fine to delete it.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-22 19:17:30 +04:00