[PATCH 4/4] qemu_hotplug: Temporarily allow emulator thread to access other NUMA nodes during mem hotplug

Michal Privoznik posted 4 patches 1 year ago
[PATCH 4/4] qemu_hotplug: Temporarily allow emulator thread to access other NUMA nodes during mem hotplug
Posted by Michal Privoznik 1 year ago
Again, this fixes the same problem as one of previous commits,
but this time for memory hotplug. Long story short, if there's a
domain running and the emulator thread is restricted to a subset
of host NUMA nodes, but the memory that's about to be hotplugged
requires memory from a host NUMA node that's not in the set we
need to allow emulator thread to access the node, temporarily.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_hotplug.c | 8 ++++++++
 src/qemu/qemu_process.c | 2 +-
 src/qemu/qemu_process.h | 3 +++
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index d5148f5815..972df572a7 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2247,6 +2247,7 @@ qemuDomainAttachMemory(virQEMUDriver *driver,
     bool teardownlabel = false;
     bool teardowncgroup = false;
     bool teardowndevice = false;
+    bool restoreemulatorcgroup = false;
     g_autoptr(virJSONValue) props = NULL;
     virObjectEvent *event;
     int id;
@@ -2294,6 +2295,10 @@ qemuDomainAttachMemory(virQEMUDriver *driver,
     if (qemuDomainAdjustMaxMemLock(vm) < 0)
         goto removedef;
 
+    if (qemuProcessSetupEmulator(vm, true) < 0)
+        goto removedef;
+    restoreemulatorcgroup = true;
+
     qemuDomainObjEnterMonitor(vm);
     if (qemuMonitorAddObject(priv->mon, &props, NULL) < 0)
         goto exit_monitor;
@@ -2333,6 +2338,9 @@ qemuDomainAttachMemory(virQEMUDriver *driver,
             qemuDomainReleaseMemoryDeviceSlot(vm, mem);
     }
 
+    if (restoreemulatorcgroup)
+        qemuProcessSetupEmulator(vm, false);
+
     virDomainMemoryDefFree(mem);
     return ret;
 
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 0fafda0beb..803bf9b0a3 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2700,7 +2700,7 @@ qemuProcessSetupPid(virDomainObj *vm,
 }
 
 
-static int
+int
 qemuProcessSetupEmulator(virDomainObj *vm,
                          bool unionMems)
 {
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index e0cbafda1d..1c4c0678ab 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -235,3 +235,6 @@ void qemuProcessCleanupMigrationJob(virQEMUDriver *driver,
 
 void qemuProcessRefreshDiskProps(virDomainDiskDef *disk,
                                  struct qemuDomainDiskInfo *info);
+
+int qemuProcessSetupEmulator(virDomainObj *vm,
+                             bool unionMems);
-- 
2.39.3
Re: [PATCH 4/4] qemu_hotplug: Temporarily allow emulator thread to access other NUMA nodes during mem hotplug
Posted by Martin Kletzander 1 year ago
On Tue, May 23, 2023 at 12:06:21PM +0200, Michal Privoznik wrote:
>Again, this fixes the same problem as one of previous commits,
>but this time for memory hotplug. Long story short, if there's a
>domain running and the emulator thread is restricted to a subset
>of host NUMA nodes, but the memory that's about to be hotplugged
>requires memory from a host NUMA node that's not in the set we
>need to allow emulator thread to access the node, temporarily.
>
>Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>---
> src/qemu/qemu_hotplug.c | 8 ++++++++
> src/qemu/qemu_process.c | 2 +-
> src/qemu/qemu_process.h | 3 +++
> 3 files changed, 12 insertions(+), 1 deletion(-)
>
>diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
>index d5148f5815..972df572a7 100644
>--- a/src/qemu/qemu_hotplug.c
>+++ b/src/qemu/qemu_hotplug.c
>@@ -2247,6 +2247,7 @@ qemuDomainAttachMemory(virQEMUDriver *driver,
>     bool teardownlabel = false;
>     bool teardowncgroup = false;
>     bool teardowndevice = false;
>+    bool restoreemulatorcgroup = false;

whoinventedthesevariablenames

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>