Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_command.c | 38 +++++++++++++++++++++++++-------------
1 file changed, 25 insertions(+), 13 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 5a438d07c3..7d84fd8b5e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7057,6 +7057,28 @@ qemuBuildIOThreadCommandLine(virCommandPtr cmd,
}
+static int
+qemuBuildNumaOldCPUs(virBufferPtr buf,
+ virBitmapPtr cpu)
+{
+ g_autofree char *cpumask = NULL;
+ char *tmpmask = NULL;
+ char *next = NULL;
+
+ 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
qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
virDomainDefPtr def,
@@ -7109,13 +7131,6 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
goto cleanup;
for (i = 0; i < ncells; i++) {
- g_autofree char *cpumask = NULL;
- char *tmpmask = NULL;
- char *next = NULL;
-
- if (!(cpumask = virBitmapFormat(virDomainNumaGetNodeCpumask(def->numa, i))))
- goto cleanup;
-
if (needBackend) {
virCommandAddArg(cmd, "-object");
virCommandAddArgBuffer(cmd, &nodeBackends[i]);
@@ -7124,12 +7139,9 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
virCommandAddArg(cmd, "-numa");
virBufferAsprintf(&buf, "node,nodeid=%zu", i);
- for (tmpmask = cpumask; tmpmask; tmpmask = next) {
- if ((next = strchr(tmpmask, ',')))
- *(next++) = '\0';
- virBufferAddLit(&buf, ",cpus=");
- virBufferAdd(&buf, tmpmask, -1);
- }
+ if (qemuBuildNumaOldCPUs(&buf,
+ virDomainNumaGetNodeCpumask(def->numa, i)) < 0)
+ goto cleanup;
if (needBackend)
virBufferAsprintf(&buf, ",memdev=ram-node%zu", i);
--
2.26.2