parasite: Sanitize thread dumping code

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: Merge thread and task parasite-core info dumping

There are parts dumping which is common to thread and task,
and this stuff is represented by parasite_dump_thread structure.

Merge this into parasite_dump_misc and facror out dumping code.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: Add comment why get_task_regs for task is in such a strange place

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: Don't push parasite-ctl into fns needing pid only

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: Move signals dumping into a helper

... fixing erroneous goto on error path :)

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
parasite: Reshuffle sync and async daemon-node executing routines

The version, that might not wait for ack is always called with
"async" flag set. Cleanup things according to this.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
parasite: Rename ack-waiting function to look better

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
v2 criu: Initial skeleton for criu library

Add target lib to Makefile for criu library.
Created directory lib and add there Makefile and criu.c - skelettons for criu library.

Signed-off-by: Ruslan Kupreev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm.sh: dump traffic for *tcpbuf* tests

Sometimes these tests don't pass successfully and we need more
information to investigate the problem.

https://bugzilla.openvz.org/show_bug.cgi?id=2676
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: Introduce "post-dump" script action

This is usefull if one needs to do some final action before checkpoint
is complete. For example in case of online migration one may provide
a script which would check the restore procedure on remote note
ended without errors, thus the script returns zero code and criu
simply kills running instance of application.

In turn, if migration failed, the script can return nonzero code
and criu won't kill the application but continue its execution
instead.

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

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: Use "post-dump" script for "-d" and "-s" option

v2:
 - Use special opcode 32 to distinguish error cases
 - Use --scripts for snapshot testings
v3:
 - test for both 32 and 0 for error code
v4: (by avagin@)
 - restore from the last snapshot
v5:
 - update comment

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

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
util: print error message if a script is failed
debuginfo
zdtm.sh: wait page-server by a proper way

page-server is forked and the child is running in background, so a bash
variable $! contains PID of the last command, which is executed in
background.

Currently it's tcpdump and zdtm.sh is waiting it and never returns back.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
test: check, that parasite can rollback itself (v2)

This test uses systemtap to replace random parasite command on
invalide command. The parasite code received this command and should
rollback itself. CRIU didn't recived ack, should understand that
something wrong and exits. The systemtap inverts exit code of criu.

"zdtm.sh -d" is used for executing tests and testing that the state of
processes don't corrupted.

v2: randomize a command, which will be replaced
posix-times: don't fail if /proc/PID/times is absent

/proc/PID/times was added in 3.10, but FC19 relesead with 3.9.

Usually we support only last version of kernel in the project git, so
we can commit it as an additional patch for the fedora package.

Cc: Adrian Reber <adrian@lisas.de>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
zdtm.sh: check number of mounts in mountinfo
mount: link dependent mounts (v2)

All shared mounts from one group are connected to circular list.
All slave are added into the proper master list.

v2: change variable name and fix a bug about adding shared mounts in a
circular list.
mount: save group and master in image file (v2)

They are required for restoring shared and slave mounts

v2: use the same names of variables in image and in code
mounts: enumirate mounts bellow specified element