[CRIU] [PATCH 1/2] finalize cgroups correctly

Saied Kazemi saied at google.com
Thu Mar 19 10:41:58 PDT 2015


Hi Tycho,

I tried the patch but it didn't work for me as cgyard is visible after
restore (please see below).  Here are criu dump and restore commands.  I've
also attached the log files.

criu dump -v4 -D /home/saied/work/nsinit/busybox/nsinit/checkpoint -o
dump.log --root /home/saied/work/nsinit/busybox --manage-cgroups
--evasive-devices -t 31361

criu restore -v4 -D /home/saied/work/nsinit/busybox/nsinit/checkpoint -o
restore.log --root /home/saied/work/nsinit/busybox --pidfile
/home/saied/work/nsinit/busybox/nsinit/restoredpid --manage-cgroups
--evasive-devices --inherit-fd fd[0]:pipe:[69253] --inherit-fd
fd[1]:pipe:[69254] --inherit-fd fd[2]:pipe:[69255]

Any ideas why?!

--Saied

[Terminal A]
$ sudo nsinit exec -- sh -c 'while :; do mount >> /foo; sleep 3; done'

[Terminal B]
$ sudo nsinit -criu /usr/local/bin/criu checkpoint && echo OK
OK
$

[Terminal A]
$ sudo nsinit -criu /usr/local/bin/criu restore

[Terminal B]
$ cat foo
...
rootfs on / type rootfs (rw)
/dev/disk/by-uuid/18ec1400-9724-446f-be66-f8426f43f206 on / type ext4
(rw,relatime,errors=remount-ro,data=ordered)
none on /nsinit/checkpoint/.criu.cgyard.SOcu9c type tmpfs (rw,relatime)
none on /nsinit/checkpoint/.criu.cgyard.SOcu9c/cpuset type cgroup
(rw,relatime,cpuset)
none on /nsinit/checkpoint/.criu.cgyard.SOcu9c/cpu type cgroup
(rw,relatime,cpu)
none on /nsinit/checkpoint/.criu.cgyard.SOcu9c/cpuacct type cgroup
(rw,relatime,cpuacct)
none on /nsinit/checkpoint/.criu.cgyard.SOcu9c/memory type cgroup
(rw,relatime,memory)
none on /nsinit/checkpoint/.criu.cgyard.SOcu9c/devices type cgroup
(rw,relatime,devices)
none on /nsinit/checkpoint/.criu.cgyard.SOcu9c/freezer type cgroup
(rw,relatime,freezer)
none on /nsinit/checkpoint/.criu.cgyard.SOcu9c/blkio type cgroup
(rw,relatime,blkio)
none on /nsinit/checkpoint/.criu.cgyard.SOcu9c/perf_event type cgroup
(rw,relatime,perf_event)
none on /nsinit/checkpoint/.criu.cgyard.SOcu9c/hugetlb type cgroup
(rw,relatime,hugetlb)
none on /nsinit/checkpoint/.criu.cgyard.SOcu9c/systemd type cgroup
(rw,relatime,name=systemd)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
proc on /proc/sys type proc (rw,nosuid,nodev,noexec,relatime)
proc on /proc/bus type proc (rw,nosuid,nodev,noexec,relatime)
proc on /proc/irq type proc (rw,nosuid,nodev,noexec,relatime)
proc on /proc/sysrq-trigger type proc (rw,nosuid,nodev,noexec,relatime)
sysfs on /sys type sysfs (ro,nosuid,nodev,noexec,relatime)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,mode=755)
devpts on /dev/pts type devpts
(rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666)
mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime)
shm on /dev/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=65536k)
tmpfs on /proc/kcore type tmpfs (rw,nosuid,relatime,mode=755)






On Thu, Mar 19, 2015 at 7:50 AM, Tycho Andersen <
tycho.andersen at canonical.com> wrote:

> We need to finalize the cg yard both on successful cgroup restore and on a
> failed restore. Further, we should restore the cgroup properties before
> allowing the task to continue in all modes (previously properties were only
> restored correctly in --restore-detached mode).
>
> CC: Saied Kazemi <saied at google.com>
> Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> ---
>  cr-restore.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/cr-restore.c b/cr-restore.c
> index 4a1fe4e..8d82945 100644
> --- a/cr-restore.c
> +++ b/cr-restore.c
> @@ -1798,6 +1798,11 @@ static int restore_root_task(struct pstree_item
> *init)
>         if (ret < 0)
>                 goto out_kill;
>
> +       ret = prepare_cgroup_properties();
> +       fini_cgroup();
> +       if (ret < 0)
> +               goto out_kill;
> +
>         ret = run_scripts(ACT_POST_RESTORE);
>         if (ret != 0) {
>                 pr_err("Aborting restore due to script ret code %d\n",
> ret);
> @@ -1934,13 +1939,8 @@ int cr_restore_tasks(void)
>         if (criu_signals_setup() < 0)
>                 goto err;
>
> -       if (restore_root_task(root_item) < 0)
> -               goto err;
> -
> -       ret = prepare_cgroup_properties();
> -
> +       ret = restore_root_task(root_item);
>  err:
> -       fini_cgroup();
>         cr_plugin_fini(CR_PLUGIN_STAGE__RESTORE, ret);
>         return ret;
>  }
> --
> 2.1.0
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20150319/dac15cad/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dump.log
Type: text/x-log
Size: 38592 bytes
Desc: not available
URL: <http://lists.openvz.org/pipermail/criu/attachments/20150319/dac15cad/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: restore.log
Type: text/x-log
Size: 59061 bytes
Desc: not available
URL: <http://lists.openvz.org/pipermail/criu/attachments/20150319/dac15cad/attachment-0003.bin>


More information about the CRIU mailing list