In order to skip controllers that we are not able to activate we need
to return different return value so the caller can decide what to do.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
Notes:
Introduced in v2
src/util/vircgroupv2.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index 3f4548b532..133a8e0e66 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -353,22 +353,37 @@ virCgroupV2PathOfController(virCgroupPtr group,
}
+/**
+ * virCgroupV2EnableController:
+ *
+ * Returns: -1 on fatal error
+ * -2 if we failed to write into cgroup.subtree_control
+ * 0 on success
+ */
static int
virCgroupV2EnableController(virCgroupPtr parent,
int controller)
{
VIR_AUTOFREE(char *) val = NULL;
+ VIR_AUTOFREE(char *) path = NULL;
if (virAsprintf(&val, "+%s",
virCgroupV2ControllerTypeToString(controller)) < 0) {
return -1;
}
- if (virCgroupSetValueStr(parent, controller,
- "cgroup.subtree_control", val) < 0) {
+ if (virCgroupPathOfController(parent, controller,
+ "cgroup.subtree_control", &path) < 0)
{
return -1;
}
+ if (virFileWriteStr(path, val, 0) < 0) {
+ virReportSystemError(errno,
+ _("Failed to enable controller '%s' for
'%s'"),
+ val, path);
+ return -2;
+ }
+
return 0;
}
--
2.21.0