The recent cleanups allow us to clean up the code a bit.
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
src/qemu/qemu_command.c | 741 +++++++++++++++-------------------------
1 file changed, 274 insertions(+), 467 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index a4df133ca0..0e9bd77f62 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -202,7 +202,6 @@ static int
qemuBuildMasterKeyCommandLine(virCommandPtr cmd,
qemuDomainObjPrivatePtr priv)
{
- int ret = -1;
VIR_AUTOFREE(char *) alias = NULL;
VIR_AUTOFREE(char *) path = NULL;
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
@@ -225,17 +224,14 @@ qemuBuildMasterKeyCommandLine(virCommandPtr cmd,
* existence of socket files before using.
*/
if (!(path = qemuDomainGetMasterKeyFilePath(priv->libDir)))
- goto cleanup;
+ return -1;
virCommandAddArg(cmd, "-object");
virBufferAsprintf(&buf, "secret,id=%s,format=raw,file=", alias);
virQEMUBuildBufferEscapeComma(&buf, path);
virCommandAddArgBuffer(cmd, &buf);
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -298,7 +294,6 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
virDomainDeviceInfoPtr info,
virQEMUCapsPtr qemuCaps)
{
- int ret = -1;
VIR_AUTOFREE(char *) devStr = NULL;
const char *contAlias = NULL;
bool contIsPHB = false;
@@ -308,7 +303,7 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
size_t i;
if (!(devStr = virPCIDeviceAddressAsString(&info->addr.pci)))
- goto cleanup;
+ return -1;
for (i = 0; i < domainDef->ncontrollers; i++) {
virDomainControllerDefPtr cont = domainDef->controllers[i];
@@ -324,7 +319,7 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
"controller with index %u required "
"for device at address %s"),
info->addr.pci.bus, devStr);
- goto cleanup;
+ return -1;
}
if (virDomainDeviceAliasIsUserAlias(contAlias)) {
@@ -350,7 +345,7 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
"controller with index %u required "
"for device at address %s"),
info->addr.pci.bus, devStr);
- goto cleanup;
+ return -1;
}
if (contIsPHB && contTargetIndex > 0) {
@@ -376,7 +371,7 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
if (!(contAlias = virDomainControllerAliasFind(domainDef,
VIR_DOMAIN_CONTROLLER_TYPE_USB,
info->addr.usb.bus)))
- goto cleanup;
+ return -1;
virBufferAsprintf(buf, ",bus=%s.0", contAlias);
if (virDomainUSBAddressPortIsValid(info->addr.usb.port)) {
virBufferAddLit(buf, ",port=");
@@ -397,9 +392,7 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
info->addr.isa.irq);
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -733,22 +726,18 @@ qemuBuildObjectSecretCommandLine(virCommandPtr cmd,
qemuDomainSecretInfoPtr secinfo)
{
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
- int ret = -1;
VIR_AUTOPTR(virJSONValue) props = NULL;
if (qemuBuildSecretInfoProps(secinfo, &props) < 0)
return -1;
if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0)
- goto cleanup;
+ return -1;
virCommandAddArg(cmd, "-object");
virCommandAddArgBuffer(cmd, &buf);
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -929,23 +918,19 @@ qemuBuildTLSx509CommandLine(virCommandPtr cmd,
virQEMUCapsPtr qemuCaps)
{
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
- int ret = -1;
VIR_AUTOPTR(virJSONValue) props = NULL;
if (qemuBuildTLSx509BackendProps(tlspath, isListen, verifypeer, alias,
certEncSecretAlias, qemuCaps, &props) < 0)
- goto cleanup;
+ return -1;
if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0)
- goto cleanup;
+ return -1;
virCommandAddArg(cmd, "-object");
virCommandAddArgBuffer(cmd, &buf);
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -954,22 +939,18 @@ qemuBuildNetworkDriveURI(virStorageSourcePtr src,
qemuDomainSecretInfoPtr secinfo)
{
VIR_AUTOPTR(virURI) uri = NULL;
- char *ret = NULL;
if (!(uri = qemuBlockStorageSourceGetURI(src)))
- goto cleanup;
+ return NULL;
if (src->hosts->socket &&
virAsprintf(&uri->query, "socket=%s", src->hosts->socket)
< 0)
- goto cleanup;
+ return NULL;
if (qemuBuildGeneralSecinfoURI(uri, secinfo) < 0)
- goto cleanup;
-
- ret = virURIFormat(uri);
+ return NULL;
- cleanup:
- return ret;
+ return virURIFormat(uri);
}
@@ -977,9 +958,9 @@ static char *
qemuBuildNetworkDriveStr(virStorageSourcePtr src,
qemuDomainSecretInfoPtr secinfo)
{
- char *ret = NULL;
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
size_t i;
+ char *ret = NULL;
switch ((virStorageNetProtocol) src->protocol) {
case VIR_STORAGE_NET_PROTOCOL_NBD:
@@ -987,7 +968,7 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("protocol '%s' accepts only one
host"),
virStorageNetProtocolTypeToString(src->protocol));
- goto cleanup;
+ return NULL;
}
if (!((src->hosts->name && strchr(src->hosts->name,
':')) ||
@@ -1010,7 +991,7 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src,
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("socket attribute required for "
"unix transport"));
- goto cleanup;
+ return NULL;
}
virBufferAsprintf(&buf, "unix:%s",
src->hosts->socket);
@@ -1020,17 +1001,16 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("nbd does not support transport
'%s'"),
virStorageNetHostTransportTypeToString(src->hosts->transport));
- goto cleanup;
+ return NULL;
}
if (src->path)
virBufferAsprintf(&buf, ":exportname=%s",
src->path);
if (virBufferCheckError(&buf) < 0)
- goto cleanup;
+ return NULL;
- ret = virBufferContentAndReset(&buf);
- goto cleanup;
+ return virBufferContentAndReset(&buf);
}
/* NBD code uses URI formatting scheme as others in some cases */
ret = qemuBuildNetworkDriveURI(src, secinfo);
@@ -1050,21 +1030,21 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src,
if (!src->path) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing disk source for 'sheepdog'
protocol"));
- goto cleanup;
+ return NULL;
}
if (src->nhosts == 0) {
if (virAsprintf(&ret, "sheepdog:%s", src->path) < 0)
- goto cleanup;
+ return NULL;
} else if (src->nhosts == 1) {
if (virAsprintf(&ret, "sheepdog:%s:%u:%s",
src->hosts->name, src->hosts->port,
src->path) < 0)
- goto cleanup;
+ return NULL;
} else {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("protocol 'sheepdog' accepts up to one
host"));
- goto cleanup;
+ return NULL;
}
break;
@@ -1074,7 +1054,7 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("':' not allowed in RBD source volume name
'%s'"),
src->path);
- goto cleanup;
+ return NULL;
}
virBufferStrcat(&buf, "rbd:", src->volume, "/",
src->path, NULL);
@@ -1083,7 +1063,7 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src,
virBufferEscape(&buf, '\\', ":", "@%s",
src->snapshot);
if (qemuBuildRBDSecinfoURI(&buf, secinfo) < 0)
- goto cleanup;
+ return NULL;
if (src->nhosts > 0) {
virBufferAddLit(&buf, ":mon_host=");
@@ -1107,7 +1087,7 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src,
virBufferEscape(&buf, '\\', ":",
":conf=%s", src->configFile);
if (virBufferCheckError(&buf) < 0)
- goto cleanup;
+ return NULL;
ret = virBufferContentAndReset(&buf);
break;
@@ -1115,23 +1095,21 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src,
case VIR_STORAGE_NET_PROTOCOL_VXHS:
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("VxHS protocol does not support URI syntax"));
- goto cleanup;
+ return NULL;
case VIR_STORAGE_NET_PROTOCOL_SSH:
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("'ssh' protocol is not yet supported"));
- goto cleanup;
+ return NULL;
case VIR_STORAGE_NET_PROTOCOL_LAST:
case VIR_STORAGE_NET_PROTOCOL_NONE:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected network protocol '%s'"),
virStorageNetProtocolTypeToString(src->protocol));
- goto cleanup;
+ return NULL;
}
- cleanup:
-
return ret;
}
@@ -1142,7 +1120,6 @@ qemuGetDriveSourceString(virStorageSourcePtr src,
char **source)
{
int actualType = virStorageSourceGetActualType(src);
- int ret = -1;
*source = NULL;
@@ -1155,13 +1132,13 @@ qemuGetDriveSourceString(virStorageSourcePtr src,
case VIR_STORAGE_TYPE_FILE:
case VIR_STORAGE_TYPE_DIR:
if (VIR_STRDUP(*source, src->path) < 0)
- goto cleanup;
+ return -1;
break;
case VIR_STORAGE_TYPE_NETWORK:
if (!(*source = qemuBuildNetworkDriveStr(src, secinfo)))
- goto cleanup;
+ return -1;
break;
case VIR_STORAGE_TYPE_VOLUME:
@@ -1170,10 +1147,7 @@ qemuGetDriveSourceString(virStorageSourcePtr src,
break;
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -1510,18 +1484,16 @@ qemuCheckDiskConfig(virDomainDiskDefPtr disk,
bool
qemuCheckFips(void)
{
- bool ret = false;
-
if (virFileExists("/proc/sys/crypto/fips_enabled")) {
VIR_AUTOFREE(char *) buf = NULL;
if (virFileReadAll("/proc/sys/crypto/fips_enabled", 10, &buf) <
0)
- return ret;
+ return false;
if (STREQ(buf, "1\n"))
- ret = true;
+ return true;
}
- return ret;
+ return false;
}
@@ -1635,7 +1607,6 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
VIR_AUTOPTR(virJSONValue) srcprops = NULL;
VIR_AUTOFREE(char *) source = NULL;
bool rawluks = false;
- int ret = -1;
if (srcpriv) {
secinfo = srcpriv->secinfo;
@@ -1644,19 +1615,18 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
if (qemuDiskSourceNeedsProps(disk->src, qemuCaps) &&
!(srcprops = qemuDiskSourceGetProps(disk->src)))
- goto cleanup;
+ return -1;
if (!srcprops &&
qemuGetDriveSourceString(disk->src, secinfo, &source) < 0)
- goto cleanup;
+ return -1;
/* nothing to format if the drive is empty */
if (!(source || srcprops) ||
((disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY ||
disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) &&
disk->tray_status == VIR_DOMAIN_DISK_TRAY_OPEN)) {
- ret = 0;
- goto cleanup;
+ return 0;
}
if (actualType == VIR_STORAGE_TYPE_BLOCK &&
@@ -1665,7 +1635,7 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
disk->src->type == VIR_STORAGE_TYPE_VOLUME ?
_("tray status 'open' is invalid for block type
volume") :
_("tray status 'open' is invalid for block type
disk"));
- goto cleanup;
+ return -1;
}
if (source) {
@@ -1688,10 +1658,10 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
virBufferAsprintf(buf, ",file.debug=%d",
disk->src->debugLevel);
if (qemuBuildDriveSourcePR(buf, disk) < 0)
- goto cleanup;
+ return -1;
} else {
if (!(source = virQEMUBuildDriveCommandlineFromJSON(srcprops)))
- goto cleanup;
+ return -1;
virBufferAdd(buf, source, -1);
}
@@ -1716,10 +1686,7 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
virBufferAsprintf(buf, "format=%s,", qemuformat);
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -2392,7 +2359,6 @@ qemuBuildFloppyCommandLineControllerOptions(virCommandPtr cmd,
VIR_AUTOFREE(char *) backendStr = NULL;
VIR_AUTOFREE(char *) bootindexStr = NULL;
size_t i;
- int ret = -1;
virBufferAddLit(&fdc_opts, "isa-fdc,");
@@ -2418,16 +2384,16 @@ qemuBuildFloppyCommandLineControllerOptions(virCommandPtr cmd,
if (bootindex &&
virAsprintf(&bootindexStr, "bootindex%c=%u", driveLetter,
bootindex) < 0)
- goto cleanup;
+ return -1;
/* with -blockdev we setup the floppy device and it's backend with -device
*/
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) {
if (qemuDomainDiskGetBackendAlias(disk, qemuCaps, &backendAlias) < 0)
- goto cleanup;
+ return -1;
if (backendAlias &&
virAsprintf(&backendStr, "drive%c=%s", driveLetter,
backendAlias) < 0)
- goto cleanup;
+ return -1;
}
if (!explicitfdc) {
@@ -2457,10 +2423,7 @@ qemuBuildFloppyCommandLineControllerOptions(virCommandPtr cmd,
virCommandAddArgBuffer(cmd, &fdc_opts);
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -2922,7 +2885,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_NON_TRANSITIONAL:
if (qemuBuildVirtioDevStr(&buf, "virtio-scsi", qemuCaps,
VIR_DOMAIN_DEVICE_CONTROLLER, def) < 0) {
- goto error;
+ return -1;
}
if (def->iothread) {
@@ -2931,7 +2894,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
}
if (qemuBuildVirtioOptionsStr(&buf, def->virtio, qemuCaps) < 0)
- goto error;
+ return -1;
break;
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC:
virBufferAddLit(&buf, "lsi");
@@ -2951,13 +2914,13 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported controller model: %s"),
virDomainControllerModelSCSITypeToString(def->model));
- goto error;
+ return -1;
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT:
case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected SCSI controller model %d"),
def->model);
- goto error;
+ return -1;
}
virBufferAsprintf(&buf, ",id=%s", def->info.alias);
break;
@@ -2965,7 +2928,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
if (qemuBuildVirtioDevStr(&buf, "virtio-serial", qemuCaps,
VIR_DOMAIN_DEVICE_CONTROLLER, def) < 0) {
- goto error;
+ return -1;
}
virBufferAsprintf(&buf, ",id=%s", def->info.alias);
@@ -2978,7 +2941,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
def->opts.vioserial.vectors);
}
if (qemuBuildVirtioOptionsStr(&buf, def->virtio, qemuCaps) < 0)
- goto error;
+ return -1;
break;
case VIR_DOMAIN_CONTROLLER_TYPE_CCID:
@@ -2991,7 +2954,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
case VIR_DOMAIN_CONTROLLER_TYPE_USB:
if (qemuBuildUSBControllerDevStr(domainDef, def, qemuCaps, &buf) == -1)
- goto error;
+ return -1;
break;
@@ -3003,7 +2966,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
if (def->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT &&
pciopts->modelName ==
VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_SPAPR_PCI_HOST_BRIDGE &&
pciopts->targetIndex == 0) {
- goto done;
+ return 0;
}
if (!modelName) {
@@ -3051,13 +3014,13 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Unsupported PCI Express root controller"));
- goto error;
+ return -1;
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected PCI controller model %d"),
def->model);
- goto error;
+ return -1;
}
break;
}
@@ -3069,7 +3032,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported controller type: %s"),
virDomainControllerTypeToString(def->type));
- goto error;
+ return -1;
}
if (def->queues)
@@ -3084,17 +3047,13 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
qemuBuildIoEventFdStr(&buf, def->ioeventfd, qemuCaps);
if (qemuBuildDeviceAddressStr(&buf, domainDef, &def->info, qemuCaps) <
0)
- goto error;
+ return -1;
- done:
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return -1;
*devstr = virBufferContentAndReset(&buf);
return 0;
-
- error:
- return -1;
}
@@ -3198,7 +3157,6 @@ qemuBuildControllersByTypeCommandLine(virCommandPtr cmd,
virQEMUCapsPtr qemuCaps,
virDomainControllerType type)
{
- int ret = -1;
size_t i;
for (i = 0; i < def->ncontrollers; i++) {
@@ -3237,20 +3195,18 @@ qemuBuildControllersByTypeCommandLine(virCommandPtr cmd,
}
if (qemuBuildControllerDevStr(def, cont, qemuCaps, &devstr) < 0)
- goto cleanup;
+ return -1;
if (devstr) {
if (qemuCommandAddExtDevice(cmd, &cont->info) < 0)
- goto cleanup;
+ return -1;
virCommandAddArg(cmd, "-device");
virCommandAddArg(cmd, devstr);
}
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -3286,20 +3242,16 @@ qemuBuildControllersCommandLine(virCommandPtr cmd,
VIR_DOMAIN_CONTROLLER_TYPE_SATA,
VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL,
};
- int ret = -1;
for (i = 0; i < ARRAY_CARDINALITY(contOrder); i++) {
if (qemuBuildControllersByTypeCommandLine(cmd, def, qemuCaps, contOrder[i]) <
0)
- goto cleanup;
+ return -1;
}
if (qemuBuildLegacyUSBControllerCommandLine(cmd, def) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
@@ -3681,7 +3633,6 @@ qemuBuildMemoryDimmBackendStr(virBufferPtr buf,
{
VIR_AUTOPTR(virJSONValue) props = NULL;
VIR_AUTOFREE(char *) alias = NULL;
- int ret = -1;
if (!mem->info.alias) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -3690,20 +3641,16 @@ qemuBuildMemoryDimmBackendStr(virBufferPtr buf,
}
if (virAsprintf(&alias, "mem%s", mem->info.alias) < 0)
- goto cleanup;
+ return -1;
if (qemuBuildMemoryBackendProps(&props, alias, cfg,
priv, def, mem, true) < 0)
- goto cleanup;
+ return -1;
if (virQEMUBuildObjectCommandlineFromJSON(buf, props) < 0)
- goto cleanup;
-
- ret = 0;
-
- cleanup:
+ return -1;
- return ret;
+ return 0;
}
@@ -4121,20 +4068,17 @@ qemuBuildWatchdogDevStr(const virDomainDef *def,
if (!model) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("missing watchdog model"));
- goto error;
+ return NULL;
}
virBufferAsprintf(&buf, "%s,id=%s", model, dev->info.alias);
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
- goto error;
+ return NULL;
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return NULL;
return virBufferContentAndReset(&buf);
-
- error:
- return NULL;
}
@@ -4194,12 +4138,12 @@ qemuBuildMemballoonCommandLine(virCommandPtr cmd,
if (qemuBuildVirtioDevStr(&buf, "virtio-balloon", qemuCaps,
VIR_DOMAIN_DEVICE_MEMBALLOON,
def->memballoon) < 0) {
- goto error;
+ return -1;
}
virBufferAsprintf(&buf, ",id=%s", def->memballoon->info.alias);
if (qemuBuildDeviceAddressStr(&buf, def, &def->memballoon->info,
qemuCaps) < 0)
- goto error;
+ return -1;
if (def->memballoon->autodeflate != VIR_TRISTATE_SWITCH_ABSENT) {
virBufferAsprintf(&buf, ",deflate-on-oom=%s",
@@ -4207,17 +4151,14 @@ qemuBuildMemballoonCommandLine(virCommandPtr cmd,
}
if (qemuBuildVirtioOptionsStr(&buf, def->memballoon->virtio, qemuCaps) <
0)
- goto error;
+ return -1;
if (qemuCommandAddExtDevice(cmd, &def->memballoon->info) < 0)
- goto error;
+ return -1;
virCommandAddArg(cmd, "-device");
virCommandAddArgBuffer(cmd, &buf);
return 0;
-
- error:
- return -1;
}
@@ -4233,16 +4174,13 @@ qemuBuildNVRAMDevStr(virDomainNVRAMDefPtr dev)
} else {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("nvram address type must be spaprvio"));
- goto error;
+ return NULL;
}
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return NULL;
return virBufferContentAndReset(&buf);
-
- error:
- return NULL;
}
@@ -4289,31 +4227,31 @@ qemuBuildVirtioInputDevStr(const virDomainDef *def,
case VIR_DOMAIN_INPUT_TYPE_MOUSE:
if (qemuBuildVirtioDevStr(&buf, "virtio-mouse", qemuCaps,
VIR_DOMAIN_DEVICE_INPUT, dev) < 0) {
- goto error;
+ return NULL;
}
break;
case VIR_DOMAIN_INPUT_TYPE_TABLET:
if (qemuBuildVirtioDevStr(&buf, "virtio-tablet", qemuCaps,
VIR_DOMAIN_DEVICE_INPUT, dev) < 0) {
- goto error;
+ return NULL;
}
break;
case VIR_DOMAIN_INPUT_TYPE_KBD:
if (qemuBuildVirtioDevStr(&buf, "virtio-keyboard", qemuCaps,
VIR_DOMAIN_DEVICE_INPUT, dev) < 0) {
- goto error;
+ return NULL;
}
break;
case VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH:
if (qemuBuildVirtioDevStr(&buf, "virtio-input-host", qemuCaps,
VIR_DOMAIN_DEVICE_INPUT, dev) < 0) {
- goto error;
+ return NULL;
}
break;
case VIR_DOMAIN_INPUT_TYPE_LAST:
default:
virReportEnumRangeError(virDomainInputType, dev->type);
- goto error;
+ return NULL;
}
virBufferAsprintf(&buf, ",id=%s", dev->info.alias);
@@ -4324,18 +4262,15 @@ qemuBuildVirtioInputDevStr(const virDomainDef *def,
}
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
- goto error;
+ return NULL;
if (qemuBuildVirtioOptionsStr(&buf, dev->virtio, qemuCaps) < 0)
- goto error;
+ return NULL;
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return NULL;
return virBufferContentAndReset(&buf);
-
- error:
- return NULL;
}
static char *
@@ -4357,22 +4292,19 @@ qemuBuildUSBInputDevStr(const virDomainDef *def,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("usb keyboard is not supported by this "
"QEMU binary"));
- goto error;
+ return NULL;
}
virBufferAsprintf(&buf, "usb-kbd,id=%s", dev->info.alias);
break;
}
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
- goto error;
+ return NULL;
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return NULL;
return virBufferContentAndReset(&buf);
-
- error:
- return NULL;
}
@@ -4449,7 +4381,7 @@ qemuBuildSoundDevStr(const virDomainDef *def,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("usb-audio controller is not supported "
"by this QEMU binary"));
- goto error;
+ return NULL;
}
break;
case VIR_DOMAIN_SOUND_MODEL_ICH9:
@@ -4458,7 +4390,7 @@ qemuBuildSoundDevStr(const virDomainDef *def,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("The ich9-intel-hda audio controller "
"is not supported in this QEMU binary"));
- goto error;
+ return NULL;
}
break;
case VIR_DOMAIN_SOUND_MODEL_SB16:
@@ -4469,20 +4401,17 @@ qemuBuildSoundDevStr(const virDomainDef *def,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("sound card model '%s' is not supported by
qemu"),
virDomainSoundModelTypeToString(sound->model));
- goto error;
+ return NULL;
}
virBufferAsprintf(&buf, "%s,id=%s", model, sound->info.alias);
if (qemuBuildDeviceAddressStr(&buf, def, &sound->info, qemuCaps) < 0)
- goto error;
+ return NULL;
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return NULL;
return virBufferContentAndReset(&buf);
-
- error:
- return NULL;
}
@@ -4518,16 +4447,13 @@ qemuBuildSoundCodecStr(virDomainSoundDefPtr sound,
if (flags == -1 || !virQEMUCapsGet(qemuCaps, flags)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("%s not supported in this QEMU binary"), stype);
- goto error;
+ return NULL;
}
virBufferAsprintf(&buf, "%s,id=%s-codec%d,bus=%s.0,cad=%d",
stype, sound->info.alias, codec->cad, sound->info.alias,
codec->cad);
return virBufferContentAndReset(&buf);
-
- error:
- return NULL;
}
@@ -4615,13 +4541,13 @@ qemuBuildDeviceVideoStr(const virDomainDef *def,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("invalid model for video type '%s'"),
virDomainVideoTypeToString(video->type));
- goto error;
+ return NULL;
}
if (STREQ(model, "virtio-gpu")) {
if (qemuBuildVirtioDevStr(&buf, "virtio-gpu", qemuCaps,
VIR_DOMAIN_DEVICE_VIDEO, video) < 0) {
- goto error;
+ return NULL;
}
} else {
virBufferAsprintf(&buf, "%s", model);
@@ -4676,18 +4602,15 @@ qemuBuildDeviceVideoStr(const virDomainDef *def,
}
if (qemuBuildDeviceAddressStr(&buf, def, &video->info, qemuCaps) < 0)
- goto error;
+ return NULL;
if (qemuBuildVirtioOptionsStr(&buf, video->virtio, qemuCaps) < 0)
- goto error;
+ return NULL;
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return NULL;
return virBufferContentAndReset(&buf);
-
- error:
- return NULL;
}
@@ -4870,7 +4793,7 @@ qemuBuildPCIHostdevDevStr(const virDomainDef *def,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("invalid PCI passthrough type '%s'"),
virDomainHostdevSubsysPCIBackendTypeToString(backend));
- goto error;
+ return NULL;
}
virBufferAddLit(&buf, ",host=");
@@ -4886,17 +4809,14 @@ qemuBuildPCIHostdevDevStr(const virDomainDef *def,
if (bootIndex)
virBufferAsprintf(&buf, ",bootindex=%u", bootIndex);
if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0)
- goto error;
+ return NULL;
if (qemuBuildRomStr(&buf, dev->info) < 0)
- goto error;
+ return NULL;
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return NULL;
return virBufferContentAndReset(&buf);
-
- error:
- return NULL;
}
@@ -4924,15 +4844,12 @@ qemuBuildUSBHostdevDevStr(const virDomainDef *def,
virBufferAsprintf(&buf, ",bootindex=%u",
dev->info->bootIndex);
if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0)
- goto error;
+ return NULL;
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return NULL;
return virBufferContentAndReset(&buf);
-
- error:
- return NULL;
}
@@ -4947,27 +4864,24 @@ qemuBuildHubDevStr(const virDomainDef *def,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("hub type %s not supported"),
virDomainHubTypeToString(dev->type));
- goto error;
+ return NULL;
}
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_USB_HUB)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("usb-hub not supported by QEMU binary"));
- goto error;
+ return NULL;
}
virBufferAddLit(&buf, "usb-hub");
virBufferAsprintf(&buf, ",id=%s", dev->info.alias);
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
- goto error;
+ return NULL;
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return NULL;
return virBufferContentAndReset(&buf);
-
- error:
- return NULL;
}
@@ -5009,7 +4923,6 @@ static char *
qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
virQEMUCapsPtr qemuCaps)
{
- char *ret = NULL;
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
VIR_AUTOFREE(char *) netsource = NULL;
VIR_AUTOPTR(virJSONValue) srcprops = NULL;
@@ -5020,27 +4933,24 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
if (qemuDiskSourceNeedsProps(iscsisrc->src, qemuCaps)) {
if (!(srcprops = qemuDiskSourceGetProps(iscsisrc->src)))
- goto cleanup;
+ return NULL;
if (!(netsource = virQEMUBuildDriveCommandlineFromJSON(srcprops)))
- goto cleanup;
+ return NULL;
virBufferAsprintf(&buf, "%s,if=none,format=raw", netsource);
} else {
/* Rather than pull what we think we want - use the network disk code */
if (!(netsource = qemuBuildNetworkDriveStr(iscsisrc->src, srcPriv ?
srcPriv->secinfo : NULL)))
- goto cleanup;
+ return NULL;
virBufferAddLit(&buf, "file=");
virQEMUBuildBufferEscapeComma(&buf, netsource);
virBufferAddLit(&buf, ",if=none,format=raw");
}
if (virBufferCheckError(&buf) < 0)
- goto cleanup;
-
- ret = virBufferContentAndReset(&buf);
+ return NULL;
- cleanup:
- return ret;
+ return virBufferContentAndReset(&buf);
}
char *
@@ -5055,12 +4965,12 @@ qemuBuildSCSIVHostHostdevDevStr(const virDomainDef *def,
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VHOST_SCSI)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("This QEMU doesn't support vhost-scsi devices"));
- goto cleanup;
+ return NULL;
}
if (qemuBuildVirtioDevStr(&buf, "vhost-scsi", qemuCaps,
VIR_DOMAIN_DEVICE_HOSTDEV, dev) < 0) {
- goto cleanup;
+ return NULL;
}
virBufferAsprintf(&buf, ",wwpn=%s,vhostfd=%s,id=%s",
@@ -5069,15 +4979,12 @@ qemuBuildSCSIVHostHostdevDevStr(const virDomainDef *def,
dev->info->alias);
if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0)
- goto cleanup;
+ return NULL;
if (virBufferCheckError(&buf) < 0)
- goto cleanup;
+ return NULL;
return virBufferContentAndReset(&buf);
-
- cleanup:
- return NULL;
}
char *
@@ -5091,27 +4998,25 @@ qemuBuildSCSIHostdevDrvStr(virDomainHostdevDefPtr dev,
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
if (!(source = qemuBuildSCSIiSCSIHostdevDrvStr(dev, qemuCaps)))
- goto error;
+ return NULL;
virBufferAdd(&buf, source, -1);
} else {
if (!(source = qemuBuildSCSIHostHostdevDrvStr(dev)))
- goto error;
+ return NULL;
virBufferAsprintf(&buf, "file=/dev/%s,if=none,format=raw",
source);
}
if (!(drivealias = qemuAliasFromHostdev(dev)))
- goto error;
+ return NULL;
virBufferAsprintf(&buf, ",id=%s", drivealias);
if (dev->readonly)
virBufferAddLit(&buf, ",readonly=on");
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return NULL;
return virBufferContentAndReset(&buf);
- error:
- return NULL;
}
char *
@@ -5125,21 +5030,21 @@ qemuBuildSCSIHostdevDevStr(const virDomainDef *def,
model = qemuDomainFindSCSIControllerModel(def, dev->info);
if (model < 0)
- goto error;
+ return NULL;
if (model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC) {
if (dev->info->addr.drive.target != 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("target must be 0 for scsi host device "
"if its controller model is
'lsilogic'"));
- goto error;
+ return NULL;
}
if (dev->info->addr.drive.unit > 7) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("unit must be not more than 7 for scsi host "
"device if its controller model is
'lsilogic'"));
- goto error;
+ return NULL;
}
}
@@ -5147,7 +5052,7 @@ qemuBuildSCSIHostdevDevStr(const virDomainDef *def,
if (!(contAlias = virDomainControllerAliasFind(def, VIR_DOMAIN_CONTROLLER_TYPE_SCSI,
dev->info->addr.drive.controller)))
- goto error;
+ return NULL;
if (model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC) {
virBufferAsprintf(&buf, ",bus=%s.%d,scsi-id=%d",
@@ -5163,18 +5068,16 @@ qemuBuildSCSIHostdevDevStr(const virDomainDef *def,
}
if (!(driveAlias = qemuAliasFromHostdev(dev)))
- goto error;
+ return NULL;
virBufferAsprintf(&buf, ",drive=%s,id=%s", driveAlias,
dev->info->alias);
if (dev->info->bootIndex)
virBufferAsprintf(&buf, ",bootindex=%u",
dev->info->bootIndex);
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return NULL;
return virBufferContentAndReset(&buf);
- error:
- return NULL;
}
static int
@@ -5320,10 +5223,9 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
bool telnet;
VIR_AUTOFREE(char *) charAlias = NULL;
- char *ret = NULL;
if (!(charAlias = qemuAliasChardevFromDevAlias(alias)))
- goto cleanup;
+ return NULL;
switch (dev->type) {
case VIR_DOMAIN_CHR_TYPE_NULL:
@@ -5352,14 +5254,14 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FILE_APPEND)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("append not supported in this QEMU binary"));
- goto cleanup;
+ return NULL;
}
if (qemuBuildChrChardevFileStr(flags & QEMU_BUILD_CHARDEV_FILE_LOGD ?
logManager : NULL,
cmd, def, &buf,
"path", dev->data.file.path,
"append", dev->data.file.append) <
0)
- goto cleanup;
+ return NULL;
break;
case VIR_DOMAIN_CHR_TYPE_PIPE:
@@ -5420,20 +5322,20 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
if (chrSourcePriv && chrSourcePriv->secinfo) {
if (qemuBuildObjectSecretCommandLine(cmd,
chrSourcePriv->secinfo) < 0)
- goto cleanup;
+ return NULL;
tlsCertEncSecAlias = chrSourcePriv->secinfo->s.aes.alias;
}
if (!(objalias = qemuAliasTLSObjFromSrcAlias(charAlias)))
- goto cleanup;
+ return NULL;
if (qemuBuildTLSx509CommandLine(cmd, cfg->chardevTLSx509certdir,
dev->data.tcp.listen,
cfg->chardevTLSx509verify,
tlsCertEncSecAlias,
objalias, qemuCaps) < 0) {
- goto cleanup;
+ return NULL;
}
virBufferAsprintf(&buf, ",tls-creds=%s", objalias);
@@ -5446,14 +5348,14 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
(flags & QEMU_BUILD_CHARDEV_UNIX_FD_PASS) &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_FD_PASS)) {
if (qemuSecuritySetSocketLabel(secManager, (virDomainDefPtr)def) < 0)
- goto cleanup;
+ return NULL;
int fd = qemuOpenChrChardevUNIXSocket(dev);
if (qemuSecurityClearSocketLabel(secManager, (virDomainDefPtr)def) < 0) {
VIR_FORCE_CLOSE(fd);
- goto cleanup;
+ return NULL;
}
if (fd < 0)
- goto cleanup;
+ return NULL;
virBufferAsprintf(&buf, ",fd=%d", fd);
@@ -5485,27 +5387,25 @@ qemuBuildChrChardevStr(virLogManagerPtr logManager,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported chardev '%s'"),
virDomainChrTypeToString(dev->type));
- goto cleanup;
+ return NULL;
}
if (dev->logfile) {
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV_LOGFILE)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("logfile not supported in this QEMU binary"));
- goto cleanup;
+ return NULL;
}
if (qemuBuildChrChardevFileStr(logManager, cmd, def, &buf,
"logfile", dev->logfile,
"logappend", dev->logappend) < 0)
- goto cleanup;
+ return NULL;
}
if (virBufferCheckError(&buf) < 0)
- goto cleanup;
+ return NULL;
- ret = virBufferContentAndReset(&buf);
- cleanup:
- return ret;
+ return virBufferContentAndReset(&buf);
}
char *
@@ -5515,17 +5415,16 @@ qemuBuildHostdevMediatedDevStr(const virDomainDef *def,
{
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
virDomainHostdevSubsysMediatedDevPtr mdevsrc = &dev->source.subsys.u.mdev;
- char *ret = NULL;
VIR_AUTOFREE(char *) mdevPath = NULL;
const char *dev_str = NULL;
if (!(mdevPath = virMediatedDeviceGetSysfsPath(mdevsrc->uuidstr)))
- goto cleanup;
+ return NULL;
dev_str = virMediatedDeviceModelTypeToString(mdevsrc->model);
if (!dev_str)
- goto cleanup;
+ return NULL;
virBufferAdd(&buf, dev_str, -1);
virBufferAsprintf(&buf, ",id=%s,sysfsdev=%s", dev->info->alias,
mdevPath);
@@ -5535,15 +5434,12 @@ qemuBuildHostdevMediatedDevStr(const virDomainDef *def,
virTristateSwitchTypeToString(mdevsrc->display));
if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0)
- goto cleanup;
+ return NULL;
if (virBufferCheckError(&buf) < 0)
- goto cleanup;
-
- ret = virBufferContentAndReset(&buf);
+ return NULL;
- cleanup:
- return ret;
+ return virBufferContentAndReset(&buf);
}
static int
@@ -5798,13 +5694,13 @@ qemuBuildVirtioSerialPortDevStr(const virDomainDef *def,
if (dev->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("virtio serial device has invalid
address type"));
- goto error;
+ return NULL;
}
contAlias = virDomainControllerAliasFind(def,
VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL,
dev->info.addr.vioserial.controller);
if (!contAlias)
- goto error;
+ return NULL;
virBufferAsprintf(&buf, ",bus=%s.%d,nr=%d", contAlias,
dev->info.addr.vioserial.bus,
@@ -5818,7 +5714,7 @@ qemuBuildVirtioSerialPortDevStr(const virDomainDef *def,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Unsupported spicevmc target name '%s'"),
dev->target.name);
- goto error;
+ return NULL;
}
virBufferAsprintf(&buf, ",chardev=char%s,id=%s",
@@ -5830,12 +5726,9 @@ qemuBuildVirtioSerialPortDevStr(const virDomainDef *def,
? dev->target.name : "com.redhat.spice.0");
}
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return NULL;
return virBufferContentAndReset(&buf);
-
- error:
- return NULL;
}
static char *
@@ -5854,17 +5747,14 @@ qemuBuildSclpDevStr(virDomainChrDefPtr dev)
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Cannot use slcp with devices other than console"));
- goto error;
+ return NULL;
}
virBufferAsprintf(&buf, ",chardev=char%s,id=%s",
dev->info.alias, dev->info.alias);
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return NULL;
return virBufferContentAndReset(&buf);
-
- error:
- return NULL;
}
@@ -5913,10 +5803,9 @@ qemuBuildRNGBackendProps(virDomainRNGDefPtr rng,
{
VIR_AUTOFREE(char *) objAlias = NULL;
VIR_AUTOFREE(char *) charBackendAlias = NULL;
- int ret = -1;
if (virAsprintf(&objAlias, "obj%s", rng->info.alias) < 0)
- goto cleanup;
+ return -1;
switch ((virDomainRNGBackend) rng->backend) {
case VIR_DOMAIN_RNG_BACKEND_RANDOM:
@@ -5924,13 +5813,13 @@ qemuBuildRNGBackendProps(virDomainRNGDefPtr rng,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("this qemu doesn't support the rng-random "
"backend"));
- goto cleanup;
+ return -1;
}
if (qemuMonitorCreateObjectProps(props, "rng-random", objAlias,
"s:filename", rng->source.file,
NULL) < 0)
- goto cleanup;
+ return -1;
break;
@@ -5939,29 +5828,26 @@ qemuBuildRNGBackendProps(virDomainRNGDefPtr rng,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("this qemu doesn't support the rng-egd "
"backend"));
- goto cleanup;
+ return -1;
}
if (!(charBackendAlias = qemuAliasChardevFromDevAlias(rng->info.alias)))
- goto cleanup;
+ return -1;
if (qemuMonitorCreateObjectProps(props, "rng-egd", objAlias,
"s:chardev", charBackendAlias,
NULL) < 0)
- goto cleanup;
+ return -1;
break;
case VIR_DOMAIN_RNG_BACKEND_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("unknown rng-random backend"));
- goto cleanup;
+ return -1;
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -5974,11 +5860,11 @@ qemuBuildRNGDevStr(const virDomainDef *def,
if (!qemuDomainCheckCCWS390AddressSupport(def, &dev->info, qemuCaps,
dev->source.file))
- goto error;
+ return NULL;
if (qemuBuildVirtioDevStr(&buf, "virtio-rng", qemuCaps,
VIR_DOMAIN_DEVICE_RNG, dev) < 0) {
- goto error;
+ return NULL;
}
virBufferAsprintf(&buf, ",rng=obj%s,id=%s",
@@ -5993,17 +5879,14 @@ qemuBuildRNGDevStr(const virDomainDef *def,
}
if (qemuBuildVirtioOptionsStr(&buf, dev->virtio, qemuCaps) < 0)
- goto error;
+ return NULL;
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
- goto error;
+ return NULL;
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return NULL;
return virBufferContentAndReset(&buf);
-
- error:
- return NULL;
}
@@ -6194,12 +6077,9 @@ qemuBuildSmbiosBaseBoardStr(virSysinfoBaseBoardDefPtr def)
}
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return NULL;
return virBufferContentAndReset(&buf);
-
- error:
- return NULL;
}
@@ -6258,12 +6138,9 @@ qemuBuildSmbiosChassisStr(virSysinfoChassisDefPtr def)
}
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return NULL;
return virBufferContentAndReset(&buf);
-
- error:
- return NULL;
}
@@ -6437,7 +6314,7 @@ qemuBuildClockArgStr(virDomainClockDefPtr def)
* startup).
*/
if (virTimeLocalOffsetFromUTC(&localOffset) < 0)
- goto error;
+ return NULL;
def->data.variable.adjustment += localOffset;
def->data.variable.basis = VIR_DOMAIN_CLOCK_BASIS_UTC;
}
@@ -6466,7 +6343,7 @@ qemuBuildClockArgStr(virDomainClockDefPtr def)
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported clock offset '%s'"),
virDomainClockOffsetTypeToString(def->offset));
- goto error;
+ return NULL;
}
/* Look for an 'rtc' timer element, and add in appropriate
@@ -6480,7 +6357,7 @@ qemuBuildClockArgStr(virDomainClockDefPtr def)
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported rtc timer track '%s'"),
virDomainTimerTrackTypeToString(def->timers[i]->track));
- goto error;
+ return NULL;
case VIR_DOMAIN_TIMER_TRACK_GUEST:
virBufferAddLit(&buf, ",clock=vm");
break;
@@ -6504,19 +6381,16 @@ qemuBuildClockArgStr(virDomainClockDefPtr def)
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported rtc timer tickpolicy
'%s'"),
virDomainTimerTickpolicyTypeToString(def->timers[i]->tickpolicy));
- goto error;
+ return NULL;
}
break; /* no need to check other timers - there is only one rtc */
}
}
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return NULL;
return virBufferContentAndReset(&buf);
-
- error:
- return NULL;
}
@@ -6704,7 +6578,7 @@ qemuBuildBootCommandLine(virCommandPtr cmd,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("reboot timeout is not supported "
"by this QEMU binary"));
- goto error;
+ return -1;
}
virBufferAsprintf(&boot_buf,
@@ -6717,7 +6591,7 @@ qemuBuildBootCommandLine(virCommandPtr cmd,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("splash timeout is not supported "
"by this QEMU binary"));
- goto error;
+ return -1;
}
virBufferAsprintf(&boot_buf, "splash-time=%u,",
def->os.bm_timeout);
@@ -6729,7 +6603,7 @@ qemuBuildBootCommandLine(virCommandPtr cmd,
virBufferTrim(&boot_buf, ",", -1);
if (virBufferCheckError(&boot_buf) < 0)
- goto error;
+ return -1;
boot_opts_str = virBufferContentAndReset(&boot_buf);
if (boot_opts_str) {
@@ -6755,9 +6629,6 @@ qemuBuildBootCommandLine(virCommandPtr cmd,
}
return 0;
-
- error:
- return -1;
}
@@ -6898,13 +6769,12 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
virBufferPtr buf,
virQEMUCapsPtr qemuCaps)
{
- int ret = -1;
size_t i;
VIR_AUTOUNREF(virCapsPtr) caps = NULL;
virCPUDefPtr cpu = def->cpu;
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
- goto cleanup;
+ return -1;
switch ((virCPUMode) cpu->mode) {
case VIR_CPU_MODE_HOST_PASSTHROUGH:
@@ -6917,7 +6787,7 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
_("QEMU binary does not support CPU "
"host-passthrough for armv7l on "
"aarch64 host"));
- goto cleanup;
+ return -1;
}
virBufferAddLit(buf, ",aarch64=off");
}
@@ -6935,7 +6805,7 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected host-model CPU for %s architecture"),
virArchToString(def->os.arch));
- goto cleanup;
+ return -1;
}
break;
@@ -6952,7 +6822,7 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("CPU features not supported by hypervisor for %s "
"architecture"), virArchToString(def->os.arch));
- goto cleanup;
+ return -1;
}
if (cpu->vendor_id)
@@ -6976,9 +6846,7 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
}
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
static int
@@ -6990,7 +6858,6 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
virArch hostarch = virArchFromHost();
VIR_AUTOFREE(char *) cpu = NULL;
VIR_AUTOFREE(char *) cpu_flags = NULL;
- int ret = -1;
VIR_AUTOCLEAN(virBuffer) cpu_buf = VIR_BUFFER_INITIALIZER;
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
size_t i;
@@ -6998,7 +6865,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
if (def->cpu &&
(def->cpu->mode != VIR_CPU_MODE_CUSTOM || def->cpu->model)) {
if (qemuBuildCpuModelArgStr(driver, def, &cpu_buf, qemuCaps) < 0)
- goto cleanup;
+ return -1;
} else {
/*
* Need to force a 32-bit guest CPU type if
@@ -7164,9 +7031,9 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
}
if (virBufferCheckError(&cpu_buf) < 0)
- goto cleanup;
+ return -1;
if (virBufferCheckError(&buf) < 0)
- goto cleanup;
+ return -1;
cpu = virBufferContentAndReset(&cpu_buf);
cpu_flags = virBufferContentAndReset(&buf);
@@ -7186,11 +7053,11 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
_("CPU flags requested but can't determine "
"default CPU for arch %s"),
virArchToString(def->os.arch));
- goto cleanup;
+ return -1;
}
if (VIR_STRDUP(cpu, default_model) < 0)
- goto cleanup;
+ return -1;
}
if (cpu) {
@@ -7198,10 +7065,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
virCommandAddArgFormat(cmd, "%s%s", cpu, NULLSTR_EMPTY(cpu_flags));
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -7304,7 +7168,6 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
virCPUDefPtr cpu = def->cpu;
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
size_t i;
- int ret = -1;
/* This should *never* be NULL, since we always provide
* a machine in the capabilities data for QEMU. So this
@@ -7360,7 +7223,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("vmport is not available "
"with this QEMU binary"));
- goto cleanup;
+ return -1;
}
virBufferAsprintf(&buf, ",vmport=%s",
@@ -7383,7 +7246,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("disable shared memory is not available "
"with this QEMU binary"));
- goto cleanup;
+ return -1;
}
virBufferAddLit(&buf, ",mem-merge=off");
@@ -7391,7 +7254,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
if (def->keywrap &&
!qemuAppendKeyWrapMachineParms(&buf, qemuCaps, def->keywrap))
- goto cleanup;
+ return -1;
if (def->features[VIR_DOMAIN_FEATURE_GIC] == VIR_TRISTATE_SWITCH_ON) {
bool hasGICVersionOption = virQEMUCapsGet(qemuCaps,
@@ -7416,7 +7279,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("gic-version option is not available "
"with this QEMU binary"));
- goto cleanup;
+ return -1;
}
virBufferAsprintf(&buf, ",gic-version=%s",
@@ -7457,7 +7320,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_NVDIMM)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("nvdimm isn't supported by this QEMU
binary"));
- goto cleanup;
+ return -1;
}
virBufferAddLit(&buf, ",nvdimm=on");
break;
@@ -7469,7 +7332,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("I/O APIC tuning is not supported by this "
"QEMU binary"));
- goto cleanup;
+ return -1;
}
switch ((virDomainIOAPIC) def->features[VIR_DOMAIN_FEATURE_IOAPIC]) {
case VIR_DOMAIN_IOAPIC_QEMU:
@@ -7477,7 +7340,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("split I/O APIC is not supported by this "
"QEMU binary"));
- goto cleanup;
+ return -1;
}
virBufferAddLit(&buf, ",kernel_irqchip=split");
break;
@@ -7499,14 +7362,14 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("HTP resizing is not supported by this "
"QEMU binary"));
- goto cleanup;
+ return -1;
}
str = virDomainHPTResizingTypeToString(def->hpt_resizing);
if (!str) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Invalid setting for HPT resizing"));
- goto cleanup;
+ return -1;
}
virBufferAsprintf(&buf, ",resize-hpt=%s", str);
@@ -7517,7 +7380,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Configuring the page size for HPT guests "
"is not supported by this QEMU binary"));
- goto cleanup;
+ return -1;
}
virBufferAsprintf(&buf, ",cap-hpt-max-page-size=%lluk",
@@ -7532,14 +7395,14 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("HTM configuration is not supported by this "
"QEMU binary"));
- goto cleanup;
+ return -1;
}
str = virTristateSwitchTypeToString(def->features[VIR_DOMAIN_FEATURE_HTM]);
if (!str) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Invalid setting for HTM state"));
- goto cleanup;
+ return -1;
}
virBufferAsprintf(&buf, ",cap-htm=%s", str);
@@ -7552,14 +7415,14 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Nested HV configuration is not supported by "
"this QEMU binary"));
- goto cleanup;
+ return -1;
}
str =
virTristateSwitchTypeToString(def->features[VIR_DOMAIN_FEATURE_NESTED_HV]);
if (!str) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Invalid setting for nested HV state"));
- goto cleanup;
+ return -1;
}
virBufferAsprintf(&buf, ",cap-nested-hv=%s", str);
@@ -7580,9 +7443,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
virCommandAddArgBuffer(cmd, &buf);
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -7956,7 +7817,6 @@ qemuBuildGraphicsSDLCommandLine(virQEMUDriverConfigPtr cfg
ATTRIBUTE_UNUSED,
virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED,
virDomainGraphicsDefPtr graphics)
{
- int ret = -1;
VIR_AUTOCLEAN(virBuffer) opt = VIR_BUFFER_INITIALIZER;
if (graphics->data.sdl.xauth)
@@ -7981,7 +7841,7 @@ qemuBuildGraphicsSDLCommandLine(virQEMUDriverConfigPtr cfg
ATTRIBUTE_UNUSED,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("OpenGL for SDL is not supported with this QEMU "
"binary"));
- goto cleanup;
+ return -1;
}
virBufferAsprintf(&opt, ",gl=%s",
@@ -7990,13 +7850,11 @@ qemuBuildGraphicsSDLCommandLine(virQEMUDriverConfigPtr cfg
ATTRIBUTE_UNUSED,
}
if (virBufferCheckError(&opt) < 0)
- goto cleanup;
+ return -1;
virCommandAddArgBuffer(cmd, &opt);
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -8013,13 +7871,13 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VNC)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("vnc graphics are not supported with this QEMU"));
- goto error;
+ return -1;
}
if (!(glisten = virDomainGraphicsGetListen(graphics, 0))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing listen element"));
- goto error;
+ return -1;
}
switch (glisten->type) {
@@ -8038,7 +7896,7 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
graphics->data.vnc.port > 65535)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("vnc port must be in range [5900,65535]"));
- goto error;
+ return -1;
}
if (glisten->address) {
@@ -8080,7 +7938,7 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
if (gfxPriv->secinfo) {
if (qemuBuildObjectSecretCommandLine(cmd,
gfxPriv->secinfo) < 0)
- goto error;
+ return -1;
secretAlias = gfxPriv->secinfo->s.aes.alias;
}
@@ -8091,7 +7949,7 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
secretAlias,
gfxPriv->tlsAlias,
qemuCaps) < 0)
- goto error;
+ return -1;
virBufferAsprintf(&opt, ",tls-creds=%s",
gfxPriv->tlsAlias);
} else {
@@ -8130,9 +7988,6 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
virCommandAddEnvString(cmd, "QEMU_AUDIO_DRV=none");
return 0;
-
- error:
- return -1;
}
@@ -8153,13 +8008,13 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("spice graphics are not supported with this QEMU"));
- goto error;
+ return -1;
}
if (!(glisten = virDomainGraphicsGetListen(graphics, 0))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing listen element"));
- goto error;
+ return -1;
}
switch (glisten->type) {
@@ -8168,7 +8023,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("unix socket for spice graphics are not supported
"
"with this QEMU"));
- goto error;
+ return -1;
}
virBufferAddLit(&opt, "unix,addr=");
@@ -8189,7 +8044,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("spice TLS port set in XML configuration, "
"but TLS is disabled in qemu.conf"));
- goto error;
+ return -1;
}
virBufferAsprintf(&opt, "tls-port=%u,", tlsPort);
hasSecure = true;
@@ -8236,7 +8091,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
default:
virReportEnumRangeError(virDomainGraphicsSpiceMouseMode,
graphics->data.spice.mousemode);
- goto error;
+ return -1;
}
}
@@ -8260,7 +8115,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
_("spice defaultMode secure requested in XML "
"configuration, but TLS connection is not "
"available"));
- goto error;
+ return -1;
}
virBufferAddLit(&opt, "tls-channel=default,");
break;
@@ -8270,7 +8125,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
_("spice defaultMode insecure requested in XML "
"configuration, but plaintext connection is not "
"available"));
- goto error;
+ return -1;
}
virBufferAddLit(&opt, "plaintext-channel=default,");
break;
@@ -8288,7 +8143,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
_("spice secure channels set in XML "
"configuration, but TLS connection is not "
"available"));
- goto error;
+ return -1;
}
virBufferAsprintf(&opt, "tls-channel=%s,",
virDomainGraphicsSpiceChannelNameTypeToString(i));
@@ -8300,7 +8155,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
_("spice insecure channels set in XML "
"configuration, but plaintext connection "
"is not available"));
- goto error;
+ return -1;
}
virBufferAsprintf(&opt, "plaintext-channel=%s,",
virDomainGraphicsSpiceChannelNameTypeToString(i));
@@ -8333,7 +8188,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE_FILE_XFER_DISABLE)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("This QEMU can't disable file transfers through
spice"));
- goto error;
+ return -1;
} else {
virBufferAddLit(&opt, "disable-agent-file-xfer,");
}
@@ -8343,7 +8198,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE_GL)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("This QEMU doesn't support spice OpenGL"));
- goto error;
+ return -1;
}
/* spice.gl is a TristateBool, but qemu expects on/off: use
@@ -8355,7 +8210,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE_RENDERNODE)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("This QEMU doesn't support spice OpenGL
rendernode"));
- goto error;
+ return -1;
}
virBufferAddLit(&opt, "rendernode=");
@@ -8381,9 +8236,6 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
virCommandAddEnvString(cmd, "QEMU_AUDIO_DRV=spice");
return 0;
-
- error:
- return -1;
}
@@ -8393,7 +8245,6 @@ qemuBuildGraphicsEGLHeadlessCommandLine(virQEMUDriverConfigPtr cfg
ATTRIBUTE_UNU
virQEMUCapsPtr qemuCaps,
virDomainGraphicsDefPtr graphics)
{
- int ret = -1;
VIR_AUTOCLEAN(virBuffer) opt = VIR_BUFFER_INITIALIZER;
virBufferAddLit(&opt, "egl-headless");
@@ -8403,7 +8254,7 @@ qemuBuildGraphicsEGLHeadlessCommandLine(virQEMUDriverConfigPtr cfg
ATTRIBUTE_UNU
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("This QEMU doesn't support OpenGL rendernode
"
"with egl-headless graphics type"));
- goto cleanup;
+ return -1;
}
virBufferAddLit(&opt, ",rendernode=");
@@ -8412,14 +8263,12 @@ qemuBuildGraphicsEGLHeadlessCommandLine(virQEMUDriverConfigPtr cfg
ATTRIBUTE_UNU
}
if (virBufferCheckError(&opt) < 0)
- goto cleanup;
+ return -1;
virCommandAddArg(cmd, "-display");
virCommandAddArgBuffer(cmd, &opt);
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -8486,7 +8335,6 @@ qemuInterfaceVhostuserConnect(virQEMUDriverPtr driver,
char **chardev)
{
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
- int ret = -1;
switch ((virDomainChrType)net->data.vhostuser->type) {
case VIR_DOMAIN_CHR_TYPE_UNIX:
@@ -8494,7 +8342,7 @@ qemuInterfaceVhostuserConnect(virQEMUDriverPtr driver,
cmd, cfg, def,
net->data.vhostuser,
net->info.alias, qemuCaps, 0)))
- goto cleanup;
+ return -1;
break;
case VIR_DOMAIN_CHR_TYPE_NULL:
@@ -8513,12 +8361,10 @@ qemuInterfaceVhostuserConnect(virQEMUDriverPtr driver,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("vhost-user type '%s' not supported"),
virDomainChrTypeToString(net->data.vhostuser->type));
- goto cleanup;
+ return -1;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
static int
@@ -9104,15 +8950,12 @@ qemuBuildShmemDevLegacyStr(virDomainDefPtr def,
}
if (qemuBuildDeviceAddressStr(&buf, def, &shmem->info, qemuCaps) < 0)
- goto error;
+ return NULL;
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return NULL;
return virBufferContentAndReset(&buf);
-
- error:
- return NULL;
}
char *
@@ -9169,7 +9012,7 @@ qemuBuildShmemBackendMemProps(virDomainShmemDefPtr shmem)
return NULL;
if (virAsprintf(&mem_alias, "shmmem-%s", shmem->info.alias) < 0)
- goto cleanup;
+ return NULL;
qemuMonitorCreateObjectProps(&ret, "memory-backend-file", mem_alias,
"s:mem-path", mem_path,
@@ -9177,7 +9020,6 @@ qemuBuildShmemBackendMemProps(virDomainShmemDefPtr shmem)
"b:share", true,
NULL);
- cleanup:
return ret;
}
@@ -9625,14 +9467,14 @@ qemuBuildRedirdevDevStr(const virDomainDef *def,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Redirection bus %s is not supported by QEMU"),
virDomainRedirdevBusTypeToString(dev->bus));
- goto error;
+ return NULL;
}
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_USB_REDIR)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("USB redirection is not supported "
"by this version of QEMU"));
- goto error;
+ return NULL;
}
virBufferAsprintf(&buf, "usb-redir,chardev=char%s,id=%s",
@@ -9643,7 +9485,7 @@ qemuBuildRedirdevDevStr(const virDomainDef *def,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("USB redirection filter is not "
"supported by this version of QEMU"));
- goto error;
+ return NULL;
}
virBufferAddLit(&buf, ",filter=");
@@ -9680,15 +9522,12 @@ qemuBuildRedirdevDevStr(const virDomainDef *def,
virBufferAsprintf(&buf, ",bootindex=%u", dev->info.bootIndex);
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
- goto error;
+ return NULL;
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return NULL;
return virBufferContentAndReset(&buf);
-
- error:
- return NULL;
}
@@ -9811,7 +9650,7 @@ qemuBuildTPMDevStr(const virDomainDef *def,
case VIR_DOMAIN_TPM_MODEL_LAST:
default:
virReportEnumRangeError(virDomainTPMModel, tpm->model);
- goto error;
+ return NULL;
}
if (!virQEMUCapsGet(qemuCaps, flag)) {
@@ -9819,19 +9658,16 @@ qemuBuildTPMDevStr(const virDomainDef *def,
_("The QEMU executable %s does not support TPM "
"model %s"),
def->emulator, model);
- goto error;
+ return NULL;
}
virBufferAsprintf(&buf, "%s,tpmdev=tpm-%s,id=%s",
model, tpm->info.alias, tpm->info.alias);
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return NULL;
return virBufferContentAndReset(&buf);
-
- error:
- return NULL;
}
@@ -9884,17 +9720,17 @@ qemuBuildTPMBackendStr(const virDomainDef *def,
case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
tpmdev = tpm->data.passthrough.source.data.file.path;
if (!(cancel_path = virTPMCreateCancelPath(tpmdev)))
- goto error;
+ return NULL;
if (qemuBuildTPMOpenBackendFDs(tpmdev, cancel_path, tpmfd, cancelfd) < 0)
- goto error;
+ return NULL;
virCommandPassFD(cmd, *tpmfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT);
virCommandPassFD(cmd, *cancelfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT);
if (!(devset = qemuVirCommandGetDevSet(cmd, *tpmfd)) ||
!(cancelset = qemuVirCommandGetDevSet(cmd, *cancelfd)))
- goto error;
+ return NULL;
virBufferAddLit(&buf, ",path=");
virQEMUBuildBufferEscapeComma(&buf, devset);
@@ -9908,20 +9744,17 @@ qemuBuildTPMBackendStr(const virDomainDef *def,
if (virAsprintf(chardev, "socket,id=chrtpm,path=%s",
tpm->data.emulator.source.data.nix.path) < 0)
- goto error;
+ return NULL;
break;
case VIR_DOMAIN_TPM_TYPE_LAST:
- goto error;
+ return NULL;
}
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return NULL;
return virBufferContentAndReset(&buf);
-
- error:
- return NULL;
}
@@ -9984,7 +9817,6 @@ qemuBuildSEVCommandLine(virDomainObjPtr vm, virCommandPtr cmd,
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
qemuDomainObjPrivatePtr priv = vm->privateData;
char *path = NULL;
- int ret = -1;
if (!sev)
return 0;
@@ -9998,23 +9830,21 @@ qemuBuildSEVCommandLine(virDomainObjPtr vm, virCommandPtr cmd,
if (sev->dh_cert) {
if (virAsprintf(&path, "%s/dh_cert.base64", priv->libDir) <
0)
- goto cleanup;
+ return -1;
virBufferAsprintf(&buf, ",dh-cert-file=%s", path);
VIR_FREE(path);
}
if (sev->session) {
if (virAsprintf(&path, "%s/session.base64", priv->libDir) <
0)
- goto cleanup;
+ return -1;
virBufferAsprintf(&buf, ",session-file=%s", path);
VIR_FREE(path);
}
virCommandAddArg(cmd, "-object");
virCommandAddArgBuffer(cmd, &buf);
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
static int
@@ -10167,15 +9997,12 @@ virJSONValuePtr
qemuBuildPRManagedManagerInfoProps(qemuDomainObjPrivatePtr priv)
{
VIR_AUTOFREE(char *) path = NULL;
- virJSONValuePtr ret = NULL;
if (!(path = qemuDomainGetManagedPRSocketPath(priv)))
return NULL;
- ret = qemuBuildPRManagerInfoPropsInternal(qemuDomainGetManagedPRAlias(),
- path);
-
- return ret;
+ return qemuBuildPRManagerInfoPropsInternal(qemuDomainGetManagedPRAlias(),
+ path);
}
@@ -10199,7 +10026,6 @@ qemuBuildManagedPRCommandLine(virCommandPtr cmd,
{
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
VIR_AUTOPTR(virJSONValue) props = NULL;
- int ret = -1;
if (!virDomainDefHasManagedPR(def))
return 0;
@@ -10208,14 +10034,12 @@ qemuBuildManagedPRCommandLine(virCommandPtr cmd,
return -1;
if (virQEMUBuildObjectCommandlineFromJSON(&buf, props) < 0)
- goto cleanup;
+ return -1;
virCommandAddArg(cmd, "-object");
virCommandAddArgBuffer(cmd, &buf);
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -10345,27 +10169,22 @@ qemuBuildVsockDevStr(virDomainDefPtr def,
{
qemuDomainVsockPrivatePtr priv = (qemuDomainVsockPrivatePtr)vsock->privateData;
VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
- char *ret = NULL;
-
if (qemuBuildVirtioDevStr(&buf, "vhost-vsock", qemuCaps,
VIR_DOMAIN_DEVICE_VSOCK, vsock) < 0) {
- goto cleanup;
+ return NULL;
}
virBufferAsprintf(&buf, ",id=%s", vsock->info.alias);
virBufferAsprintf(&buf, ",guest-cid=%u", vsock->guest_cid);
virBufferAsprintf(&buf, ",vhostfd=%s%u", fdprefix, priv->vhostfd);
if (qemuBuildDeviceAddressStr(&buf, def, &vsock->info, qemuCaps) < 0)
- goto cleanup;
+ return NULL;
if (virBufferCheckError(&buf) < 0)
- goto cleanup;
-
- ret = virBufferContentAndReset(&buf);
+ return NULL;
- cleanup:
- return ret;
+ return virBufferContentAndReset(&buf);
}
@@ -10377,22 +10196,19 @@ qemuBuildVsockCommandLine(virCommandPtr cmd,
{
qemuDomainVsockPrivatePtr priv = (qemuDomainVsockPrivatePtr)vsock->privateData;
VIR_AUTOFREE(char *) devstr = NULL;
- int ret = -1;
if (!(devstr = qemuBuildVsockDevStr(def, vsock, qemuCaps, "")))
- goto cleanup;
+ return -1;
virCommandPassFD(cmd, priv->vhostfd, VIR_COMMAND_PASS_FD_CLOSE_PARENT);
priv->vhostfd = -1;
if (qemuCommandAddExtDevice(cmd, &vsock->info) < 0)
- goto cleanup;
+ return -1;
virCommandAddArgList(cmd, "-device", devstr, NULL);
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -10707,7 +10523,7 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("'%s' is not supported in this QEMU
binary"),
virDomainChrSerialTargetModelTypeToString(serial->targetModel));
- goto error;
+ return -1;
}
break;
@@ -10721,7 +10537,7 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
* branch and we will not have ended up here. */
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Invalid target model for serial device"));
- goto error;
+ return -1;
}
virBufferAsprintf(&buf, "%s,chardev=char%s,id=%s",
@@ -10729,16 +10545,13 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
serial->info.alias, serial->info.alias);
if (qemuBuildDeviceAddressStr(&buf, def, &serial->info, qemuCaps) < 0)
- goto error;
+ return -1;
if (virBufferCheckError(&buf) < 0)
- goto error;
+ return -1;
*deviceStr = virBufferContentAndReset(&buf);
return 0;
-
- error:
- return -1;
}
static int
@@ -10771,12 +10584,12 @@ qemuBuildChannelChrDeviceStr(char **deviceStr,
if (virAsprintf(deviceStr,
"user,guestfwd=tcp:%s:%i-chardev:char%s,id=%s",
addr, port, chr->info.alias, chr->info.alias) < 0)
- goto cleanup;
+ return -1;
break;
case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO:
if (!(*deviceStr = qemuBuildVirtioSerialPortDevStr(def, chr)))
- goto cleanup;
+ return -1;
break;
case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_XEN:
@@ -10785,9 +10598,7 @@ qemuBuildChannelChrDeviceStr(char **deviceStr,
return ret;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
static int
@@ -10795,18 +10606,16 @@ qemuBuildConsoleChrDeviceStr(char **deviceStr,
const virDomainDef *def,
virDomainChrDefPtr chr)
{
- int ret = -1;
-
switch ((virDomainChrConsoleTargetType)chr->targetType) {
case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLP:
case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SCLPLM:
if (!(*deviceStr = qemuBuildSclpDevStr(chr)))
- goto cleanup;
+ return -1;
break;
case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO:
if (!(*deviceStr = qemuBuildVirtioSerialPortDevStr(def, chr)))
- goto cleanup;
+ return -1;
break;
case VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL:
@@ -10821,12 +10630,10 @@ qemuBuildConsoleChrDeviceStr(char **deviceStr,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported console target type %s"),
NULLSTR(virDomainChrConsoleTargetTypeToString(chr->targetType)));
- goto cleanup;
+ return -1;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
int
--
2.19.2