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

4661 Commits

Author SHA1 Message Date
Cyrill Gorcunov
994ae676b4 restore: Set CLONE_PARENT iif pdeath_sig is present, v4
It's been discovered that on 3.11 we might fail on restore
if pass @CLONE_PARENT flag into clone() call due to kernel
limitations.

Because we're treating 3.11 as a base working kernel lets
do a trick instead

 - setup this flag iif pdeath_sig is present
 - if CLONE_NEWPID is passed warn a user about
   potential consequences.
 - because we need to carry the condition in attach_to_tasks
   call, introduce @root_as_sibling variable for this.

CC: Tycho Andersen <tycho.andersen@canonical.com>
CC: Pavel Emelyanov <xemul@parallels.com>
CC: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-15 13:26:36 +04:00
Andrey Vagin
47fae013b5 zdtm: add a small program to create a zdtm container (v2)
I didn't find a way how to do that with help "unshare".
It's simpler to write this program. It looks better than tricks in
zdtm.sh.

v2: proxify exit status

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Ruslan Kuprieiev <kupruser@gmail.com>
Acked-by: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-14 18:28:38 +04:00
Andrey Vagin
0b33bac3bc criu: allow the root task to handle SIGCHLD
If criu process attaches to the root task (it happens for opts.swrk_restore
and opts.restore_detach) with ptrace, then any signal delivered to the root
would be also delivered to criu. The latter woult treat the former to die
due to this delivery and would abort the restore.

Fix it by checking that criu (current == NULL) gets ptrace notification
(si_code == CLD_TRAPPED) about signal delivered (si_status = SIGCHLD,
no other signals are allowed by the restoring tasks).

This patch fixes the following error of static/zombie00:

Execute zdtm/live/static/zombie00
./zombie00 --pidfile=zombie00.pid --outfile=zombie00.out
Dump 2207
Restore
Test: zdtm/live/static/zombie00, Result: FAIL
==================================== ERROR ====================================
Restore log: /root/git/orig/criu/test/dump/static/zombie00/2207/1/restore.log
(00.026826) Error (cr-restore.c:1085): 2207 killed by signal 17
(00.026985) Error (cr-restore.c:1706): Restoring FAILED.
================================= ERROR OVER =================================

Reported-by: Mr Jenkins
Cc: Pavel Emelyanov <xemul@parallels.com>
Cc: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-14 17:09:53 +04:00
Pavel Emelyanov
bcd1649699 cg: Use relative paths in cgroup dirs image
Before the patch cg tree section from cgroup00 test looked like this

{
	cnames: "name=zdtmtst"
	dirs: 	{
		path: "/subcg"
		children: 		{
			path: "/subcg/subsubcg"
			children: <empty>
			properties: <empty>
		}

		properties: <empty>
	}

}

this /subsg in the children is excessive. Turn this into directory names.
Now the section looks like

{
	cnames: "name=zdtmtst"
	dirs: 	{
		dir_name: "subcg"
		children: 		{
			dir_name: "subsubcg"
			children: <empty>
			properties: <empty>
		}

		properties: <empty>
	}

}

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
2014-08-14 12:27:19 +04:00
Pavel Emelyanov
bf91821f11 cg: Fix restoration of tasks into existing cgroups
When we omit the --manage-cgroups on dump the controllers section
in cgroups image lacks the none-d entries (the name=systemd is the
most typical).

If it happens, that init task lives in non-criu cgset (it can be
so if we do --shell-job dump from another terminal and see criu
and root task living in different user.slice systemd cgroups) then
on restore the move_in_cgroup() would fail to lookup the required
controller.

In order to fix this we should still call the collect_cgroups()
on dump, so that it adds the none-d controllers into the list,
but don't dump the dirs tree itself.

The patch looks ugly, but it just moves the current_controller
evaluation from the middle of the loop upwards (and renames the
char *opts variable not to conflict with global opts).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
2014-08-14 12:26:56 +04:00
Tycho Andersen
e301b1d56c restore: --restore-detached implies CLONE_PARENT
We need to use CLONE_PARENT to prevent processes from immediately dying due to
pdeath_sig when they are restored in detached mode.

[ xemul: One more place which requires check for restore-detach
         is in sigactions preparation ]

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-14 12:25:07 +04:00
Andrey Vagin
9d4e5370f1 zdtm/ipc_namespace: set the auto_msgmni sysctl to zero
We are going to execute tests concurrently, but if auto_msgmni is
enabled, the msgmni is recalcalated each time, when ipcns is created
or removed.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-14 12:21:53 +04:00
Andrey Vagin
edca5ab0af sysctl: don't write '\0' at the end of buffer in a sysctl file
It isn't required. The kernel has a bug in handling auto_msgmni and
if we send extra symbols, a new value isn't applied.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-14 12:21:48 +04:00
Andrey Vagin
64405c1d5b ipc: set the msgmni sysctl after auto_msgmni
Because setting of auto_msgmni recalculates a value of msgmni

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-14 12:21:43 +04:00
Andrey Vagin
20578e63cf zdtm/ipc_namespaces: don't extra symbols in a sysctl file
The kernel has a bug in handling auto_msgmni and if we send extra
symbols, a new value isn't applied.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-14 12:21:38 +04:00
Andrey Vagin
6705051282 syscall: don't use pr_info to print a part of string
Before:
(00.009468)     87: sysctl: <kernel/sem> = <(00.009475)     87: 2108913153 (00.009481)     87: 1252387386 (00.009486)     87: 835139248 (00.009491)     87: 320896030 (00.009496)     87: >
After:
(00.009468)     87: sysctl: <kernel/sem> = <2108913153 1252387386 835139248 320896030 >

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-14 12:20:36 +04:00
Cyrill Gorcunov
d7ff4a1319 test: bers -- Add short help output
Reported-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-13 15:50:54 +04:00
Sophie Blee-Goldman
3faaed2f64 Bug-fix in size calculation
Fixes a bug in how PARASITE_MAX_GROUPS was calculated, and adds a
compiler check to assert that parasite_dump_creds doesn't exceed
the page size.

Signed-off-by: Sophie Blee-Goldman <ableegoldman@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-13 13:04:58 +04:00
Tycho Andersen
ded04267f8 scripts: set CRIU_IMAGE_DIR when running scripts
When doing a restore for LXC, we store some other metadata (which bridge a veth
was on) in the image directory so that the restore script can correctly unlock
a network device and attach it to the right interface. This patch is needed so
that the script can find this metadata.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 22:43:37 +04:00
Pavel Emelyanov
44926184a1 cg: Don't copy path when restoring properties
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 22:32:22 +04:00
Pavel Emelyanov
c5002f7c18 cg: Get yard fd on demand
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 22:32:21 +04:00
Pavel Emelyanov
042538b12c cg: A helper for getting controller's yard dir name (and opts)
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
2014-08-12 22:32:01 +04:00
Pavel Emelyanov
8c0c713626 cg: Check for name= prefix in controller, not cgset
This should be symmetrical with cg dirs creation.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
2014-08-12 22:32:00 +04:00
Pavel Emelyanov
67a65fe368 cg: Strip trailing \n from property's value
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 22:31:58 +04:00
Pavel Emelyanov
cf8b7c8f5c zdtm: Introduce per-test hooks
This is inspired by two problems we have with cgroup* tests.

1. Tests cannot easily clean after themselves -- one cannot
   remove a cg dir with tasks in it and the root task of
   a test is in a cgroup it tries to remove.

2. After dump old cgroup dirs are remained after the test,
   while criu should restore them (this is what we write
   tests for).

The proposal is to introduce per-test hooks, for now two of
them: --pre-restore and --clean. For cgroup tests both hooks
will remove the created directories.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 22:31:57 +04:00
Christopher Covington
513091aa48 zdtm: Make kernel version check more POSIX-like
Arrays and "&&" in test are not supported by Busybox v1.19.4. The
`set` command can put field-separated arguments into the positional
parameters, which is relatively equivalent to using an array.

Signed-off-by: Christopher Covington <cov@codeaurora.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 21:51:15 +04:00
Pavel Emelyanov
371a7092ee cg: Remove write-only variable
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 18:33:29 +04:00
Pavel Emelyanov
a40ab4e372 locks: Dump virtual pid of a lock owner
If we're dumping namespaced tasks, the fl_owner value we see
are the real pids of tasks, while we need virtual ones.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 15:48:31 +04:00
Pavel Emelyanov
536076bd28 show: Print filelocks.img pids as %u
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 15:45:34 +04:00
Andrey Vagin
bb5f5b19c6 zdtm: add ability to execute non-namespacess tests concurrently
For that zdtm.sh is executed in pidns to avoid pid conflicts.

Cc: Christopher Covington <cov@codeaurora.org>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 14:42:34 +04:00
Pavel Emelyanov
15b39a1dd5 pstree: Use task_alive() instead of switch()-es
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 14:41:10 +04:00
Pavel Emelyanov
548625132d pstree: Introduce task_alive() helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 14:41:00 +04:00
Andrey Vagin
ab1be206c3 zdtm.sh: add a test directory name in a path to images
Otherwise static/socket-tcp and streaming/socket-tcp have the same path
to images and they can affect each other.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 14:40:22 +04:00
Pavel Emelyanov
7960379f71 flock: Merge all file lock entries into single image file
They are now in per-pid images, but every entry contains a
pid to which it "belongs". This belonging is fake -- it's
just a pid of a task who placed the lock, while locks really
belong to files. We even have a bug when task that locked
a file exited and "delegated" the lock to its child.

This images merge reduces the amount of image files criu
generates and may simplify the fix of mentioned above issue.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 14:38:49 +04:00
Pavel Emelyanov
4816882da9 img: Add ability to check whether optional image collection happened
A bit later we'd need to check whether cinfo collector
opened an image or not due to file absense.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 14:38:22 +04:00
Pavel Emelyanov
1e3ae669fa flock: Don't hide image read error on flocks restore
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 14:38:16 +04:00
Pavel Emelyanov
2c31147f9d stats: Properly initialize dump stats
They all should be zeroed.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 14:37:51 +04:00
Andrey Vagin
c9228dd809 restore: use /proc/self/mountinfo for collecting mounts fo the root task (v3)
If the root task is forked in a new pidns, it can't use its pid for
accessing /proc, because this proc belongs to the source pidns.

v2: don't copy a static string.
v3: take a bright part of Tycho's patch

Reported-by: Tycho Andersen <tycho.andersen@canonical.com>
Cc: Tycho Andersen <tycho.andersen@canonical.com>
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-12 14:35:25 +04:00
Pavel Emelyanov
7833260baf zdtm: Make cgroup00 test check several tasks and sub-cgroup
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 14:34:36 +04:00
Pavel Emelyanov
5a44f7f43c zdtm: Sanitize cgroup00 test
Prepare it for multiple tasks by moving cg creation and
checking code into helpers.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 14:34:30 +04:00
Pavel Emelyanov
f5e92084ee cg: Don't close cgyard early when inherit cgroups
Fix for closed cgyard descriptor for changed cgroup was 9752c11d.
One more place left.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 14:34:24 +04:00
Tycho Andersen
f95b05eb75 opts: add --manage-cgroups option
criu managed cgroups is now an opt-in thing, so by default criu does not manage
(i.e. dump or restore) cgroups. This allows users to use the previous behavior.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 14:32:50 +04:00
Pavel Emelyanov
8b019e0bb4 mnt: Don't delay external mount points
It looks like criu constantly postpones external bind mounts. I'm trying to resolve
when we manage to break this (when I did ext-mount-map they for some reason didn't).
Meanwhile, this patch fixes it back.

Reported-by: Saied Kazemi <saied@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 14:30:39 +04:00
Christopher Covington
59dae2372a zdtm: Make use of $test consistently
The $test variable was being used without being locally defined in
the start_test function. Define it locally for uniformity with other
functions and use it where convenient. Also make the definition in
case_error local for uniformity with other functions.

Signed-off-by: Christopher Covington <cov@codeaurora.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 14:28:15 +04:00
Christopher Covington
6e9be69f76 zdtm: Replace ps -p with kill -0
The -p argument to `ps` is not supported by Busybox v1.19.4. Sending
signal 0 with the `kill` command is an alternative way to check
whether a process is still running.

http://www.linuxjournal.com/content/monitoring-processes-kill-0

Signed-off-by: Christopher Covington <cov@codeaurora.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-12 14:27:17 +04:00
Andrey Vagin
29a688bb80 zdtm: don't execute mntns_* tests, if the kernel doesn't show mnt_id
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-08 19:22:11 +04:00
Garrison Bellack
5a1b5197c3 Fill out cgroup properties restoration list
Building on top of the cgroup properties infrastructure patch, this patch will
add all the cgroups properties to the static list of properties we want to restore.

Change-Id: I992c260089dcc2ba169a8ac5b19d73f29c678e7d
Signed-off-by: Garrison Bellack <gbellack@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-08 17:06:18 +04:00
Garrison Bellack
4c7bc7678e Cgroup property restoration infrastructure
Restores 2 cgroup properties after the criu restoration of tasks.
Currently the cgroup files to be restored are static but
are easily extendable. To change the properties to be restored,
edit this list at the top of cgroup.c. If a cgroup exists during
restoration, its properties will not be overwritten.
Work based off Tycho Anderson tycho.andersen@canonical.com

Change-Id: Ida32b9773eeac1d4d6e82ad644524ed099d5f9b1
Signed-off-by: Garrison Bellack <gbellack@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-08 17:06:08 +04:00
gbellack
3b0d7fb674 Minor change in protobuf/cgroup.proto numbering
Change-Id: Idaf8689188041c848126beb9c401bd90d0e2be69
Signed-off-by: Garrison Bellack <gbellack@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-08 17:04:54 +04:00
gbellack
9752c11d23 Quick bug fix for missing fd for move_in_cgroup
There is an issue where if the proccess to be killed spawns a child proccess and
moves it in a child cgroup of the one the parent process is in, the cgroup fd
was being closed in the parent process before it forked the child. Then when
move_in_cgroup() is called for the child process, the file descriptor has
already been closed causing a failure for the second call to move_in_cgroup().
Moved the fd close after the fork call.

Change-Id: I6ae88b95c5410a7f56108e28eb3133f113e868d0
Signed-off-by: Garrison Bellack <gbellack@google.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-08 17:04:39 +04:00
Andrey Vagin
7a203afe0a restore: fix index for accessing entries of the parent_act array
SIGMAX is a valid value, but the 0 signal doesn't exist.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-07 17:29:49 +04:00
Cyrill Gorcunov
8311b43517 proc_parse.c: parse_task_cgroup -- Don't forget to init @path
proc_parse.c: In function ‘parse_task_cgroup’:
proc_parse.c:1603:16: error: ‘path’ may be used uninitialized in this function [-Werror=uninitialized]
cc1: all warnings being treated as errors

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-07 13:18:09 +04:00
Andrew Vagin
e44f4e7acd restore: restore sigaction for alive tasks
The helper task doesn't change sigaction and does nothing with
parent_sigacts. paren_sigacts will contain values for the previous alive
task, so the logic about inherence should work as expected.

Reported-by: Jenkins Criuovich
Signed-off-by: Andrew Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-07 12:12:20 +04:00
Pavel Emelyanov
b674caf2ff sig: Add some logging to sigactions restore
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-07 11:05:54 +04:00
Pavel Emelyanov
50f712e9df sig: Optimize sigactions restore
Most of the sigactions are the same across the tasks in the image.
Nonetheless existing code always calls a syscall to restore them
and spends 64 calls per-task.

Let's restore signals before forking children and let them inherit
sigactions. Tune one only if it differs from the parent's.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-08-07 11:05:47 +04:00