From a41c00b472efaa192d2deae51ab732e65903238f Mon Sep 17 00:00:00 2001 From: Henning Schild Date: Mon, 14 Dec 2015 15:48:05 -0500 Subject: [PATCH] qemu: do not put a task into machine cgroup 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 . Signed-off-by: Henning Schild --- src/qemu/qemu_cgroup.c | 15 ++++----------- src/qemu/qemu_process.c | 12 ++++++------ 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 5df5e4537d..14cf657b77 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -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; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 229808e15e..ba8dfebd13 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -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;