[CRIU] Handling Named Cgroup Hierarchies
Saied Kazemi
saied at google.com
Fri Jun 20 17:07:34 PDT 2014
Sorry, the last patch is missing an "else".
diff --git a/cgroup.c b/cgroup.c
index d2185fb..60b560c 100644
--- a/cgroup.c
+++ b/cgroup.c
@@ -373,7 +373,7 @@ static int prepare_cgroup_sfd(CgSetEntry *root_set)
sprintf(paux + off, "/%s", ce->name + 5);
sprintf(aux, "none,%s", ce->name);
opt = aux;
- }
+ } else
sprintf(paux + off, "/%s", ce->name);
if (mkdir(paux, 0700)) {
On Fri, Jun 20, 2014 at 4:54 PM, Saied Kazemi <saied at google.com> wrote:
> 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.
>
> # criu show -f img/cgroup.img
> ...
> :{
> name: "name=systemd"
> path: "/user/1000.user/4.session"
> }
> ...
>
> The function prepare_cgroup_sfd() creates a directory called
> "name=systemd" and mounts it.
>
> I applied the following patch as a quick workaround but I think the issue
> needs further study.
>
> diff --git a/cgroup.c b/cgroup.c
> index 2d9ebad..d2185fb 100644
> --- a/cgroup.c
> +++ b/cgroup.c
> @@ -258,7 +258,10 @@ static int move_in_cgroup(CgSetEntry *se)
> int fd, err;
> ControllerEntry *ce = se->ctls[i];
>
> - sprintf(aux, "%s/%s/tasks", ce->name, ce->path);
> + if (strstartswith(ce->name, "name="))
> + sprintf(aux, "%s/%s/tasks", ce->name + 5,
> ce->path);
> + else
> + sprintf(aux, "%s/%s/tasks", ce->name, ce->path);
> pr_debug(" `-> %s\n", aux);
> err = fd = openat(cg, aux, O_WRONLY);
> if (fd >= 0) {
> @@ -366,11 +369,12 @@ static int prepare_cgroup_sfd(CgSetEntry *root_set)
> ControllerEntry *ce = root_set->ctls[i];
> char *opt = ce->name;
>
> - sprintf(paux + off, "/%s", ce->name);
> if (strstartswith(ce->name, "name=")) {
> + sprintf(paux + off, "/%s", ce->name + 5);
> sprintf(aux, "none,%s", ce->name);
> opt = aux;
> }
> + sprintf(paux + off, "/%s", ce->name);
>
> if (mkdir(paux, 0700)) {
> pr_perror("Can't make cgyard subdir");
>
> What do you think?
>
> --Saied
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20140620/22d4afc6/attachment.html>
More information about the CRIU
mailing list