[PATCH 4/5] qemuBuildNumaCommandLine: Separate out building of CPU list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_command.c | 43 ++++++++++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 020cbfa214..f04ae1e311 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7407,6 +7407,31 @@ qemuBuildNumaHMATCommandLine(virCommand *cmd,
 }
 
 
+static int
+qemuBuildNumaCPUs(virBuffer *buf,
+                  virBitmap *cpu)
+{
+    g_autofree char *cpumask = NULL;
+    char *tmpmask = NULL;
+    char *next = NULL;
+
+    if (!cpu)
+        return 0;
+
+    if (!(cpumask = virBitmapFormat(cpu)))
+        return -1;
+
+    for (tmpmask = cpumask; tmpmask; tmpmask = next) {
+        if ((next = strchr(tmpmask, ',')))
+            *(next++) = '\0';
+        virBufferAddLit(buf, ",cpus=");
+        virBufferAdd(buf, tmpmask, -1);
+    }
+
+    return 0;
+}
+
+
 static int
 qemuBuildNumaCommandLine(virQEMUDriverConfig *cfg,
                          virDomainDef *def,
@@ -7473,7 +7498,6 @@ qemuBuildNumaCommandLine(virQEMUDriverConfig *cfg,
     }
 
     for (i = 0; i < ncells; i++) {
-        virBitmap *cpumask = virDomainNumaGetNodeCpumask(def->numa, i);
         ssize_t initiator = virDomainNumaGetNodeInitiator(def->numa, i);
 
         if (needBackend) {
@@ -7484,21 +7508,8 @@ qemuBuildNumaCommandLine(virQEMUDriverConfig *cfg,
         virCommandAddArg(cmd, "-numa");
         virBufferAsprintf(&buf, "node,nodeid=%zu", i);
 
-        if (cpumask) {
-            g_autofree char *cpumaskStr = NULL;
-            char *next = NULL;
-            char *tmpmask;
-
-            if (!(cpumaskStr = virBitmapFormat(cpumask)))
-                goto cleanup;
-
-            for (tmpmask = cpumaskStr; tmpmask; tmpmask = next) {
-                if ((next = strchr(tmpmask, ',')))
-                    *(next++) = '\0';
-                virBufferAddLit(&buf, ",cpus=");
-                virBufferAdd(&buf, tmpmask, -1);
-            }
-        }
+        if (qemuBuildNumaCPUs(&buf, virDomainNumaGetNodeCpumask(def->numa, i)) < 0)
+            goto cleanup;
 
         if (hmat) {
             if (initiator < 0)
-- 
2.32.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux