]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cgfsng: handle v1 cpuset hierarchy first 2670/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 3 Oct 2018 10:23:36 +0000 (12:23 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 3 Oct 2018 10:29:20 +0000 (12:29 +0200)
If the value of cgroup.clone_children in our immediate ancestor cgroup
is 0 then the cpuset of any cgroups we create in subtrees will be empty
and hence we'll copy an empty cpuset at which point we cannot enter the
cpuset cgroup.
Avoid this problem by initializing cgroup.clone_children to 1 an copying
the initialized cpuset of our immediate ancestor. Note, that the cpuset
of our immediate ancestor must be initialized and ours as well otherwise
we couldn't be located in this cgroup.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cgroups/cgfsng.c

index ec4501c33e4e50a25f5bea3c22dd6d16c641a43a..97913209c7fddc2a7ebe3d64af87917a81e10e7f 100644 (file)
@@ -1297,6 +1297,11 @@ static bool monitor_create_path_for_hierarchy(struct hierarchy *h, char *cgname)
 {
        int ret;
 
+       if (!cg_legacy_handle_cpuset_hierarchy(h, cgname)) {
+               ERROR("Failed to handle legacy cpuset controller");
+               return false;
+       }
+
        h->monitor_full_path = must_make_path(h->mountpoint, h->container_base_path, cgname, NULL);
        ret = mkdir_eexist_on_last(h->monitor_full_path, 0755);
        if (ret < 0) {
@@ -1304,11 +1309,6 @@ static bool monitor_create_path_for_hierarchy(struct hierarchy *h, char *cgname)
                return false;
        }
 
-       if (!cg_legacy_handle_cpuset_hierarchy(h, cgname)) {
-               ERROR("Failed to handle legacy cpuset controller");
-               return false;
-       }
-
        return cg_unified_create_cgroup(h, cgname);
 }
 
@@ -1316,6 +1316,11 @@ static bool container_create_path_for_hierarchy(struct hierarchy *h, char *cgnam
 {
        int ret;
 
+       if (!cg_legacy_handle_cpuset_hierarchy(h, cgname)) {
+               ERROR("Failed to handle legacy cpuset controller");
+               return false;
+       }
+
        h->container_full_path = must_make_path(h->mountpoint, h->container_base_path, cgname, NULL);
        ret = mkdir_eexist_on_last(h->container_full_path, 0755);
        if (ret < 0) {
@@ -1323,11 +1328,6 @@ static bool container_create_path_for_hierarchy(struct hierarchy *h, char *cgnam
                return false;
        }
 
-       if (!cg_legacy_handle_cpuset_hierarchy(h, cgname)) {
-               ERROR("Failed to handle legacy cpuset controller");
-               return false;
-       }
-
        return cg_unified_create_cgroup(h, cgname);
 }