const virDomainDef *def,
virQEMUCapsPtr qemuCaps)
{
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
bool obsoleteAccel = false;
+ int ret = -1;
/* This should *never* be NULL, since we always provide
* a machine in the capabilities data for QEMU. So this
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("disable shared memory is not available "
"with this QEMU binary"));
- return -1;
+ return -1;
}
obsoleteAccel = true;
return -1;
}
} else {
- virBuffer buf = VIR_BUFFER_INITIALIZER;
virTristateSwitch vmport = def->features[VIR_DOMAIN_FEATURE_VMPORT];
virCommandAddArg(cmd, "-machine");
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("vmport is not available "
"with this QEMU binary"));
- virBufferFreeAndReset(&buf);
- return -1;
+ goto cleanup;
}
virBufferAsprintf(&buf, ",vmport=%s",
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("dump-guest-core is not available "
"with this QEMU binary"));
- virBufferFreeAndReset(&buf);
- return -1;
+ goto cleanup;
}
virBufferAsprintf(&buf, ",dump-guest-core=%s",
}
if (def->mem.nosharepages) {
- if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_MEM_MERGE)) {
- virBufferAddLit(&buf, ",mem-merge=off");
- } else {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MEM_MERGE)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("disable shared memory is not available "
"with this QEMU binary"));
- virBufferFreeAndReset(&buf);
- return -1;
+ goto cleanup;
}
+
+ virBufferAddLit(&buf, ",mem-merge=off");
}
if (def->keywrap &&
- !qemuAppendKeyWrapMachineParms(&buf, qemuCaps, def->keywrap)) {
- virBufferFreeAndReset(&buf);
- return -1;
- }
+ !qemuAppendKeyWrapMachineParms(&buf, qemuCaps, def->keywrap))
+ goto cleanup;
if (def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ON) {
if (def->gic_version != VIR_GIC_VERSION_NONE) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("gic-version option is available "
"only for ARM virt machine"));
- virBufferFreeAndReset(&buf);
- return -1;
+ goto cleanup;
}
/* The default GIC version should not be specified on the
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("gic-version option is not available "
"with this QEMU binary"));
- virBufferFreeAndReset(&buf);
- return -1;
+ goto cleanup;
}
virBufferAsprintf(&buf, ",gic-version=%s",
if (obsoleteAccel &&
qemuBuildObsoleteAccelArg(cmd, def, qemuCaps) < 0)
- return -1;
+ goto cleanup;
- return 0;
+ ret = 0;
+ cleanup:
+ virBufferFreeAndReset(&buf);
+ return ret;
}
static int