Currently CPU controller cannot be enabled if there is any real-time
task running and is assigned to non-root cgroup which is the case on
several distributions with graphical environment.
Instead of erroring out treat it as the controller is not available.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
Changes in v2:
- Reworked error reporting to virResetLastError only if we fail
to enable controller. The error message will be still logged
but now it's more descriptive what have failed.
src/util/vircgroupv2.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index 133a8e0e66..348c12d5c6 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -433,6 +433,8 @@ virCgroupV2MakeGroup(virCgroupPtr parent ATTRIBUTE_UNUSED,
} else {
size_t i;
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
+ int rc;
+
if (!virCgroupV2HasController(parent, i))
continue;
@@ -440,8 +442,17 @@ virCgroupV2MakeGroup(virCgroupPtr parent ATTRIBUTE_UNUSED,
if (i == VIR_CGROUP_CONTROLLER_CPUACCT)
continue;
- if (virCgroupV2EnableController(parent, i) < 0)
+ rc = virCgroupV2EnableController(parent, i);
+ if (rc < 0) {
+ if (rc == -2) {
+ virResetLastError();
+ VIR_DEBUG("failed to enable '%s' controller,
skipping",
+ virCgroupV2ControllerTypeToString(i));
+ group->unified.controllers &= ~(1 << i);
+ continue;
+ }
return -1;
+ }
}
}
}
--
2.21.0