]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Set up EMULATOR thread and cpuset.mems before exec()-ing qemu
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 10 Apr 2019 15:14:25 +0000 (17:14 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 18 Apr 2019 15:53:42 +0000 (17:53 +0200)
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.

This basically reverts 7e72ac787848b7434c9 which was a workaround
for kernel bug. This bug was apparently fixed because I've tested
this successfully with recent kernel.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/qemu/qemu_process.c

index a7a475e75c913d967035ac29aae14e055ada652f..688e27ab7296a880b4686b6e98dc22f82f09b47d 100644 (file)
@@ -6666,6 +6666,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;
@@ -6757,10 +6761,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;