[libvirt PATCH 10/25] vircgroup: introduce virCgroupCopyPlacement helper

Pavel Hrdina phrdina at redhat.com
Tue Nov 3 12:41:22 UTC 2020


Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 src/util/vircgroup.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index a30aec4e5e..b5f38210fb 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -294,6 +294,24 @@ virCgroupDetectMounts(virCgroupPtr group)
 }
 
 
+static int
+virCgroupCopyPlacement(virCgroupPtr group,
+                      const char *path,
+                      virCgroupPtr parent)
+{
+    size_t i;
+
+    for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
+        if (group->backends[i] &&
+            group->backends[i]->copyPlacement(group, path, parent) < 0) {
+            return -1;
+        }
+    }
+
+    return 0;
+}
+
+
 /*
  * virCgroupDetectPlacement:
  * @group: the group to process
@@ -403,12 +421,8 @@ virCgroupDetect(virCgroupPtr group,
      * based on the parent cgroup...
      */
     if (parent || path[0] == '/') {
-        for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
-            if (group->backends[i] &&
-                group->backends[i]->copyPlacement(group, path, parent) < 0) {
-                return -1;
-            }
-        }
+        if (virCgroupCopyPlacement(group, path, parent) < 0)
+            return -1;
     }
 
     /* ... but use /proc/cgroups to fill in the rest */
-- 
2.26.2




More information about the libvir-list mailing list