zdtm_ct: call setsid() to move in another autogroup

Transition and streaming tests can create many processes
which are using cpu. CPU should be divided between tests fairly.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cg: add --cgroup-root option

The motivation for this is to be able to restore containers into cgroups other
than what they were dumped in (if, e.g. they might conflict with an existing
container). Suppose you have a container in:

memory:/mycontainer
cpuacct,cpu:/mycontainer
blkio:/mycontainer
name=systemd:/mycontainer

You could then restore them to /mycontainer2 via --cgroup-root /mycontainer2.
If you want to restore different controllers to different paths, you can
provide multiple arguments, for example, passing:

--cgroup-root /mycontainer2 --cgroup-root cpuacct,cpu:/specialcpu \
--cgroup-root name=systemd:/specialsystemd

Would result in things being restored to:

memory:/mycontainer2
cpuacct,cpu:/specialcpu
blkio:/mycontainer2
name=systemd:/specialsystemd

i.e. a --cgroup-root without a controller prefix specifies the new default root
for all cgroups.

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
tests: add a test for --cgroup-root

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
shmem: Explicitly initialize rst_shmems

This is a position in the RM_SHREMAP memory. Since shmems are currently
the only user of it, this is validly equals zero, but it will change soon.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
shmem: Fix format of printing shmem addresses

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
rst: Rework task_entries to use rst_mem engine

The task_entries is a small structure used to coordinate the
processes restore stages. Currentl we allocate one page for
it and handle one separately. No need in this complexity, actually.
The rst_mem engine is already capable to controll this small object.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
protobuf: add signal_queue_entry and use it in thread_core_entry and task_core_entry

Add signal_queue_entry signals_s for shared signals to task_core_entry
and signals_p for private signals to thread_core_entry.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restore: open cores for each thread early and store them at current->core

We need to open cores for each thread early, because we'll need them to
prepare signals later.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
restore: use signals_s and signals_p to prepare signals

In order to save backward compatibility, criu will try to open signal*.img,
if no signals_* are found.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: allocate task cores in collect_task() instead of parasite_infect_seized()

We need it to be able to dump signals into cores
before calling parasite_infect_seized().

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
dump: dump signals into signals_*

Every thread has it's own private signals stored at thread_core->signals_p
and leader thread has also shared signals stored at tc->signals_s.

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
image: mark CR_FD_SIGNAL and CR_FD_PSIGNAL as obsoleted and don't create signal-s*.img, v2

After this patch, signal-s*.img won't be created.

v2: just move them to the end of array

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
rst: Fix core pointer passed into reading thread core image

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: Remove cgroup02 out of runlist

It fails on moving tasks into cpuset due to empty masks. Temporary
disable the test.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
signals: Calculate peek offset in-place

No need in extra variable for that.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
signals: Move nr variable into peeking loop

And sanitize its usage a little bit.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
signals: Don't forget to allocate SiginfoEntry

The se variable is just an array of pointers on these
objects. Need to allocate the objects themselves.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
signals: Don't collect siginfo_t-s on stack

We've moved signinfos on core entry, thus the bits with
siginfo-s themselves cannot sit on stack any longer.
Otherwise we would overwritem them with next batch and
will feed stack pointer to the caller, thus causing a
data and garbage on the stack to be written into image
instead of siginfo data.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
signals: Sanitize j loop control variable

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
signals: Comments and while (1) loop

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