sockets, unix: Use general machnism for checkpoint/restore v2

Use fdtype_ops facility to c/r unix sockets.

v2
 - BUG_ON added in dump_one_unix_fd if socket
   is already dumped since we never should dump
   same socket several times
 - The order of restore remains as it was before,
   the lookup is done via socket inode numbers

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
sockets, inet: Use general machnism for checkpoint/restore v2

Use fdtype_ops facility to c/r inet sockets.

v2:
 - Use BUG_ON if socket is attempted to be dumped
   several times

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
make: simplify OBJ on BLOBS dependence

Replace dances with "|" by simple dependence rule both for DEPS and OBJS.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
make: make "all" as phony target

Also, .PHONY have to be specified prior to desired goals,
And it's better to have one line for all goals instead on one line per goal.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
make: specify DEPS implicitly

Instead of using wildcard expressions like "*.c" lets implicitely specify
desired dependence files.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
make: echo deps build

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
make: prepare crtools build for submake calls

The reason for this patch is that only phony goal can depend on phony targets.
But with protobuf we will have to execute phony targets prior to main target
build.
So, this patch set add few new goals and dependences:

1) "all" become default goal.
2) new goals "deps" and "preq" introduced.
3) "all" depends on "deps" and "crtools".
4) All global goals like "zdtm" and "test-legacy" now depends on "all".

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
unix: Beautify the unixsk image show output

Print IDs with %#x to get rid of spaces between 0x and numbers.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
show: Beautify fdinfos showing

Shifd fd and type left and print ID with %#x

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

Don't mix various types of sockets in a single
test case, in case of problems it become harder
to fins which kind of socket failed.

The removed test cases will be addressed in
further patches.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: Add sockets_spair test case

Code to test socketpair (extracted from
previous sockets00 test case).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: Add sockets_dgram test case

Code to test unix dgarm sockets (extracted from
previous sockets00 test case).

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: Don't mask O_ASYNC flag from being set

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
crtools: link pstree_item-s in a tree (v3)

because they describes a process TREE.

It's usefull, when we dump tasks from another pid namespace,
because a real pid is got from parasite. In previous version
we need to update pid in two places one is in a pstree_item and
one is in a children array.

A process tree will be necessery to restore sid and pgid,
because we should add fake tasks in a tree. For example if
a sesion leader is absent.

v2: fix rollback actions
v3: fix comments from Pavel Emelyanov
    * add macros for_each_pstree_item
    * and a few bugs

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restore: add fast path to find a parent pstree item

Taking into account the way the dump saves pstrees in the image.

If pstree.img isn't edited, a slow path should not be executed at all.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
pstree: allocate restore data as a tail of pstree_item (v2)

v2: Synchronize the argument type of __alloc_pstree_item and the
values you put into it. I.e. int-int or bool-bool, not bool-int.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
make: fix blob dependencies

v5:
1) make change directory messages supressed.

v4:
1) Fixed apply conflicts.

v3:
1) "crtools" goal dependences fixed.

v2:
1) wrong "protobuf/tmp.pb-c.h" inclusion removed from cr-dump.c

Without this patch "touch parasite.c" will lead to rebuild of the whole
project.
This patch also introduces "pie" goal as a subsystem. This will be usefull,
when other subsystems will apper, because it allows to build them in parallel.
"all" becomes default goal. This allows to skip deps inclusion for empty,
"all", "zdtm" and "test-legacy" goals.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
util: do a control shot from BUG_ON

SIGABRT may be blocked. We do that in the restorer.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: Cleanup file_fown test case (v2)

 - add test for flags recovery
 - drop sockets, not needed
 - simplify test for owners and signumber

v2: remove polling (by avagin@)

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: Don't dump file params with on-stack values in dump_task_fs

Ad addition to commit 63000f5bb20e12ced2bc9662482775d163c97c5a,
this place was missed to fix.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>