In cgroups v2 when a new group is created by default no controller is
enabled so the detection code will not detect any controllers.
When enabling the controllers we should also store them for the group.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/util/vircgroupv2.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index 9c44b3473e..af3192c99c 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -365,7 +365,8 @@ virCgroupV2PathOfController(virCgroupPtr group,
* 0 on success
*/
static int
-virCgroupV2EnableController(virCgroupPtr parent,
+virCgroupV2EnableController(virCgroupPtr group,
+ virCgroupPtr parent,
int controller,
bool report)
{
@@ -391,6 +392,8 @@ virCgroupV2EnableController(virCgroupPtr parent,
return -2;
}
+ group->unified.controllers |= 1 << controller;
+
return 0;
}
@@ -432,14 +435,14 @@ virCgroupV2MakeGroup(virCgroupPtr parent ATTRIBUTE_UNUSED,
}
if (virCgroupV2HasController(parent, VIR_CGROUP_CONTROLLER_CPU) &&
- virCgroupV2EnableController(parent,
+ virCgroupV2EnableController(group, parent,
VIR_CGROUP_CONTROLLER_CPU,
true) < 0) {
return -1;
}
if (virCgroupV2HasController(parent, VIR_CGROUP_CONTROLLER_CPUSET)
&&
- virCgroupV2EnableController(parent,
+ virCgroupV2EnableController(group, parent,
VIR_CGROUP_CONTROLLER_CPUSET,
true) < 0) {
return -1;
@@ -456,7 +459,7 @@ virCgroupV2MakeGroup(virCgroupPtr parent ATTRIBUTE_UNUSED,
if (i == VIR_CGROUP_CONTROLLER_CPUACCT)
continue;
- rc = virCgroupV2EnableController(parent, i, false);
+ rc = virCgroupV2EnableController(group, parent, i, false);
if (rc < 0) {
if (rc == -2) {
virResetLastError();
--
2.21.0