]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vircgroup: introduce virCgroupCopyPlacement helper
authorPavel Hrdina <phrdina@redhat.com>
Wed, 14 Oct 2020 09:14:34 +0000 (11:14 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Tue, 3 Nov 2020 20:26:32 +0000 (21:26 +0100)
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/util/vircgroup.c

index a30aec4e5ef4cf397cd2508bc388b11a17bee106..b5f38210fbf818f9c9013dee747110aeac7956bd 100644 (file)
@@ -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 */