]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vircgroup: expand virCgroupDetect into virCgroupNew
authorPavel Hrdina <phrdina@redhat.com>
Thu, 15 Oct 2020 11:11:28 +0000 (13:11 +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 794680d6963d7cab3205ac0196082b4215517dc5..81aa3ee7910528904285e4c8c1aac8fdc1162f87 100644 (file)
@@ -442,39 +442,6 @@ virCgroupDetectControllers(virCgroupPtr group,
 }
 
 
-static int
-virCgroupDetect(virCgroupPtr group,
-                pid_t pid,
-                int controllers,
-                const char *path)
-{
-    VIR_DEBUG("group=%p controllers=%d path=%s",
-              group, controllers, path);
-
-    if (virCgroupSetBackends(group) < 0)
-        return -1;
-
-    if (virCgroupDetectMounts(group) < 0)
-        return -1;
-
-    if (virCgroupCopyPlacement(group, path, NULL) < 0)
-        return -1;
-
-    /* ... but use /proc/cgroups to fill in the rest */
-    if (virCgroupDetectPlacement(group, pid, path) < 0)
-        return -1;
-
-    /* Check that for every mounted controller, we found our placement */
-    if (virCgroupValidatePlacement(group, pid) < 0)
-        return -1;
-
-    if (virCgroupDetectControllers(group, controllers, NULL) < 0)
-        return -1;
-
-    return 0;
-}
-
-
 char *
 virCgroupGetBlockDevString(const char *path)
 {
@@ -717,7 +684,24 @@ virCgroupNew(pid_t pid,
     *group = NULL;
     newGroup = g_new0(virCgroup, 1);
 
-    if (virCgroupDetect(newGroup, pid, controllers, path) < 0)
+    if (virCgroupSetBackends(newGroup) < 0)
+        return -1;
+
+    if (virCgroupDetectMounts(newGroup) < 0)
+        return -1;
+
+    if (virCgroupCopyPlacement(newGroup, path, NULL) < 0)
+        return -1;
+
+    /* ... but use /proc/cgroups to fill in the rest */
+    if (virCgroupDetectPlacement(newGroup, pid, path) < 0)
+        return -1;
+
+    /* Check that for every mounted controller, we found our placement */
+    if (virCgroupValidatePlacement(newGroup, pid) < 0)
+        return -1;
+
+    if (virCgroupDetectControllers(newGroup, controllers, NULL) < 0)
         return -1;
 
     *group = g_steal_pointer(&newGroup);