Blame SOURCES/libvirt-qemu-Set-up-EMULATOR-thread-and-cpuset.mems-before-exec-ing-qemu.patch

c313de
From ac89574e251dfecf34606083e402194ded63dba2 Mon Sep 17 00:00:00 2001
c313de
Message-Id: <ac89574e251dfecf34606083e402194ded63dba2@dist-git>
c313de
From: Michal Privoznik <mprivozn@redhat.com>
c313de
Date: Wed, 5 Jun 2019 11:33:29 +0200
c313de
Subject: [PATCH] qemu: Set up EMULATOR thread and cpuset.mems before
c313de
 exec()-ing qemu
c313de
c313de
It's funny how this went unnoticed for such a long time. Long
c313de
story short, if a domain is configured with
c313de
VIR_DOMAIN_NUMATUNE_MEM_STRICT libvirt doesn't really honour
c313de
that. This is because of 7e72ac787848 after which libvirt allowed
c313de
qemu to allocate memory just anywhere and only after that it used
c313de
some magic involving cpuset.memory_migrate and cpuset.mems to
c313de
move the memory to desired NUMA nodes. This was done in order to
c313de
work around some KVM bug where KVM would fail if there wasn't a
c313de
DMA zone available on the NUMA node. Well, while the work around
c313de
might stopped libvirt tickling the KVM bug it also caused a bug
c313de
on libvirt side: if there is not enough memory on configured NUMA
c313de
node(s) then any attempt to start a domain must fail. Because of
c313de
the way we play with guest memory domains can start just happily.
c313de
c313de
The solution is to move the child we've just forked into emulator
c313de
cgroup, set up cpuset.mems and exec() qemu only after that.
c313de
c313de
This basically reverts 7e72ac787848b7434c9 which was a workaround
c313de
for kernel bug. This bug was apparently fixed because I've tested
c313de
this successfully with recent kernel.
c313de
c313de
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
c313de
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
c313de
(cherry picked from commit 0eaa4716e1b8f6eb59d77049aed3735c3b5fbdd6)
c313de
c313de
https://bugzilla.redhat.com/show_bug.cgi?id=1716943
c313de
c313de
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
c313de
Message-Id: <fe479c5bad92778ec29f1c1bf4fb0c7b9049f3ab.1559727075.git.mprivozn@redhat.com>
c313de
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
c313de
---
c313de
 src/qemu/qemu_process.c | 8 ++++----
c313de
 1 file changed, 4 insertions(+), 4 deletions(-)
c313de
c313de
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
c313de
index 6071b3ba3d..8b05cef80c 100644
c313de
--- a/src/qemu/qemu_process.c
c313de
+++ b/src/qemu/qemu_process.c
c313de
@@ -6442,6 +6442,10 @@ qemuProcessLaunch(virConnectPtr conn,
c313de
     if (qemuProcessInitCpuAffinity(vm) < 0)
c313de
         goto cleanup;
c313de
 
c313de
+    VIR_DEBUG("Setting emulator tuning/settings");
c313de
+    if (qemuProcessSetupEmulator(vm) < 0)
c313de
+        goto cleanup;
c313de
+
c313de
     VIR_DEBUG("Setting cgroup for external devices (if required)");
c313de
     if (qemuSetupCgroupForExtDevices(vm, driver) < 0)
c313de
         goto cleanup;
c313de
@@ -6533,10 +6537,6 @@ qemuProcessLaunch(virConnectPtr conn,
c313de
     if (qemuProcessDetectIOThreadPIDs(driver, vm, asyncJob) < 0)
c313de
         goto cleanup;
c313de
 
c313de
-    VIR_DEBUG("Setting emulator tuning/settings");
c313de
-    if (qemuProcessSetupEmulator(vm) < 0)
c313de
-        goto cleanup;
c313de
-
c313de
     VIR_DEBUG("Setting global CPU cgroup (if required)");
c313de
     if (qemuSetupGlobalCpuCgroup(vm) < 0)
c313de
         goto cleanup;
c313de
-- 
c313de
2.22.0
c313de