&backendType, &props, false)) < 0)
goto cleanup;
- if (rc == 1) {
- ret = 0;
- goto cleanup;
- }
-
if (!(*backendStr = qemuBuildObjectCommandlineFromJSON(backendType,
alias,
props)))
goto cleanup;
- ret = 0;
+ ret = rc;
cleanup:
VIR_FREE(alias);
size_t i;
virBuffer buf = VIR_BUFFER_INITIALIZER;
char *cpumask = NULL, *tmpmask = NULL, *next = NULL;
- char *backendStr = NULL;
+ char **nodeBackends = NULL;
+ bool needBackend = false;
+ int rc;
int ret = -1;
const long system_page_size = sysconf(_SC_PAGESIZE) / 1024;
}
}
+ if (VIR_ALLOC_N(nodeBackends, def->cpu->ncells) < 0)
+ goto cleanup;
+
+ /* using of -numa memdev= cannot be combined with -numa mem=, thus we
+ * need to check which approach to use */
for (i = 0; i < def->cpu->ncells; i++) {
unsigned long long cellmem = VIR_DIV_UP(def->cpu->cells[i].mem, 1024);
def->cpu->cells[i].mem = cellmem * 1024;
- VIR_FREE(cpumask);
- VIR_FREE(backendStr);
-
- if (!(cpumask = virBitmapFormat(def->cpu->cells[i].cpumask)))
- goto cleanup;
-
- if (strchr(cpumask, ',') &&
- !virQEMUCapsGet(qemuCaps, QEMU_CAPS_NUMA)) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
- _("disjoint NUMA cpu ranges are not supported "
- "with this QEMU"));
- goto cleanup;
- }
-
-
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_RAM) ||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_MEMORY_FILE)) {
- if (qemuBuildMemoryCellBackendStr(def, qemuCaps, cfg, i,
- auto_nodeset, &backendStr) < 0)
+ if ((rc = qemuBuildMemoryCellBackendStr(def, qemuCaps, cfg, i,
+ auto_nodeset,
+ &nodeBackends[i])) < 0)
goto cleanup;
- if (backendStr) {
- virCommandAddArg(cmd, "-object");
- virCommandAddArg(cmd, backendStr);
- }
+ if (rc == 0)
+ needBackend = true;
} else {
if (def->cpu->cells[i].memAccess) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
goto cleanup;
}
}
+ }
+
+ for (i = 0; i < def->cpu->ncells; i++) {
+ VIR_FREE(cpumask);
+ if (!(cpumask = virBitmapFormat(def->cpu->cells[i].cpumask)))
+ goto cleanup;
+
+ if (strchr(cpumask, ',') &&
+ !virQEMUCapsGet(qemuCaps, QEMU_CAPS_NUMA)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("disjoint NUMA cpu ranges are not supported "
+ "with this QEMU"));
+ goto cleanup;
+ }
+
+ if (needBackend)
+ virCommandAddArgList(cmd, "-object", nodeBackends[i], NULL);
virCommandAddArg(cmd, "-numa");
virBufferAsprintf(&buf, "node,nodeid=%zu", i);
virBufferAdd(&buf, tmpmask, -1);
}
- if (backendStr)
+ if (needBackend)
virBufferAsprintf(&buf, ",memdev=ram-node%zu", i);
else
- virBufferAsprintf(&buf, ",mem=%llu", cellmem);
+ virBufferAsprintf(&buf, ",mem=%llu", def->cpu->cells[i].mem / 1024);
virCommandAddArgBuffer(cmd, &buf);
}
cleanup:
VIR_FREE(cpumask);
- VIR_FREE(backendStr);
+
+ if (nodeBackends) {
+ for (i = 0; i < def->cpu->ncells; i++)
+ VIR_FREE(nodeBackends[i]);
+
+ VIR_FREE(nodeBackends);
+ }
+
virBufferFreeAndReset(&buf);
return ret;
}