restore: --restore-detached implies CLONE_PARENT

We need to use CLONE_PARENT to prevent processes from immediately dying due to
pdeath_sig when they are restored in detached mode.

[ xemul: One more place which requires check for restore-detach
         is in sigactions preparation ]

Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cg: Fix restoration of tasks into existing cgroups

When we omit the --manage-cgroups on dump the controllers section
in cgroups image lacks the none-d entries (the name=systemd is the
most typical).

If it happens, that init task lives in non-criu cgset (it can be
so if we do --shell-job dump from another terminal and see criu
and root task living in different user.slice systemd cgroups) then
on restore the move_in_cgroup() would fail to lookup the required
controller.

In order to fix this we should still call the collect_cgroups()
on dump, so that it adds the none-d controllers into the list,
but don't dump the dirs tree itself.

The patch looks ugly, but it just moves the current_controller
evaluation from the middle of the loop upwards (and renames the
char *opts variable not to conflict with global opts).

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>
cg: Use relative paths in cgroup dirs image

Before the patch cg tree section from cgroup00 test looked like this

{
	cnames: "name=zdtmtst"
	dirs: 	{
		path: "/subcg"
		children: 		{
			path: "/subcg/subsubcg"
			children: <empty>
			properties: <empty>
		}

		properties: <empty>
	}

}

this /subsg in the children is excessive. Turn this into directory names.
Now the section looks like

{
	cnames: "name=zdtmtst"
	dirs: 	{
		dir_name: "subcg"
		children: 		{
			dir_name: "subsubcg"
			children: <empty>
			properties: <empty>
		}

		properties: <empty>
	}

}

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Acked-by: Tycho Andersen <tycho.andersen@canonical.com>