v3 of:
diff to v2:
- Not calling qemuSetupCpusetMems() in qemuProcessLaunch
- Dropping qemuSetupCpusetMems()
Michal Prívozník (2):
qemu: Set up EMULATOR thread and cpuset.mems before exec()-ing qemu
qemu_cgroup: Remove unused qemuSetupCpusetMems
src/qemu/qemu_cgroup.c | 35 -----------------------------------
src/qemu/qemu_cgroup.h | 1 -
src/qemu/qemu_process.c | 8 ++++----
3 files changed, 4 insertions(+), 40 deletions(-)
--
2.21.0
Show replies by date
It's funny how this went unnoticed for such a long time. Long
story short, if a domain is configured with
VIR_DOMAIN_NUMATUNE_MEM_STRICT libvirt doesn't really honour
that. This is because of 7e72ac787848 after which libvirt allowed
qemu to allocate memory just anywhere and only after that it used
some magic involving cpuset.memory_migrate and cpuset.mems to
move the memory to desired NUMA nodes. This was done in order to
work around some KVM bug where KVM would fail if there wasn't a
DMA zone available on the NUMA node. Well, while the work around
might stopped libvirt tickling the KVM bug it also caused a bug
on libvirt side: if there is not enough memory on configured NUMA
node(s) then any attempt to start a domain must fail. Because of
the way we play with guest memory domains can start just happily.
The solution is to move the child we've just forked into emulator
cgroup, set up cpuset.mems and exec() qemu only after that.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_process.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index f773aa89b7..746db85631 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -6653,6 +6653,10 @@ qemuProcessLaunch(virConnectPtr conn,
if (qemuProcessInitCpuAffinity(vm) < 0)
goto cleanup;
+ VIR_DEBUG("Setting emulator tuning/settings");
+ if (qemuProcessSetupEmulator(vm) < 0)
+ goto cleanup;
+
VIR_DEBUG("Setting cgroup for external devices (if required)");
if (qemuSetupCgroupForExtDevices(vm, driver) < 0)
goto cleanup;
@@ -6744,10 +6748,6 @@ qemuProcessLaunch(virConnectPtr conn,
if (qemuProcessDetectIOThreadPIDs(driver, vm, asyncJob) < 0)
goto cleanup;
- VIR_DEBUG("Setting emulator tuning/settings");
- if (qemuProcessSetupEmulator(vm) < 0)
- goto cleanup;
-
VIR_DEBUG("Setting global CPU cgroup (if required)");
if (qemuSetupGlobalCpuCgroup(vm) < 0)
goto cleanup;
--
2.21.0
This function is not used anymore. Let's remove it.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_cgroup.c | 35 -----------------------------------
src/qemu/qemu_cgroup.h | 1 -
2 files changed, 36 deletions(-)
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index c23f0af2aa..ca76c4fdfa 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -824,41 +824,6 @@ qemuSetupDevicesCgroup(virDomainObjPtr vm)
}
-int
-qemuSetupCpusetMems(virDomainObjPtr vm)
-{
- virCgroupPtr cgroup_temp = NULL;
- qemuDomainObjPrivatePtr priv = vm->privateData;
- virDomainNumatuneMemMode mode;
- char *mem_mask = NULL;
- int ret = -1;
-
- if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET))
- return 0;
-
- if (virDomainNumatuneGetMode(vm->def->numa, -1, &mode) < 0 ||
- mode != VIR_DOMAIN_NUMATUNE_MEM_STRICT)
- return 0;
-
- if (virDomainNumatuneMaybeFormatNodeset(vm->def->numa,
- priv->autoNodeset,
- &mem_mask, -1) < 0)
- goto cleanup;
-
- if (mem_mask)
- if (virCgroupNewThread(priv->cgroup, VIR_CGROUP_THREAD_EMULATOR, 0,
- false, &cgroup_temp) < 0 ||
- virCgroupSetCpusetMems(cgroup_temp, mem_mask) < 0)
- goto cleanup;
-
- ret = 0;
- cleanup:
- VIR_FREE(mem_mask);
- virCgroupFree(&cgroup_temp);
- return ret;
-}
-
-
static int
qemuSetupCpusetCgroup(virDomainObjPtr vm)
{
diff --git a/src/qemu/qemu_cgroup.h b/src/qemu/qemu_cgroup.h
index dc6d173fce..88ad4a38b6 100644
--- a/src/qemu/qemu_cgroup.h
+++ b/src/qemu/qemu_cgroup.h
@@ -61,7 +61,6 @@ int qemuConnectCgroup(virDomainObjPtr vm);
int qemuSetupCgroup(virDomainObjPtr vm,
size_t nnicindexes,
int *nicindexes);
-int qemuSetupCpusetMems(virDomainObjPtr vm);
int qemuSetupCgroupVcpuBW(virCgroupPtr cgroup,
unsigned long long period,
long long quota);
--
2.21.0
This series is
Reviewed-by: Martin Kletzander <mkletzan(a)redhat.com>