From ef1853605066aa15630424340f2d7777964ed5d9 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Wed, 3 Oct 2018 12:23:36 +0200 Subject: [PATCH] cgfsng: handle v1 cpuset hierarchy first 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 --- src/lxc/cgroups/cgfsng.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index ec4501c33..97913209c 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -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); } -- 2.47.2