On hosts without systemd libvirt is responsible for creating cgroups topology. With cgroups v2 the logic changed a bit. If we need to create new directory the detection of controllers fails because the directory doesn't exists so there is no cgroup.controllers file. To fix that issue we need to have a parent cgroup where we can look into cgroup.subtree_control to get a list of enabled controllers. To fix the issue reorder the operations to get a parent group fist so we can use it to create a new partition. <https://www.redhat.com/archives/libvir-list/2019-July/msg01309.html> Reported-by: Raghav Gururajan <rvgn@xxxxxxxxxxx> Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx> --- src/util/vircgroup.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 825f62a97b..0789630b47 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -842,6 +842,7 @@ virCgroupNewPartition(const char *path, virCgroupPtr *group) { int ret = -1; + char *tmp; VIR_AUTOFREE(char *) parentPath = NULL; VIR_AUTOFREE(char *) newPath = NULL; virCgroupPtr parent = NULL; @@ -858,25 +859,27 @@ virCgroupNewPartition(const char *path, if (virCgroupSetPartitionSuffix(path, &newPath) < 0) goto cleanup; - if (virCgroupNew(-1, newPath, NULL, controllers, group) < 0) + if (STREQ(newPath, "/")) { + ret = 0; goto cleanup; - - if (STRNEQ(newPath, "/")) { - char *tmp; - if (VIR_STRDUP(parentPath, newPath) < 0) - goto cleanup; - - tmp = strrchr(parentPath, '/'); - tmp++; - *tmp = '\0'; - - if (virCgroupNew(-1, parentPath, NULL, controllers, &parent) < 0) - goto cleanup; - - if (virCgroupMakeGroup(parent, *group, create, VIR_CGROUP_NONE) < 0) - goto cleanup; } + if (VIR_STRDUP(parentPath, newPath) < 0) + goto cleanup; + + tmp = strrchr(parentPath, '/'); + tmp++; + *tmp = '\0'; + + if (virCgroupNew(-1, parentPath, NULL, controllers, &parent) < 0) + goto cleanup; + + if (virCgroupNew(-1, newPath, parent, controllers, group) < 0) + goto cleanup; + + if (virCgroupMakeGroup(parent, *group, create, VIR_CGROUP_NONE) < 0) + goto cleanup; + ret = 0; cleanup: if (ret != 0) -- 2.21.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list