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>
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>
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>
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>
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>
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>
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>
zdtm: Make cgroup00 test check several tasks and sub-cgroup

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
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>
stats: Properly initialize dump stats

They all should be zeroed.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
flock: Don't hide image read error on flocks restore

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
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>
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>
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>
pstree: Introduce task_alive() helper

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
pstree: Use task_alive() instead of switch()-es

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
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>
show: Print filelocks.img pids as %u

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
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>
cg: Remove write-only variable

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>