[CRIU] [PATCH] Skip restoring certain cgroup root directories when using full mode

Hui Kang hkang.sunysb at gmail.com
Fri Aug 28 20:43:22 PDT 2015


On Wed, Aug 26, 2015 at 12:45 AM, Andrew Vagin <avagin at gmail.com> wrote:
> On Wed, Aug 26, 2015 at 12:28:40AM -0400, Hui Kang wrote:
>> On Wed, Aug 26, 2015 at 12:27 AM, Andrew Vagin <avagin at gmail.com> wrote:
>> > On Tue, Aug 25, 2015 at 10:25:02PM -0400, Hui Kang wrote:
>> >>
>> >> Hi, Pavel
>> >> I still have difficulty in producing the bug you described. I have
>> >> /sys/fs/cgroup/cpuset (which is the root) and /sys/fs/cgroup/cpuset/A.
>> >> I have added task 1001 to the root and 1002 to
>> >> /sys/fs/cgroup/cpuset/A. The patch has no problem in restoring the the
>> >> task in /A.
>> >>
>> >> If this is the not nested case you described, could you give more
>> >> detailed about the case you think of? Thanks.
>> >
>> > I think I've reproduced this bug:
>> > https://asciinema.org/a/cv3qlitwvvt2guyi2woaok056
>>
>> Thanks. Will look into this.
>
> I think we need something like this:

I tested your changes. It works perfects: avoid opening the root
directory and restoring the children directories. However, I am
wondering if we should do something like this

+               if (strcmp(e->dir_name, "") == 0 &&
+                   ((strstr(path, "cpu")) || (strstr(path, "memory"))))
+                       goto skip; /* skip root cgroups */
+

Because other root directories are writable by criu.

- Hui

>
> diff --git a/cgroup.c b/cgroup.c
> index a4e0146..2c9c29f 100644
> --- a/cgroup.c
> +++ b/cgroup.c
> @@ -992,6 +992,9 @@ static int prepare_cgroup_dir_properties(char *path, int off, CgroupDirEntry **e
>                 CgroupDirEntry *e = ents[i];
>                 size_t off2 = off;
>
> +               if (strcmp(e->dir_name, "") == 0)
> +                       goto skip; /* skip root cgroups */
> +
>                 off2 += sprintf(path + off, "/%s", e->dir_name);
>                 if (e->n_properties > 0) {
>                         for (j = 0; j < e->n_properties; ++j) {
> @@ -1000,6 +1003,7 @@ static int prepare_cgroup_dir_properties(char *path, int off, CgroupDirEntry **e
>                         }
>                 }
>
> +skip:
>                 if (prepare_cgroup_dir_properties(path, off2, e->children, e->n_children) < 0)
>                         return -1;
>         }
>
>
>>
>> - Hui
>>
>> >
>> >>
>> >> - Hui
>> >>
>> _______________________________________________
>> CRIU mailing list
>> CRIU at openvz.org
>> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list