From: Daniel P. Berrange Date: Mon, 23 Sep 2013 16:43:47 +0000 (+0100) Subject: Honour error returned by virBitmapFormat X-Git-Tag: v1.1.3-rc1~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b81f30566b919bebff0df9501574848088cae6a6;p=thirdparty%2Flibvirt.git Honour error returned by virBitmapFormat The code formatting NUMA args was ignoring the return value of virBitmapFormat, so on OOM, it would silently drop the NUMA cpumask arg. Signed-off-by: Daniel P. Berrange --- diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9900b411f8..fe3d353ce3 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6861,22 +6861,22 @@ qemuBuildNumaArgStr(const virDomainDefPtr def, virCommandPtr cmd) virCommandAddArg(cmd, "-numa"); virBufferAsprintf(&buf, "node,nodeid=%d", def->cpu->cells[i].cellid); virBufferAddLit(&buf, ",cpus="); - cpumask = virBitmapFormat(def->cpu->cells[i].cpumask); - if (cpumask) { - /* Up through qemu 1.4, -numa does not accept a cpus - * argument any more complex than start-stop. - * - * XXX For qemu 1.5, the syntax has not yet been decided; - * but when it is, we need a capability bit and - * translation of our cpumask into the qemu syntax. */ - if (strchr(cpumask, ',')) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("disjoint NUMA cpu ranges are not supported " - "with this QEMU")); - goto cleanup; - } - virBufferAdd(&buf, cpumask, -1); + if (!(cpumask = virBitmapFormat(def->cpu->cells[i].cpumask))) + goto cleanup; + + /* Up through qemu 1.4, -numa does not accept a cpus + * argument any more complex than start-stop. + * + * XXX For qemu 1.5, the syntax has not yet been decided; + * but when it is, we need a capability bit and + * translation of our cpumask into the qemu syntax. */ + if (strchr(cpumask, ',')) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("disjoint NUMA cpu ranges are not supported " + "with this QEMU")); + goto cleanup; } + virBufferAdd(&buf, cpumask, -1); def->cpu->cells[i].mem = VIR_DIV_UP(def->cpu->cells[i].mem, 1024) * 1024; virBufferAsprintf(&buf, ",mem=%d", def->cpu->cells[i].mem / 1024);