<div dir="ltr">The restore code in CRIU 1.3rc2 for cgroups does not seem to correctly handle named hierarchies. A named hierarchy can be created by "mount -t cgroup -o none,name=<name> <source> <target>". One such named cgroup is systemd. Below is a snippet of the cgroup image file after CRIU dump showing the entry for systemd.<div>
<br></div><div># criu show -f img/cgroup.img </div><div>...</div><div><div>:{</div><div><span style="white-space:pre-wrap">                </span>name: "name=systemd"</div><div><span style="white-space:pre-wrap">                </span>path: "/user/1000.user/4.session"</div>
<div><span style="white-space:pre-wrap">        </span>}</div></div><div>...</div><div><br></div><div>The function prepare_cgroup_sfd() creates a directory called "name=systemd" and mounts it.</div><div><br></div><div>
I applied the following patch as a quick workaround but I think the issue needs further study.</div><div><br></div><div><div>diff --git a/cgroup.c b/cgroup.c</div><div>index 2d9ebad..d2185fb 100644</div><div>--- a/cgroup.c</div>
<div>+++ b/cgroup.c</div><div>@@ -258,7 +258,10 @@ static int move_in_cgroup(CgSetEntry *se)</div><div> int fd, err;</div><div> ControllerEntry *ce = se->ctls[i];</div><div> </div><div>- sprintf(aux, "%s/%s/tasks", ce->name, ce->path);</div>
<div>+ if (strstartswith(ce->name, "name="))</div><div>+ sprintf(aux, "%s/%s/tasks", ce->name + 5, ce->path);</div><div>+ else</div><div>+ sprintf(aux, "%s/%s/tasks", ce->name, ce->path);</div>
<div> pr_debug(" `-> %s\n", aux);</div><div> err = fd = openat(cg, aux, O_WRONLY);</div><div> if (fd >= 0) {</div><div>@@ -366,11 +369,12 @@ static int prepare_cgroup_sfd(CgSetEntry *root_set)</div>
<div> ControllerEntry *ce = root_set->ctls[i];</div><div> char *opt = ce->name;</div><div> </div><div>- sprintf(paux + off, "/%s", ce->name);</div><div> if (strstartswith(ce->name, "name=")) {</div>
<div>+ sprintf(paux + off, "/%s", ce->name + 5);</div><div> sprintf(aux, "none,%s", ce->name);</div><div> opt = aux;</div><div>
}</div><div>+ sprintf(paux + off, "/%s", ce->name);</div><div> </div><div> if (mkdir(paux, 0700)) {</div><div> pr_perror("Can't make cgyard subdir");</div>
</div><div><br></div><div>What do you think?</div><div><br></div><div>--Saied</div><div><br></div></div>