render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
e8e641
From 179240a310b8b74075f90c1580b2864aa406bf03 Mon Sep 17 00:00:00 2001
e8e641
Message-Id: <179240a310b8b74075f90c1580b2864aa406bf03@dist-git>
e8e641
From: Michal Privoznik <mprivozn@redhat.com>
e8e641
Date: Tue, 7 Mar 2023 12:39:47 +0100
e8e641
Subject: [PATCH] qemu: Add @nodemask argument to qemuBuildThreadContextProps()
e8e641
e8e641
When building a thread-context object (inside of
e8e641
qemuBuildThreadContextProps()) we look at given memory-backend-*
e8e641
object and look for .host-nodes attribute. This works, as long as
e8e641
we need to just copy the attribute value into another
e8e641
thread-context attribute. But soon we will need to adjust it.
e8e641
That's the point where having the value in virBitmap comes handy.
e8e641
Utilize the previous commit, which made
e8e641
qemuBuildMemoryBackendProps() set the argument and pass it into
e8e641
qemuBuildThreadContextProps().
e8e641
e8e641
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
e8e641
Reviewed-by: Kristina Hanicova <khanicov@redhat.com>
e8e641
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
e8e641
(cherry picked from commit 45222a83b76e05a522afc8743a77ca320feb72f2)
e8e641
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2185039
e8e641
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
e8e641
---
e8e641
 src/qemu/qemu_command.c | 38 +++++++++++++++++++++-----------------
e8e641
 src/qemu/qemu_command.h |  3 ++-
e8e641
 2 files changed, 23 insertions(+), 18 deletions(-)
e8e641
e8e641
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
e8e641
index 938332496f..346967f51c 100644
e8e641
--- a/src/qemu/qemu_command.c
e8e641
+++ b/src/qemu/qemu_command.c
e8e641
@@ -3490,7 +3490,8 @@ qemuBuildMemoryCellBackendProps(virDomainDef *def,
e8e641
                                 virQEMUDriverConfig *cfg,
e8e641
                                 size_t cell,
e8e641
                                 qemuDomainObjPrivate *priv,
e8e641
-                                virJSONValue **props)
e8e641
+                                virJSONValue **props,
e8e641
+                                virBitmap **nodemask)
e8e641
 {
e8e641
     g_autofree char *alias = NULL;
e8e641
     virDomainMemoryDef mem = { 0 };
e8e641
@@ -3503,8 +3504,8 @@ qemuBuildMemoryCellBackendProps(virDomainDef *def,
e8e641
     mem.targetNode = cell;
e8e641
     mem.info.alias = alias;
e8e641
 
e8e641
-    return qemuBuildMemoryBackendProps(props, alias, cfg, priv,
e8e641
-                                       def, &mem, false, false, NULL);
e8e641
+    return qemuBuildMemoryBackendProps(props, alias, cfg, priv, def,
e8e641
+                                       &mem, false, false, nodemask);
e8e641
 }
e8e641
 
e8e641
 
e8e641
@@ -3517,6 +3518,7 @@ qemuBuildMemoryDimmBackendStr(virCommand *cmd,
e8e641
 {
e8e641
     g_autoptr(virJSONValue) props = NULL;
e8e641
     g_autoptr(virJSONValue) tcProps = NULL;
e8e641
+    virBitmap *nodemask = NULL;
e8e641
     g_autofree char *alias = NULL;
e8e641
 
e8e641
     if (!mem->info.alias) {
e8e641
@@ -3527,11 +3529,11 @@ qemuBuildMemoryDimmBackendStr(virCommand *cmd,
e8e641
 
e8e641
     alias = g_strdup_printf("mem%s", mem->info.alias);
e8e641
 
e8e641
-    if (qemuBuildMemoryBackendProps(&props, alias, cfg,
e8e641
-                                    priv, def, mem, true, false, NULL) < 0)
e8e641
+    if (qemuBuildMemoryBackendProps(&props, alias, cfg, priv,
e8e641
+                                    def, mem, true, false, &nodemask) < 0)
e8e641
         return -1;
e8e641
 
e8e641
-    if (qemuBuildThreadContextProps(&tcProps, &props, priv) < 0)
e8e641
+    if (qemuBuildThreadContextProps(&tcProps, &props, priv, nodemask) < 0)
e8e641
         return -1;
e8e641
 
e8e641
     if (tcProps &&
e8e641
@@ -3628,11 +3630,10 @@ qemuBuildMemoryDeviceProps(virQEMUDriverConfig *cfg,
e8e641
 int
e8e641
 qemuBuildThreadContextProps(virJSONValue **tcProps,
e8e641
                             virJSONValue **memProps,
e8e641
-                            qemuDomainObjPrivate *priv)
e8e641
+                            qemuDomainObjPrivate *priv,
e8e641
+                            virBitmap *nodemask)
e8e641
 {
e8e641
     g_autoptr(virJSONValue) props = NULL;
e8e641
-    virJSONValue *nodemask = NULL;
e8e641
-    g_autoptr(virJSONValue) nodemaskCopy = NULL;
e8e641
     g_autofree char *tcAlias = NULL;
e8e641
     const char *memalias = NULL;
e8e641
     bool prealloc = false;
e8e641
@@ -3642,7 +3643,6 @@ qemuBuildThreadContextProps(virJSONValue **tcProps,
e8e641
     if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_THREAD_CONTEXT))
e8e641
         return 0;
e8e641
 
e8e641
-    nodemask = virJSONValueObjectGetArray(*memProps, "host-nodes");
e8e641
     if (!nodemask)
e8e641
         return 0;
e8e641
 
e8e641
@@ -3658,12 +3658,11 @@ qemuBuildThreadContextProps(virJSONValue **tcProps,
e8e641
     }
e8e641
 
e8e641
     tcAlias = g_strdup_printf("tc-%s", memalias);
e8e641
-    nodemaskCopy = virJSONValueCopy(nodemask);
e8e641
 
e8e641
     if (virJSONValueObjectAdd(&props,
e8e641
                               "s:qom-type", "thread-context",
e8e641
                               "s:id", tcAlias,
e8e641
-                              "a:node-affinity", &nodemaskCopy,
e8e641
+                              "m:node-affinity", nodemask,
e8e641
                               NULL) < 0)
e8e641
         return -1;
e8e641
 
e8e641
@@ -7054,17 +7053,18 @@ qemuBuildMemCommandLineMemoryDefaultBackend(virCommand *cmd,
e8e641
     g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(priv->driver);
e8e641
     g_autoptr(virJSONValue) props = NULL;
e8e641
     g_autoptr(virJSONValue) tcProps = NULL;
e8e641
+    virBitmap *nodemask = NULL;
e8e641
     virDomainMemoryDef mem = { 0 };
e8e641
 
e8e641
     mem.size = virDomainDefGetMemoryInitial(def);
e8e641
     mem.targetNode = -1;
e8e641
     mem.info.alias = (char *) defaultRAMid;
e8e641
 
e8e641
-    if (qemuBuildMemoryBackendProps(&props, defaultRAMid, cfg,
e8e641
-                                    priv, def, &mem, false, true, NULL) < 0)
e8e641
+    if (qemuBuildMemoryBackendProps(&props, defaultRAMid, cfg, priv,
e8e641
+                                    def, &mem, false, true, &nodemask) < 0)
e8e641
         return -1;
e8e641
 
e8e641
-    if (qemuBuildThreadContextProps(&tcProps, &props, priv) < 0)
e8e641
+    if (qemuBuildThreadContextProps(&tcProps, &props, priv, nodemask) < 0)
e8e641
         return -1;
e8e641
 
e8e641
     if (tcProps &&
e8e641
@@ -7335,6 +7335,7 @@ qemuBuildNumaCommandLine(virQEMUDriverConfig *cfg,
e8e641
     virQEMUCaps *qemuCaps = priv->qemuCaps;
e8e641
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
e8e641
     virJSONValue **nodeBackends = NULL;
e8e641
+    g_autofree virBitmap **nodemask = NULL;
e8e641
     bool needBackend = false;
e8e641
     bool hmat = false;
e8e641
     int ret = -1;
e8e641
@@ -7356,10 +7357,12 @@ qemuBuildNumaCommandLine(virQEMUDriverConfig *cfg,
e8e641
     }
e8e641
 
e8e641
     nodeBackends = g_new0(virJSONValue *, ncells);
e8e641
+    nodemask = g_new0(virBitmap *, ncells);
e8e641
 
e8e641
     for (i = 0; i < ncells; i++) {
e8e641
         if ((rc = qemuBuildMemoryCellBackendProps(def, cfg, i, priv,
e8e641
-                                                  &nodeBackends[i])) < 0)
e8e641
+                                                  &nodeBackends[i],
e8e641
+                                                  &nodemask[i])) < 0)
e8e641
             goto cleanup;
e8e641
 
e8e641
         if (rc == 0)
e8e641
@@ -7389,7 +7392,8 @@ qemuBuildNumaCommandLine(virQEMUDriverConfig *cfg,
e8e641
         if (needBackend) {
e8e641
             g_autoptr(virJSONValue) tcProps = NULL;
e8e641
 
e8e641
-            if (qemuBuildThreadContextProps(&tcProps, &nodeBackends[i], priv) < 0)
e8e641
+            if (qemuBuildThreadContextProps(&tcProps, &nodeBackends[i],
e8e641
+                                            priv, nodemask[i]) < 0)
e8e641
                 goto cleanup;
e8e641
 
e8e641
             if (tcProps &&
e8e641
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
e8e641
index 9074822bc5..17f326d13b 100644
e8e641
--- a/src/qemu/qemu_command.h
e8e641
+++ b/src/qemu/qemu_command.h
e8e641
@@ -153,7 +153,8 @@ qemuBuildMemoryDeviceProps(virQEMUDriverConfig *cfg,
e8e641
 int
e8e641
 qemuBuildThreadContextProps(virJSONValue **tcProps,
e8e641
                             virJSONValue **memProps,
e8e641
-                            qemuDomainObjPrivate *priv);
e8e641
+                            qemuDomainObjPrivate *priv,
e8e641
+                            virBitmap *nodemask);
e8e641
 
e8e641
 /* Current, best practice */
e8e641
 virJSONValue *
e8e641
-- 
e8e641
2.40.0