util: Introduce strstartswith helper

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
proc: Introduce helper for parsing /proc/$pid/cgroup file

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
image: Add bits and pieces for cgroups image

The exact structure of the image will be revealed in the
next patch(es). What is important here, is that cgroup
image is somewhat new.

It will likely contain arrays of objects of different types,
so I introduce the "header" object, that will link these
arrays using pb repeated fields. This will help us to avoid
many image files for different cgroup objects and will make
the amount of write()-s required be 1.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cg: Skeleton for cgroup code

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cg: Dump cgroups tasks live in

Each task points to a single ID of cgroup-set it lives in. This
is done so to save some space in the image, as tasks likely
live in the same set of cgroups.

Other than this we keep track of what cgroup set we dump the
subtree from. If it happens, that root task lives in the same
cgroup set as criu does, we don't allow for any other sub-cgroups
and make restore (next patch) much simpler and faster.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cg: Restore tasks into proper cgroups

On restore find out in which sets tasks live in and move
them there.

Optimization note -- move tasks into cgroups _before_ fork
kids to make them inherit cgroups if required. This saves
a lot of time.

Accessibility note -- when moving tasks into cgroups don't
search for existing host mounts (they may be not available)
and don't mount temporary ones (may be impossible due to
user namespaces). Instead introduce service fd with a yard
of mounts.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
zdtm: Stupid test for task-in-cgroup

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