]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: don't error out when cgroups don't exist
authorMartin Kletzander <mkletzan@redhat.com>
Wed, 9 Jul 2014 07:55:29 +0000 (09:55 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Wed, 9 Jul 2014 13:09:54 +0000 (15:09 +0200)
When creating cgroups for vcpu and emulator threads whilst starting a
domain, we explicitly skip creating those cgroups in case priv->cgroup
is NULL (cgroups not supported) because SetAffinity() serves the same
purpose.  If the host supports only some cgroups (the ones we need are
either unmounted or disabled in qemu.conf), we error out with weird
message even though we could continue starting the domain.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1097028

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
src/qemu/qemu_cgroup.c

index 00b405beb9e969b68c26744d07776c50db806f31..79f5f5522199cb97cdffb2eb4082dde8a5f5bcf7 100644 (file)
@@ -906,6 +906,15 @@ qemuSetupCgroupForVcpu(virDomainObjPtr vm)
         return -1;
     }
 
+    /*
+     * If CPU cgroup controller is not initialized here, then we need
+     * neither period nor quota settings.  And if CPUSET controller is
+     * not initialized either, then there's nothing to do anyway.
+     */
+    if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU) &&
+        !virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET))
+        return 0;
+
     /* We are trying to setup cgroups for CPU pinning, which can also be done
      * with virProcessSetAffinity, thus the lack of cgroups is not fatal here.
      */
@@ -985,6 +994,15 @@ qemuSetupCgroupForEmulator(virQEMUDriverPtr driver,
         return -1;
     }
 
+    /*
+     * If CPU cgroup controller is not initialized here, then we need
+     * neither period nor quota settings.  And if CPUSET controller is
+     * not initialized either, then there's nothing to do anyway.
+     */
+    if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU) &&
+        !virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET))
+        return 0;
+
     if (priv->cgroup == NULL)
         return 0; /* Not supported, so claim success */