]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: do not put a task into machine cgroup
authorHenning Schild <henning.schild@siemens.com>
Mon, 14 Dec 2015 20:48:05 +0000 (15:48 -0500)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 14 Dec 2015 20:48:05 +0000 (15:48 -0500)
The machine cgroup is a superset, a parent to the emulator and vcpuX
cgroups. The parent cgroup should never have any tasks directly in it.
In fact the parent cpuset might contain way more cpus than the sum of
emulatorpin and vcpupins. So putting tasks in the superset will allow
them to run outside of <cputune>.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
src/qemu/qemu_cgroup.c
src/qemu/qemu_process.c

index 5df5e4537d765de2b41e3739dda580e66d3a2e62..14cf657b7702d5e0bce33d2227d82ae6020cf8f0 100644 (file)
@@ -789,17 +789,6 @@ qemuInitCgroup(virQEMUDriverPtr driver,
         goto cleanup;
     }
 
-    if (virCgroupAddTask(priv->cgroup, vm->pid) < 0) {
-        virErrorPtr saved = virSaveLastError();
-        virCgroupRemove(priv->cgroup);
-        virCgroupFree(&priv->cgroup);
-        if (saved) {
-            virSetError(saved);
-            virFreeError(saved);
-        }
-        goto cleanup;
-    }
-
  done:
     ret = 0;
  cleanup:
@@ -1170,6 +1159,10 @@ qemuSetupCgroupForEmulator(virDomainObjPtr vm)
             goto cleanup;
     }
 
+    /* consider the first thread an emulator-thread */
+    if (virCgroupAddTask(cgroup_emulator, vm->pid) < 0)
+        goto cleanup;
+
     virCgroupFree(&cgroup_emulator);
     return 0;
 
index 229808e15ea8e7aef2224b12c59958c8c641782c..ba8dfebd1357a238033f9be98c42667de673918a 100644 (file)
@@ -4888,12 +4888,6 @@ qemuProcessLaunch(virConnectPtr conn,
     if (qemuSetupCgroup(driver, vm, nnicindexes, nicindexes) < 0)
         goto cleanup;
 
-    /* This must be done after cgroup placement to avoid resetting CPU
-     * affinity */
-    if (!vm->def->cputune.emulatorpin &&
-        qemuProcessInitCpuAffinity(vm) < 0)
-        goto cleanup;
-
     VIR_DEBUG("Setting domain security labels");
     if (virSecurityManagerSetAllLabel(driver->securityManager,
                                       vm->def,
@@ -4940,6 +4934,12 @@ qemuProcessLaunch(virConnectPtr conn,
     if (qemuSetupCgroupForEmulator(vm) < 0)
         goto cleanup;
 
+    /* This must be done after cgroup placement to avoid resetting CPU
+     * affinity */
+    if (!vm->def->cputune.emulatorpin &&
+        qemuProcessInitCpuAffinity(vm) < 0)
+        goto cleanup;
+
     VIR_DEBUG("Setting affinity of emulator threads");
     if (qemuProcessSetEmulatorAffinity(vm) < 0)
         goto cleanup;