mem: Protobuf format for page dumps

Since now we drain pages out of parasite, we can invent any format for
page dumps. Let is be ... prorobuf one! :)

Another thing to keep in mind, is that we're about to use splices and
implement iterative migration, so it's better to have actual pages be
page-aligned in the image.

And -- backward compatibility. That said the new format is:

1. pagemap-... file which contains a header (currently with a ID of
   the image with pages, see below) and an array of <nr_pages:vaddr>
   pairs. The first value means "how many pages to take from the
   file with pages (see below)" and the second -- where in the task
   address space to put them. Simple.

2. pages-... file which containes only pages one by one (thus aligned
   as we want).

This patch breaks backward compatibility (old images with pages wil
be restored and then crash). Need to do it before v0.5 release.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
mem: Abstraction layer for putting pages into image

We'll send them over network soon, so prepare abstraction layer for
this. Shmem is not on this scheme yet.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
mem: Introduce page server

The page server is a process, that is about to get pages over
the network and put them into pagemap- + pages- images. Right
now what it does is simply get the data and puts it into the
image files. When we have dirty set tracking in the kernel the
page server will have to collect "page changes" and properly
integrate them into images.

Running crtools with page server is like this:

dst_node# crtools page-server --port <port> -D dump/ ...
src_node# crtools dump -t <pid> --page-server --address <dst_node> --port <port> -D dump/ ...

After this images from dst_node/dump/ and src_node/dump/ should
be put into one place and tasks can be restored out of it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: Test how page server works

When -p is used, launch page server in the same dir as
crtools dump is to get fill dump in it.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
mem: Raise the page images IDs base for page server

Currently shmem generates page images in parallel
with page server and IDs may intersect. Fix this by
making page server create larger IDs.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
app-emu/lxc: create /var/run/netns/

In Fedora /var/run is on tmpfs, so all directories should be
recreated each times.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: check unshared descriptors for one end of a pipe

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
image: Fixup error paths in check_img_inventory

 - Free unpacked PB data
 - Close file descriptor

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cr-restore: Report the mem size if mmap failed

Without patch

 | Error (cr-restore.c:414): Unable to reserve memory: Invalid argument

with applied

 | Error (cr-restore.c:414): Unable to reserve memory (0 bytes): Invalid argument

more convenient for debugging.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
ids: Don't forget to setup task state in write_img_inventory

Need to have proper fake-item state to make this code work ok:

get_task_ids
if (item->state != TASK_DEAD) {
	ret = dump_task_kobj_ids(item);
	if (ret)
		goto err_free;

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: Return x perms back

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restore: find VMA for each restored page

Otherwise ppage_bitmap and page_bitmap will be updated for wrong VMA
zdtm: add a test case for pending signals

Signed-off-by: Andrey Vagin <avagin@openvz.org>
protobuf: add a new description for saving siginfo-s

Signed-off-by: Andrey Vagin <avagin@openvz.org>
crtools: add a callback to show signal=*.img

Signed-off-by: Andrey Vagin <avagin@openvz.org>
crtools: add image contants for pending signals (v2)

v2: rename images

Signed-off-by: Andrey Vagin <avagin@openvz.org>
crtools: dump pending signals (v4)

PTRACE_PEEKSIGINFO is used for received pending signals,
then all signal are sent back and saved in a image.

v2: rework according with the new kernel interface
v3: rework according with the newrest kernel interface
v4: fix error handling

Signed-off-by: Andrey Vagin <avagin@openvz.org>
crtools: restore pending signals (v3)

Read siginfo-s from images and send them to itself by sigqueueinfo.

v2: Don't remap task_args and thread_args
v3: fix error handling

Signed-off-by: Andrey Vagin <avagin@openvz.org>
check: check PTRACE_PEEKSIGINFO and sigqueueinfo with positive si_code (v2)

v2: fix indentations.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
crtools: remove declaration of rt_sigset_t

Actually rt_sigset_t and k_rtsigset_t are the same