render / rpms / libvirt

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