]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: vircgroupv2: don't error out if enabling controller fails
authorPavel Hrdina <phrdina@redhat.com>
Thu, 20 Jun 2019 11:10:20 +0000 (13:10 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Wed, 26 Jun 2019 11:34:01 +0000 (13:34 +0200)
Currently CPU controller cannot be enabled if there is any real-time
task running and is assigned to non-root cgroup which is the case on
several distributions with graphical environment.

Instead of erroring out treat it as the controller is not available.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/util/vircgroupv2.c

index 032f78ac8e7dd57fab5652801f4c5729f99ece06..3cf786b123e2d23be042f52fe16df29a9c9bf1f4 100644 (file)
@@ -438,6 +438,8 @@ virCgroupV2MakeGroup(virCgroupPtr parent ATTRIBUTE_UNUSED,
         } else {
             size_t i;
             for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
+                int rc;
+
                 if (!virCgroupV2HasController(parent, i))
                     continue;
 
@@ -445,8 +447,17 @@ virCgroupV2MakeGroup(virCgroupPtr parent ATTRIBUTE_UNUSED,
                 if (i == VIR_CGROUP_CONTROLLER_CPUACCT)
                     continue;
 
-                if (virCgroupV2EnableController(parent, i, true) < 0)
+                rc = virCgroupV2EnableController(parent, i, false);
+                if (rc < 0) {
+                    if (rc == -2) {
+                        virResetLastError();
+                        VIR_DEBUG("failed to enable '%s' controller, skipping",
+                                  virCgroupV2ControllerTypeToString(i));
+                        group->unified.controllers &= ~(1 << i);
+                        continue;
+                    }
                     return -1;
+                }
             }
         }
     }