]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vircgroup: introduce virCgroupValidatePlacement helper
authorPavel Hrdina <phrdina@redhat.com>
Wed, 14 Oct 2020 09:15:53 +0000 (11:15 +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 b5f38210fbf818f9c9013dee747110aeac7956bd..55fa49a398b4e2e449450434f63a321c5bde61c9 100644 (file)
@@ -393,6 +393,23 @@ virCgroupDetectPlacement(virCgroupPtr group,
 }
 
 
+static int
+virCgroupValidatePlacement(virCgroupPtr group,
+                           pid_t pid)
+{
+    size_t i;
+
+    for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
+        if (group->backends[i] &&
+            group->backends[i]->validatePlacement(group, pid) < 0) {
+            return -1;
+        }
+    }
+
+    return 0;
+}
+
+
 static int
 virCgroupDetect(virCgroupPtr group,
                 pid_t pid,
@@ -430,12 +447,8 @@ virCgroupDetect(virCgroupPtr group,
         return -1;
 
     /* Check that for every mounted controller, we found our placement */
-    for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
-        if (group->backends[i] &&
-            group->backends[i]->validatePlacement(group, pid) < 0) {
-            return -1;
-        }
-    }
+    if (virCgroupValidatePlacement(group, pid) < 0)
+        return -1;
 
     for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
         if (group->backends[i]) {