render / rpms / libvirt

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