[PATCH v3 5/7] util: vircgroupv2: separate return values of virCgroupV2EnableController

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---

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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux