]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: vircgroup: pass parent cgroup into virCgroupDetectControllersCB
authorPavel Hrdina <phrdina@redhat.com>
Thu, 20 Jun 2019 10:59:29 +0000 (12:59 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Wed, 26 Jun 2019 11:34:01 +0000 (13:34 +0200)
In cgroups v2 we don't have to detect available controllers every single
time if we are creating a new cgroup based on parent cgroup.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/vircgroup.c
src/util/vircgroupbackend.h
src/util/vircgroupv1.c
src/util/vircgroupv2.c

index e32215935b0cdfa7dbe2cb0a4de0856f4b107d6a..b7e5f0352147059ff2013e7f9019b7e8cacfd7f0 100644 (file)
@@ -383,7 +383,7 @@ virCgroupDetect(virCgroupPtr group,
 
     for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
         if (group->backends[i]) {
-            int rc = group->backends[i]->detectControllers(group, controllers);
+            int rc = group->backends[i]->detectControllers(group, controllers, parent);
             if (rc < 0)
                 return -1;
             controllersAvailable |= rc;
index e58e327c68724c49e0d178e0cd1af744a6f48f26..1fe08511844b7b92ad8b4512f58a8c2eaa80746a 100644 (file)
@@ -95,7 +95,8 @@ typedef char *
 
 typedef int
 (*virCgroupDetectControllersCB)(virCgroupPtr group,
-                                int controllers);
+                                int controllers,
+                                virCgroupPtr parent);
 
 typedef bool
 (*virCgroupHasControllerCB)(virCgroupPtr cgroup,
index 97258917bc20c2ce0a8fe91b088b60fa186f3302..fb3e0b2d478b48151e87a0e40a25d13fcbdaf127 100644 (file)
@@ -420,7 +420,8 @@ virCgroupV1StealPlacement(virCgroupPtr group)
 
 static int
 virCgroupV1DetectControllers(virCgroupPtr group,
-                             int controllers)
+                             int controllers,
+                             virCgroupPtr parent ATTRIBUTE_UNUSED)
 {
     size_t i;
     size_t j;
index 1179c4459a34e96b437174e1496b1575b1e5cb6a..2d09d77a2998e451dc3e9845fc08be70f32e02b1 100644 (file)
@@ -285,16 +285,21 @@ virCgroupV2ParseControllersFile(virCgroupPtr group)
 
 static int
 virCgroupV2DetectControllers(virCgroupPtr group,
-                             int controllers)
+                             int controllers,
+                             virCgroupPtr parent)
 {
     size_t i;
 
-    if (virCgroupV2ParseControllersFile(group) < 0)
-        return -1;
+    if (parent) {
+        group->unified.controllers = parent->unified.controllers;
+    } else {
+        if (virCgroupV2ParseControllersFile(group) < 0)
+            return -1;
 
-    /* In cgroup v2 there is no cpuacct controller, the cpu.stat file always
-     * exists with usage stats. */
-    group->unified.controllers |= 1 << VIR_CGROUP_CONTROLLER_CPUACCT;
+        /* In cgroup v2 there is no cpuacct controller, the cpu.stat file always
+         * exists with usage stats. */
+        group->unified.controllers |= 1 << VIR_CGROUP_CONTROLLER_CPUACCT;
+    }
 
     for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++)
         VIR_DEBUG("Controller '%s' present=%s",