[CRIU] Handling Named Cgroup Hierarchies
Pavel Emelyanov
xemul at parallels.com
Mon Jun 23 01:44:41 PDT 2014
On 06/21/2014 03:54 AM, Saied Kazemi 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.
But what is the issue exactly in? This directory is just a temporary place for
mounting this cgroups and the whole cgyard gets restroyed after cgroups restore.
>
> 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
>
More information about the CRIU
mailing list