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
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
Pavel Emelyanov
bf0d4c4b2c sig: Block signals once before forking children
We already have a signals setup helper for this.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-08-07 11:05:33 +04:00
Pavel Emelyanov
8c133309a3 sig: Setup CHLD handler in dedicated helper
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-07 11:05:19 +04:00
Pavel Emelyanov
e50d0e7c6f sig: Don't reset CHLD handler to old action, DFL it
The whole idea behind this code was to stop receiving CHLD from
restored tasks after resume. The comment about this is done for
scripts is wrong (we call more scripts before this) because
sigchld_handler() knows about scripts:

commit de71bc69170cfeceb24bddd431ad10b8ea607d42
	 exit = (siginfo->si_code == CLD_EXITED);
	 status = siginfo->si_status;
	+
	+       /* skip scripts */
	+       if (!current && root_item->pid.real != pid) {
	+               pid = waitpid(root_item->pid.real, &status, WNOHANG);
	+               if (pid <= 0)
	+                       return;
	+       }

And since CHLD handler makes little sence after exec, it's easier
just to reset one to default action at the end.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-08-07 11:05:11 +04:00
Pavel Emelyanov
adc63c73d5 sig: Instantly drop SA_NOCLDSTOP for swrk_restore
We tune the CHLD handler if we're restoring root task
as sibling. This tuning is better to be done with one
sigaction() call, rather than two. First, it's shorter
and the second -- it will allow us to move the whole
criu signalling setup into one helper.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-08-07 11:04:21 +04:00
Pavel Emelyanov
bc7d6e315d sig: Don't feed pid argument to prepare_sigactions
We don't need pid in any of these calls actually, they are
all legacy from the old days. I plan to move the call to
prepare_sigactions, so remove the pid argument in advance.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-08-07 11:04:08 +04:00
Pavel Emelyanov
d14abcf7c3 sig: Don't request for old act when restoring sigactions
This old info is simply not used at that place.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Andrew Vagin <avagin@parallels.com>
2014-08-07 11:03:58 +04:00
Cyrill Gorcunov
1a801c6ded zdtm: timerfd requires new kernels to pass
Reported-by: Jenkins
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-07 10:28:25 +04:00
Andrey Vagin
a48e52b58c proc_parse: check that scanf fill the offset var
CID 1168165 (#2 of 2): Untrusted array index read (TAINTED_SCALAR)
40. tainted_data: Using tainted variable "hoff" as an index into an
array "str"

$ man 3 scanf
n      Nothing  is expected; instead, the number of characters consumed
      thus far from the input is  stored  through  the  next  pointer,
      which  must  be  a  pointer  to  int.  This is not a conversion,
      although it can be suppressed with the *  assignment-suppression
      character.   The  C  standard says: "Execution of a %n directive
      does not increment the assignment count returned at the  comple‐
      tion of execution" but the Corrigendum seems to contradict this.
      Probably it is wise not to make any assumptions on the effect of
      %n conversions on the return value.

So it isn't not enough to check a return code from scanf().

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
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-07 10:26:14 +04:00
Andrey Vagin
e601a2ea5d cgroup: trigger BUG if a mtype is unknown
CID 1230179 (#1 of 1): Resource leak (RESOURCE_LEAK)
15. leaked_storage: Variable "ncd" going out of scope leaks the storage
it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-07 10:26:02 +04:00
Andrey Vagin
9ba0baabd5 mount: fix dereference after null check
CID 1168169 (#1 of 1): Dereference after null check (FORWARD_NULL)
7. var_deref_model: Passing "mi" to function "do_bind_mount(struct
   mount_info *)", which dereferences null "mi->bind"

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-07 10:25:53 +04:00
Andrey Vagin
1e0e83701f cgroup: fix dereference before null check
Coverity: 1230177 Dereference before null check

There may be a null pointer dereference, or else the comparison against
null is unnecessary.  In parse_task_cgroup: All paths that lead to this
null pointer comparison already dereference the pointer earlier
(CWE-476)

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-07 10:24:50 +04:00
Christopher Covington
ca94dc9bed vdso: aarch64 -- Merge fixes from x86
This brings the changes made in the following commits to the
aarch64 copy of the code.

commit 7794f67f2055420c6b6c2967edfbe0c39a7cd744
Author: Cyrill Gorcunov <gorcunov@openvz.org>
Date:   Tue Aug 5 13:59:18 2014 +0400

    vdso: x86 -- Fix missing ability to remap vDSO if only one zone present

commit 066add0de44f462e7482571763f303ded0b4762f
Author: Cyrill Gorcunov <gorcunov@openvz.org>
Date:   Tue Aug 5 13:07:00 2014 +0400

    vdso: x86 -- Simplify vdso_proxify

Signed-off-by: Christopher Covington <cov@codeaurora.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-07 10:23:02 +04:00
Tycho Andersen
2b1021a43b restore: actually fail if clone() fails
Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-07 10:20:59 +04:00
Cyrill Gorcunov
7158448dd6 timerfd: Implement check routine
Reported-by: Jenkins
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-07 10:18:09 +04:00
Cyrill Gorcunov
ec3515107c timerfd: zdtm -- Add simple testcase
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
2014-08-06 19:20:28 +04:00