zdtm.sh: check backward compatibility

zdtm.sh -b <commit>
* save a current head, rollback on <commit> and compile crtools
* execute a test and dump its processes
* checkout the current head and comple crtools
* restore test processes and check results

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
crtools: fix backward compatibility

crtools should not failed, if new images are absent.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: pass a file descriptor on an fdinfo image instead of cr_fdset

Currently fdinfo dumps for each task, so CR_FD_FDINFO is in cr_fdset.
A few tasks can share one fd table and the set of descriptors will be
dumped once and a image name will contain files_id instead of pid.
In this case CR_FD_FDINFO will go away from cr_fdset.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
lock: add futex_inc_and_wake and futex_wait_while_lt (v2)

v2: fix descriptions

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: add an error message if crtools is absent

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm.sh: detect unrecognized options

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
pipe: Make pipe-data entry always be present in the image

It contains info about the pipe itself, not jut one of its
ends. Thus if we want to add more (e.g. -- its size) we'll
have to put it there and thus have it always present.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
pipe: Dump and restore pipe size

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
mntns: close_proc before clean up mounts

Because /proc could not be umounted, if any its file is opened.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
util: clone service descriptors, if fd tables are shared for tasks (v3)

It looks like a namespace for service descriptors.
It will be used for restoring tasks with shared fd tables.
Service descriptors should be own for each process.

v2: clone_service_fd doesn't know about sub-systems like log, proc, etc
v3: Don't try to find a free name-space.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
crtools: add ability to create and close a service fd (v3)

A service fd should be created, otherwise get_service_fd returns -1.

This patch removes this functionality from other subsystems and
allows to clone service descriptors.

v2: rename open_service_fd to install_service_fd
v3: two patches were merged for bisecting

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
crtools: put kobj-ids into separate image file (v2)

It is read together with pstree items for checking what kind of
resources should be shared. Core is too big for reading it in
this place.

v2: fix check_core

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: save ids on pstree_item

It will be used for determing which resources are shared

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
pstree: allocate fdt shared data

fdt shared data contains PID of process, which will restore file
descriptors and a futex for synchronization.

A process with mimimal pid restores file descriptors.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: close_old_fds before forking children (v2)

A few processes can share one fd table. Each process has own set of
service file descriptors and a process knows nothing about servic fds
of another processes. So if two process share one fd table,
close_old_fds will close servic descriptors of another process.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files: dump fdinfo per files_id instead of pid

A few processes can share one fdtable.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restore: restore pocesses which share one fdtable (v5)

Currenly crtools supports a case when a child shared a fd table
with parent.

Here is only two interesting things.
* Service descriptors should be cloned for each process
  who shared one fd table.
* One task should restore files and other tasks should sleep in this
* time.

v2: * allocate fdt_lock from shared memory
    * don't wait a child, if it doesn't share fdtable
v3: * don't move ids on the pstree image
v4: * save ids in a separate image
    * save fdinfo per id instead of pid
v5: fix alignment of service_fd_id

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: test shared file tables

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