render / rpms / libvirt

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