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(a)siemens.com>
---
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 7320046..85b8e4e 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -770,17 +770,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:
@@ -1151,6 +1140,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 f7eb2b6..cfe1da8 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4881,12 +4881,6 @@ int qemuProcessStart(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, stdin_path) < 0)
@@ -4934,6 +4928,12 @@ int qemuProcessStart(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;
--
2.4.10