[CRIU] Handling Named Cgroup Hierarchies
Saied Kazemi
saied at google.com
Mon Jun 23 19:04:16 PDT 2014
The hierarchy created in cgyard mimics the hierarchy in /sys/fs/cgroup for
the process being restored except for the systemd and other named
hierarchies.
As you've mentioned, since cgyard will be deleted, this doesn't really
matter but it'd be nice to be consistent like the rest of them (cpu, blkio,
etc.) especially when it's so easy to skip the "name=" part.
--Saied
On Mon, Jun 23, 2014 at 1:44 AM, Pavel Emelyanov <xemul at parallels.com>
wrote:
> 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
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20140623/65d4161c/attachment.html>
More information about the CRIU
mailing list