Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/qemu/qemu_cgroup.c | 15 ++--
src/qemu/qemu_domain.c | 84 +++++++------------
src/qemu/qemu_domain_address.c | 31 +++----
src/qemu/qemu_driver.c | 145 ++++++++++++---------------------
src/qemu/qemu_hotplug.c | 75 +++++++----------
src/qemu/qemu_interface.c | 26 +++---
src/qemu/qemu_migration.c | 38 +++------
src/qemu/qemu_process.c | 69 +++++-----------
src/qemu/qemu_tpm.c | 18 ++--
9 files changed, 176 insertions(+), 325 deletions(-)
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 131cdd1134..31cf71146b 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -1076,7 +1076,6 @@ qemuSetupCgroup(virDomainObjPtr vm,
int *nicindexes)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
- int ret = -1;
if (!vm->pid) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -1091,23 +1090,21 @@ qemuSetupCgroup(virDomainObjPtr vm,
return 0;
if (qemuSetupDevicesCgroup(vm) < 0)
- goto cleanup;
+ return -1;
if (qemuSetupBlkioCgroup(vm) < 0)
- goto cleanup;
+ return -1;
if (qemuSetupMemoryCgroup(vm) < 0)
- goto cleanup;
+ return -1;
if (qemuSetupCpuCgroup(vm) < 0)
- goto cleanup;
+ return -1;
if (qemuSetupCpusetCgroup(vm) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
int
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 1d1683a038..355d53eee1 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2291,7 +2291,6 @@ qemuStorageSourcePrivateDataFormat(virStorageSourcePtr src,
{
g_auto(virBuffer) tmp = VIR_BUFFER_INITIALIZER;
qemuDomainStorageSourcePrivatePtr srcPriv = QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src);
- int ret = -1;
if (src->nodestorage || src->nodeformat) {
virBufferAddLit(buf, "<nodenames>\n");
@@ -2306,7 +2305,7 @@ qemuStorageSourcePrivateDataFormat(virStorageSourcePtr src,
virBufferAsprintf(buf, "<reservations mgralias='%s'/>\n",
src->pr->mgralias);
if (virStorageSourcePrivateDataFormatRelPath(src, buf) < 0)
- goto cleanup;
+ return -1;
virBufferSetChildIndent(&tmp, buf);
@@ -2320,10 +2319,7 @@ qemuStorageSourcePrivateDataFormat(virStorageSourcePtr src,
virXMLFormatElement(buf, "objects", NULL, &tmp);
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -2605,7 +2601,6 @@ qemuDomainObjPrivateXMLFormatNBDMigrationSource(virBufferPtr buf,
{
g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
- int ret = -1;
virBufferSetChildIndent(&childBuf, buf);
@@ -2615,14 +2610,11 @@ qemuDomainObjPrivateXMLFormatNBDMigrationSource(virBufferPtr buf,
if (virDomainDiskSourceFormat(&childBuf, src, "source", 0, false,
VIR_DOMAIN_DEF_FORMAT_STATUS, xmlopt) < 0)
- goto cleanup;
+ return -1;
virXMLFormatElement(buf, "migrationSource", &attrBuf, &childBuf);
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -2636,7 +2628,6 @@ qemuDomainObjPrivateXMLFormatNBDMigration(virBufferPtr buf,
size_t i;
virDomainDiskDefPtr disk;
qemuDomainDiskPrivatePtr diskPriv;
- int ret = -1;
for (i = 0; i < vm->def->ndisks; i++) {
disk = vm->def->disks[i];
@@ -2651,15 +2642,12 @@ qemuDomainObjPrivateXMLFormatNBDMigration(virBufferPtr buf,
qemuDomainObjPrivateXMLFormatNBDMigrationSource(&childBuf,
diskPriv->migrSource,
priv->driver->xmlopt)
< 0)
- goto cleanup;
+ return -1;
virXMLFormatElement(buf, "disk", &attrBuf, &childBuf);
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -2671,7 +2659,6 @@ qemuDomainObjPrivateXMLFormatJob(virBufferPtr buf,
g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
qemuDomainJob job = priv->job.active;
- int ret = -1;
if (!qemuDomainTrackJob(job))
job = QEMU_JOB_NONE;
@@ -2697,17 +2684,14 @@ qemuDomainObjPrivateXMLFormatJob(virBufferPtr buf,
if (priv->job.asyncJob == QEMU_ASYNC_JOB_MIGRATION_OUT &&
qemuDomainObjPrivateXMLFormatNBDMigration(&childBuf, vm) < 0)
- goto cleanup;
+ return -1;
if (priv->job.migParams)
qemuMigrationParamsFormat(&childBuf, priv->job.migParams);
virXMLFormatElement(buf, "job", &attrBuf, &childBuf);
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -4018,11 +4002,10 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
bool addDefaultUSBKBD = false;
bool addDefaultUSBMouse = false;
bool addPanicDevice = false;
- int ret = -1;
/* add implicit input devices */
if (qemuDomainDefAddImplicitInputDevice(def) < 0)
- goto cleanup;
+ return -1;
/* Add implicit PCI root controller if the machine has one */
switch (def->os.arch) {
@@ -4135,12 +4118,12 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
if (addDefaultUSB &&
virDomainControllerFind(def, VIR_DOMAIN_CONTROLLER_TYPE_USB, 0) < 0
&&
virDomainDefAddUSBController(def, 0, usbModel) < 0)
- goto cleanup;
+ return -1;
if (addImplicitSATA &&
virDomainDefMaybeAddController(
def, VIR_DOMAIN_CONTROLLER_TYPE_SATA, 0, -1) < 0)
- goto cleanup;
+ return -1;
pciRoot = virDomainControllerFind(def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0);
@@ -4155,11 +4138,11 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
"model='pci-root' for this machine type,
"
"but model='%s' was found instead"),
virDomainControllerModelPCITypeToString(def->controllers[pciRoot]->model));
- goto cleanup;
+ return -1;
}
} else if (!virDomainDefAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0,
VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT)) {
- goto cleanup;
+ return -1;
}
}
@@ -4178,18 +4161,18 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
"model='pcie-root' for this machine type,
"
"but model='%s' was found instead"),
virDomainControllerModelPCITypeToString(def->controllers[pciRoot]->model));
- goto cleanup;
+ return -1;
}
} else if (!virDomainDefAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0,
VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT)) {
- goto cleanup;
+ return -1;
}
}
if (addDefaultMemballoon && !def->memballoon) {
virDomainMemballoonDefPtr memballoon;
if (VIR_ALLOC(memballoon) < 0)
- goto cleanup;
+ return -1;
memballoon->model = VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO;
def->memballoon = memballoon;
@@ -4224,14 +4207,14 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
virDomainDefMaybeAddInput(def,
VIR_DOMAIN_INPUT_TYPE_KBD,
VIR_DOMAIN_INPUT_BUS_USB) < 0)
- goto cleanup;
+ return -1;
if (addDefaultUSBMouse &&
def->ngraphics > 0 &&
virDomainDefMaybeAddInput(def,
VIR_DOMAIN_INPUT_TYPE_MOUSE,
VIR_DOMAIN_INPUT_BUS_USB) < 0)
- goto cleanup;
+ return -1;
if (addPanicDevice) {
size_t j;
@@ -4250,14 +4233,12 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
VIR_APPEND_ELEMENT_COPY(def->panics,
def->npanics, panic) < 0) {
VIR_FREE(panic);
- goto cleanup;
+ return -1;
}
}
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -13348,19 +13329,16 @@ qemuDomainPopulateDevices(virQEMUDriverConfigPtr cfg,
{
const char *const *devices = (const char *const *) cfg->cgroupDeviceACL;
size_t i;
- int ret = -1;
if (!devices)
devices = defaultDeviceACL;
for (i = 0; devices[i]; i++) {
if (qemuDomainCreateDevice(devices[i], data, true) < 0)
- goto cleanup;
+ return -1;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -13709,7 +13687,6 @@ qemuDomainSetupLoader(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED,
const struct qemuDomainCreateDeviceData *data)
{
virDomainLoaderDefPtr loader = vm->def->os.loader;
- int ret = -1;
VIR_DEBUG("Setting up loader");
@@ -13717,16 +13694,16 @@ qemuDomainSetupLoader(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED,
switch ((virDomainLoader) loader->type) {
case VIR_DOMAIN_LOADER_TYPE_ROM:
if (qemuDomainCreateDevice(loader->path, data, false) < 0)
- goto cleanup;
+ return -1;
break;
case VIR_DOMAIN_LOADER_TYPE_PFLASH:
if (qemuDomainCreateDevice(loader->path, data, false) < 0)
- goto cleanup;
+ return -1;
if (loader->nvram &&
qemuDomainCreateDevice(loader->nvram, data, false) < 0)
- goto cleanup;
+ return -1;
break;
case VIR_DOMAIN_LOADER_TYPE_NONE:
@@ -13736,9 +13713,7 @@ qemuDomainSetupLoader(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED,
}
VIR_DEBUG("Setup loader");
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -14327,7 +14302,6 @@ qemuDomainDetachDeviceUnlink(virQEMUDriverPtr driver
G_GNUC_UNUSED,
char * const *devMountsPath,
size_t ndevMountsPath)
{
- int ret = -1;
size_t i;
if (STRPREFIX(file, QEMU_DEVPREFIX)) {
@@ -14342,13 +14316,11 @@ qemuDomainDetachDeviceUnlink(virQEMUDriverPtr driver
G_GNUC_UNUSED,
if (virProcessRunInMountNamespace(vm->pid,
qemuDomainDetachDeviceUnlinkHelper,
(void *)file) < 0)
- goto cleanup;
+ return -1;
}
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 82db62e988..605984f80f 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -223,7 +223,6 @@ static int
qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def)
{
size_t i;
- int ret = -1;
/* Default values match QEMU. See spapr_(llan|vscsi|vty).c */
@@ -234,7 +233,7 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def)
net->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
if (qemuDomainAssignSpaprVIOAddress(def, &net->info, VIO_ADDR_NET) <
0)
- goto cleanup;
+ return -1;
}
for (i = 0; i < def->ncontrollers; i++) {
@@ -246,7 +245,7 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def)
}
if (qemuDomainAssignSpaprVIOAddress(def, &cont->info,
VIO_ADDR_SCSI) < 0) {
- goto cleanup;
+ return -1;
}
}
@@ -257,7 +256,7 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def)
}
if (qemuDomainAssignSpaprVIOAddress(def, &def->serials[i]->info,
VIO_ADDR_SERIAL) < 0)
- goto cleanup;
+ return -1;
}
if (def->nvram) {
@@ -265,15 +264,12 @@ qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def)
def->nvram->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO;
if (qemuDomainAssignSpaprVIOAddress(def, &def->nvram->info,
VIO_ADDR_NVRAM) < 0)
- goto cleanup;
+ return -1;
}
/* No other devices are currently supported on spapr-vio */
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -1376,7 +1372,6 @@ static int
qemuDomainSetupIsolationGroups(virDomainDefPtr def)
{
int idx;
- int ret = -1;
/* Only pSeries guests care about isolation groups at the moment */
if (!qemuDomainIsPSeries(def))
@@ -1384,7 +1379,7 @@ qemuDomainSetupIsolationGroups(virDomainDefPtr def)
idx = virDomainControllerFind(def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0);
if (idx < 0)
- goto cleanup;
+ return -1;
/* We want to prevent hostdevs from being plugged into the default PHB:
* we can make sure that doesn't happen by locking its isolation group */
@@ -1394,13 +1389,10 @@ qemuDomainSetupIsolationGroups(virDomainDefPtr def)
if (virDomainDeviceInfoIterate(def,
qemuDomainFillDeviceIsolationGroupIter,
NULL) < 0) {
- goto cleanup;
+ return -1;
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -1500,7 +1492,6 @@ qemuDomainCollectPCIAddress(virDomainDefPtr def G_GNUC_UNUSED,
void *opaque)
{
virDomainPCIAddressSetPtr addrs = opaque;
- int ret = -1;
virPCIDeviceAddressPtr addr = &info->addr.pci;
if (!virDeviceInfoPCIAddressIsPresent(info) ||
@@ -1577,12 +1568,10 @@ qemuDomainCollectPCIAddress(virDomainDefPtr def G_GNUC_UNUSED,
if (virDomainPCIAddressReserveAddr(addrs, addr,
info->pciConnectFlags,
info->isolationGroup) < 0) {
- goto cleanup;
+ return -1;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
static int
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f4ff2ba292..9316ab309d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3662,7 +3662,6 @@ static int
qemuDumpWaitForCompletion(virDomainObjPtr vm)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
- int ret = -1;
VIR_DEBUG("Waiting for dump completion");
while (!priv->job.dumpCompleted && !priv->job.abortJob) {
@@ -3679,14 +3678,11 @@ qemuDumpWaitForCompletion(virDomainObjPtr vm)
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("memory-only dump failed for unknown reason"));
- goto cleanup;
+ return -1;
}
qemuDomainJobInfoUpdateTime(priv->job.current);
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -3728,21 +3724,19 @@ qemuDumpToFd(virQEMUDriverPtr driver,
_("unsupported dumpformat '%s' "
"for this QEMU binary"),
dumpformat);
- ret = -1;
ignore_value(qemuDomainObjExitMonitor(driver, vm));
- goto cleanup;
+ return -1;
}
}
ret = qemuMonitorDumpToFd(priv->mon, fd, dumpformat, detach);
if ((qemuDomainObjExitMonitor(driver, vm) < 0) || ret < 0)
- goto cleanup;
+ return -1;
if (detach)
ret = qemuDumpWaitForCompletion(vm);
- cleanup:
return ret;
}
@@ -7405,13 +7399,12 @@ static int qemuConnectListDefinedDomains(virConnectPtr conn,
int ret = -1;
if (virConnectListDefinedDomainsEnsureACL(conn) < 0)
- goto cleanup;
+ return -1;
ret = virDomainObjListGetInactiveNames(driver->domains, names, nnames,
virConnectListDefinedDomainsCheckACL,
conn);
- cleanup:
return ret;
}
@@ -7421,13 +7414,12 @@ static int qemuConnectNumOfDefinedDomains(virConnectPtr conn)
int ret = -1;
if (virConnectNumOfDefinedDomainsEnsureACL(conn) < 0)
- goto cleanup;
+ return -1;
ret = virDomainObjListNumOfDomains(driver->domains, false,
virConnectNumOfDefinedDomainsCheckACL,
conn);
- cleanup:
return ret;
}
@@ -7963,22 +7955,21 @@ qemuDomainChangeDiskLive(virDomainObjPtr vm,
virDomainDiskDefPtr disk = dev->data.disk;
virDomainDiskDefPtr orig_disk = NULL;
virDomainDeviceDef oldDev = { .type = dev->type };
- int ret = -1;
if (!(orig_disk = virDomainDiskByTarget(vm->def, disk->dst))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("disk '%s' not found"), disk->dst);
- goto cleanup;
+ return -1;
}
oldDev.data.disk = orig_disk;
if (virDomainDefCompatibleDevice(vm->def, dev, &oldDev,
VIR_DOMAIN_DEVICE_ACTION_UPDATE,
true) < 0)
- goto cleanup;
+ return -1;
if (!qemuDomainDiskChangeSupported(disk, orig_disk))
- goto cleanup;
+ return -1;
if (!virStorageSourceIsSameLocation(disk->src, orig_disk->src)) {
/* Disk source can be changed only for removable devices */
@@ -7987,12 +7978,12 @@ qemuDomainChangeDiskLive(virDomainObjPtr vm,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("disk source can be changed only in removable "
"drives"));
- goto cleanup;
+ return -1;
}
if (qemuDomainChangeEjectableMedia(driver, vm, orig_disk,
dev->data.disk->src, force) < 0)
- goto cleanup;
+ return -1;
dev->data.disk->src = NULL;
}
@@ -8000,9 +7991,7 @@ qemuDomainChangeDiskLive(virDomainObjPtr vm,
orig_disk->startupPolicy = dev->data.disk->startupPolicy;
orig_disk->snapshot = dev->data.disk->snapshot;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
static int
@@ -12321,20 +12310,16 @@ qemuConnectDomainEventRegister(virConnectPtr conn,
virFreeCallback freecb)
{
virQEMUDriverPtr driver = conn->privateData;
- int ret = -1;
if (virConnectDomainEventRegisterEnsureACL(conn) < 0)
- goto cleanup;
+ return -1;
if (virDomainEventStateRegister(conn,
driver->domainEventState,
callback, opaque, freecb) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
@@ -12343,20 +12328,16 @@ qemuConnectDomainEventDeregister(virConnectPtr conn,
virConnectDomainEventCallback callback)
{
virQEMUDriverPtr driver = conn->privateData;
- int ret = -1;
if (virConnectDomainEventDeregisterEnsureACL(conn) < 0)
- goto cleanup;
+ return -1;
if (virDomainEventStateDeregister(conn,
driver->domainEventState,
callback) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
@@ -12372,7 +12353,7 @@ qemuConnectDomainEventRegisterAny(virConnectPtr conn,
int ret = -1;
if (virConnectDomainEventRegisterAnyEnsureACL(conn) < 0)
- goto cleanup;
+ return -1;
if (virDomainEventStateRegisterID(conn,
driver->domainEventState,
@@ -12380,7 +12361,6 @@ qemuConnectDomainEventRegisterAny(virConnectPtr conn,
callback, opaque, freecb, &ret) < 0)
ret = -1;
- cleanup:
return ret;
}
@@ -12390,20 +12370,16 @@ qemuConnectDomainEventDeregisterAny(virConnectPtr conn,
int callbackID)
{
virQEMUDriverPtr driver = conn->privateData;
- int ret = -1;
if (virConnectDomainEventDeregisterAnyEnsureACL(conn) < 0)
- goto cleanup;
+ return -1;
if (virObjectEventStateDeregisterID(conn,
driver->domainEventState,
callbackID, true) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
@@ -15012,7 +14988,6 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
{
qemuDomainObjPrivatePtr priv = vm->privateData;
bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
- int ret = -1;
size_t i;
bool active = virDomainObjIsActive(vm);
bool reuse = (*flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT) != 0;
@@ -15026,7 +15001,7 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
if (disk->snapshot != VIR_DOMAIN_SNAPSHOT_LOCATION_NONE &&
qemuDomainDiskBlockJobIsActive(dom_disk))
- goto cleanup;
+ return -1;
switch ((virDomainSnapshotLocation) disk->snapshot) {
case VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL:
@@ -15037,12 +15012,12 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
_("active qemu domains require external disk "
"snapshots; disk %s requested internal"),
disk->name);
- goto cleanup;
+ return -1;
}
if (qemuDomainSnapshotPrepareDiskInternal(dom_disk,
active) < 0)
- goto cleanup;
+ return -1;
if (vm->def->disks[i]->src->format > 0 &&
vm->def->disks[i]->src->format != VIR_STORAGE_FILE_QCOW2) {
@@ -15052,7 +15027,7 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
disk->name,
virStorageFileFormatTypeToString(
vm->def->disks[i]->src->format));
- goto cleanup;
+ return -1;
}
break;
@@ -15066,12 +15041,12 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
"is unsupported: %s"),
disk->name,
virStorageFileFormatTypeToString(disk->src->format));
- goto cleanup;
+ return -1;
}
if (qemuDomainSnapshotPrepareDiskExternal(dom_disk, disk,
active, reuse, blockdev) < 0)
- goto cleanup;
+ return -1;
external++;
break;
@@ -15087,7 +15062,7 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
case VIR_DOMAIN_SNAPSHOT_LOCATION_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("unexpected code path"));
- goto cleanup;
+ return -1;
}
}
@@ -15095,7 +15070,7 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
def->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_NONE) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("nothing selected for snapshot"));
- goto cleanup;
+ return -1;
}
/* internal snapshot requires a disk image to store the memory image to, and
@@ -15105,7 +15080,7 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("internal and full system snapshots require all "
"disks to be selected for snapshot"));
- goto cleanup;
+ return -1;
}
/* disk snapshot requires at least one disk */
@@ -15113,7 +15088,7 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("disk-only snapshots require at least "
"one disk to be selected for snapshot"));
- goto cleanup;
+ return -1;
}
/* For now, we don't allow mixing internal and external disks.
@@ -15125,7 +15100,7 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("mixing internal and external targets for a snapshot
"
"is not yet supported"));
- goto cleanup;
+ return -1;
}
/* internal snapshots + pflash based loader have the following problems:
@@ -15142,17 +15117,14 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("internal snapshots of a VM with pflash based "
"firmware are not supported"));
- goto cleanup;
+ return -1;
}
/* Alter flags to let later users know what we learned. */
if (external && !active)
*flags |= VIR_DOMAIN_SNAPSHOT_CREATE_DISK_ONLY;
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -17423,7 +17395,7 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
case QEMU_BLOCKJOB_TYPE_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR,
_("invalid job type '%d'"), job->type);
- goto cleanup;
+ return -1;
case QEMU_BLOCKJOB_TYPE_PULL:
case QEMU_BLOCKJOB_TYPE_COMMIT:
@@ -17432,7 +17404,7 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
virReportError(VIR_ERR_OPERATION_INVALID,
_("job type '%s' does not support pivot"),
qemuBlockjobTypeToString(job->type));
- goto cleanup;
+ return -1;
case QEMU_BLOCKJOB_TYPE_COPY:
case QEMU_BLOCKJOB_TYPE_ACTIVE_COMMIT:
@@ -17443,7 +17415,7 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
virReportError(VIR_ERR_BLOCK_COPY_ACTIVE,
_("block job '%s' not ready for pivot yet"),
job->name);
- goto cleanup;
+ return -1;
}
qemuDomainObjEnterMonitor(driver, vm);
@@ -17451,20 +17423,17 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
ret = qemuMonitorJobComplete(priv->mon, job->name);
else
ret = qemuMonitorDrivePivot(priv->mon, job->name);
- if (qemuDomainObjExitMonitor(driver, vm) < 0) {
- ret = -1;
- goto cleanup;
- }
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
+ return -1;
/* The pivot failed. The block job in QEMU remains in the synchronised state */
if (ret < 0)
- goto cleanup;
+ return -1;
if (disk && disk->mirror)
disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_PIVOT;
job->state = QEMU_BLOCKJOB_STATE_PIVOTING;
- cleanup:
return ret;
}
@@ -19809,18 +19778,14 @@ qemuConnectListAllDomains(virConnectPtr conn,
unsigned int flags)
{
virQEMUDriverPtr driver = conn->privateData;
- int ret = -1;
virCheckFlags(VIR_CONNECT_LIST_DOMAINS_FILTERS_ALL, -1);
if (virConnectListAllDomainsEnsureACL(conn) < 0)
- goto cleanup;
-
- ret = virDomainObjListExport(driver->domains, conn, domains,
- virConnectListAllDomainsCheckACL, flags);
+ return -1;
- cleanup:
- return ret;
+ return virDomainObjListExport(driver->domains, conn, domains,
+ virConnectListAllDomainsCheckACL, flags);
}
static char *
@@ -19882,7 +19847,7 @@ qemuConnectDomainQemuMonitorEventRegister(virConnectPtr conn,
int ret = -1;
if (virConnectDomainQemuMonitorEventRegisterEnsureACL(conn) < 0)
- goto cleanup;
+ return -1;
if (virDomainQemuMonitorEventStateRegisterID(conn,
driver->domainEventState,
@@ -19891,7 +19856,6 @@ qemuConnectDomainQemuMonitorEventRegister(virConnectPtr conn,
&ret) < 0)
ret = -1;
- cleanup:
return ret;
}
@@ -19901,19 +19865,15 @@ qemuConnectDomainQemuMonitorEventDeregister(virConnectPtr conn,
int callbackID)
{
virQEMUDriverPtr driver = conn->privateData;
- int ret = -1;
if (virConnectDomainQemuMonitorEventDeregisterEnsureACL(conn) < 0)
- goto cleanup;
+ return -1;
if (virObjectEventStateDeregisterID(conn, driver->domainEventState,
callbackID, true) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
@@ -20795,13 +20755,12 @@ qemuDomainGetStatsInterface(virQEMUDriverPtr driver
G_GNUC_UNUSED,
{
size_t i;
struct _virDomainInterfaceStats tmp;
- int ret = -1;
if (!virDomainObjIsActive(dom))
return 0;
if (virTypedParamListAddUInt(params, dom->def->nnets, "net.count")
< 0)
- goto cleanup;
+ return -1;
/* Check the path is one of the domain's network interfaces. */
for (i = 0; i < dom->def->nnets; i++) {
@@ -20816,7 +20775,7 @@ qemuDomainGetStatsInterface(virQEMUDriverPtr driver
G_GNUC_UNUSED,
actualType = virDomainNetGetActualType(net);
if (virTypedParamListAddString(params, net->ifname, "net.%zu.name",
i) < 0)
- goto cleanup;
+ return -1;
if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER) {
if (virNetDevOpenvswitchInterfaceStats(net->ifname, &tmp) < 0) {
@@ -20849,9 +20808,7 @@ qemuDomainGetStatsInterface(virQEMUDriverPtr driver
G_GNUC_UNUSED,
"tx.drop", tmp.tx_drop);
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
#undef QEMU_ADD_NET_PARAM
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 811ad952c5..b2fceec582 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -3298,23 +3298,19 @@ qemuDomainAttachLease(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainLeaseDefPtr lease)
{
- int ret = -1;
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
if (virDomainLeaseInsertPreAlloc(vm->def) < 0)
- goto cleanup;
+ return -1;
if (virDomainLockLeaseAttach(driver->lockManager, cfg->uri,
vm, lease) < 0) {
virDomainLeaseInsertPreAlloced(vm->def, NULL);
- goto cleanup;
+ return -1;
}
virDomainLeaseInsertPreAlloced(vm->def, lease);
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -3329,7 +3325,7 @@ qemuDomainChangeNetBridge(virDomainObjPtr vm,
if (!oldbridge || !newbridge) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing bridge
name"));
- goto cleanup;
+ return -1;
}
VIR_DEBUG("Change bridge for interface %s: %s -> %s",
@@ -3338,7 +3334,7 @@ qemuDomainChangeNetBridge(virDomainObjPtr vm,
if (virNetDevExists(newbridge) != 1) {
virReportError(VIR_ERR_OPERATION_FAILED,
_("bridge %s doesn't exist"), newbridge);
- goto cleanup;
+ return -1;
}
ret = virNetDevBridgeRemovePort(oldbridge, olddev->ifname);
@@ -3362,12 +3358,10 @@ qemuDomainChangeNetBridge(virDomainObjPtr vm,
_("unable to recover former state by adding port "
"to bridge %s"), oldbridge);
}
- goto cleanup;
+ return ret;
}
/* caller will replace entire olddev with newdev in domain nets list */
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
static int
@@ -4010,20 +4004,19 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
const char *type = virDomainGraphicsTypeToString(dev->type);
size_t i;
- int ret = -1;
if (!olddev) {
virReportError(VIR_ERR_DEVICE_MISSING,
_("cannot find existing graphics device to modify of "
"type '%s'"), type);
- goto cleanup;
+ return -1;
}
if (dev->nListens != olddev->nListens) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("cannot change the number of listen addresses "
"on '%s' graphics"), type);
- goto cleanup;
+ return -1;
}
for (i = 0; i < dev->nListens; i++) {
@@ -4034,7 +4027,7 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("cannot change the type of listen address "
"on '%s' graphics"), type);
- goto cleanup;
+ return -1;
}
switch (newlisten->type) {
@@ -4043,7 +4036,7 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("cannot change listen address setting "
"on '%s' graphics"), type);
- goto cleanup;
+ return -1;
}
break;
@@ -4053,7 +4046,7 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("cannot change listen address setting "
"on '%s' graphics"), type);
- goto cleanup;
+ return -1;
}
break;
@@ -4063,7 +4056,7 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("cannot change listen socket setting "
"on '%s' graphics"), type);
- goto cleanup;
+ return -1;
}
break;
@@ -4081,12 +4074,12 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
(olddev->data.vnc.port != dev->data.vnc.port))) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot change port settings on vnc graphics"));
- goto cleanup;
+ return -1;
}
if (STRNEQ_NULLABLE(olddev->data.vnc.keymap, dev->data.vnc.keymap)) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot change keymap setting on vnc graphics"));
- goto cleanup;
+ return -1;
}
/* If a password lifetime was, or is set, or action if connected has
@@ -4099,13 +4092,13 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
dev->data.vnc.auth.passwd)) {
VIR_DEBUG("Updating password on VNC server %p %p",
dev->data.vnc.auth.passwd, cfg->vncPassword);
- ret = qemuDomainChangeGraphicsPasswords(driver, vm,
- VIR_DOMAIN_GRAPHICS_TYPE_VNC,
- &dev->data.vnc.auth,
- cfg->vncPassword,
- QEMU_ASYNC_JOB_NONE);
- if (ret < 0)
- goto cleanup;
+
+ if (qemuDomainChangeGraphicsPasswords(driver, vm,
+ VIR_DOMAIN_GRAPHICS_TYPE_VNC,
+ &dev->data.vnc.auth,
+ cfg->vncPassword,
+ QEMU_ASYNC_JOB_NONE) < 0)
+ return -1;
/* Steal the new dev's char * reference */
VIR_FREE(olddev->data.vnc.auth.passwd);
@@ -4114,8 +4107,6 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
olddev->data.vnc.auth.validTo = dev->data.vnc.auth.validTo;
olddev->data.vnc.auth.expires = dev->data.vnc.auth.expires;
olddev->data.vnc.auth.connected = dev->data.vnc.auth.connected;
- } else {
- ret = 0;
}
break;
@@ -4127,13 +4118,13 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
(olddev->data.spice.tlsPort != dev->data.spice.tlsPort))) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot change port settings on spice
graphics"));
- goto cleanup;
+ return -1;
}
if (STRNEQ_NULLABLE(olddev->data.spice.keymap,
dev->data.spice.keymap)) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("cannot change keymap setting on spice
graphics"));
- goto cleanup;
+ return -1;
}
/* We must reset the password if it has changed but also if:
@@ -4150,14 +4141,12 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
dev->data.spice.auth.passwd)) {
VIR_DEBUG("Updating password on SPICE server %p %p",
dev->data.spice.auth.passwd, cfg->spicePassword);
- ret = qemuDomainChangeGraphicsPasswords(driver, vm,
- VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
- &dev->data.spice.auth,
- cfg->spicePassword,
- QEMU_ASYNC_JOB_NONE);
-
- if (ret < 0)
- goto cleanup;
+ if (qemuDomainChangeGraphicsPasswords(driver, vm,
+ VIR_DOMAIN_GRAPHICS_TYPE_SPICE,
+ &dev->data.spice.auth,
+ cfg->spicePassword,
+ QEMU_ASYNC_JOB_NONE) < 0)
+ return -1;
/* Steal the new dev's char * reference */
VIR_FREE(olddev->data.spice.auth.passwd);
@@ -4168,7 +4157,6 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
olddev->data.spice.auth.connected = dev->data.spice.auth.connected;
} else {
VIR_DEBUG("Not updating since password didn't change");
- ret = 0;
}
break;
@@ -4185,8 +4173,7 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
break;
}
- cleanup:
- return ret;
+ return 0;
}
diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c
index dff4b3d76d..bb62b53c04 100644
--- a/src/qemu/qemu_interface.c
+++ b/src/qemu/qemu_interface.c
@@ -53,7 +53,6 @@ VIR_LOG_INIT("qemu.qemu_interface");
int
qemuInterfaceStartDevice(virDomainNetDefPtr net)
{
- int ret = -1;
virDomainNetType actualType = virDomainNetGetActualType(net);
switch (actualType) {
@@ -71,7 +70,7 @@ qemuInterfaceStartDevice(virDomainNetDefPtr net)
if (virNetDevBridgeFDBAdd(&net->mac, net->ifname,
VIR_NETDEVBRIDGE_FDB_FLAG_MASTER |
VIR_NETDEVBRIDGE_FDB_FLAG_TEMP) < 0)
- goto cleanup;
+ return -1;
}
break;
@@ -84,9 +83,9 @@ qemuInterfaceStartDevice(virDomainNetDefPtr net)
* some sort of "blip" in the physdev's status.
*/
if (physdev && virNetDevGetOnline(physdev, &isOnline) < 0)
- goto cleanup;
+ return -1;
if (!isOnline && virNetDevSetOnline(physdev, true) < 0)
- goto cleanup;
+ return -1;
/* macvtap devices share their MAC address with the guest
* domain, and if they are set online prior to the domain CPUs
@@ -101,13 +100,13 @@ qemuInterfaceStartDevice(virDomainNetDefPtr net)
* we are starting the domain CPUs.
*/
if (virNetDevSetOnline(net->ifname, true) < 0)
- goto cleanup;
+ return -1;
break;
}
case VIR_DOMAIN_NET_TYPE_ETHERNET:
if (virNetDevIPInfoAddToDev(net->ifname, &net->hostIP) < 0)
- goto cleanup;
+ return -1;
break;
@@ -124,9 +123,7 @@ qemuInterfaceStartDevice(virDomainNetDefPtr net)
break;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
/**
@@ -159,7 +156,6 @@ qemuInterfaceStartDevices(virDomainDefPtr def)
int
qemuInterfaceStopDevice(virDomainNetDefPtr net)
{
- int ret = -1;
virDomainNetType actualType = virDomainNetGetActualType(net);
switch (actualType) {
@@ -173,7 +169,7 @@ qemuInterfaceStopDevice(virDomainNetDefPtr net)
if (virNetDevBridgeFDBDel(&net->mac, net->ifname,
VIR_NETDEVBRIDGE_FDB_FLAG_MASTER |
VIR_NETDEVBRIDGE_FDB_FLAG_TEMP) < 0)
- goto cleanup;
+ return -1;
}
break;
@@ -186,7 +182,7 @@ qemuInterfaceStopDevice(virDomainNetDefPtr net)
* on this network.
*/
if (virNetDevSetOnline(net->ifname, false) < 0)
- goto cleanup;
+ return -1;
/* also mark the physdev down for passthrough macvtap, as the
* physdev has the same MAC address as the macvtap device.
@@ -194,7 +190,7 @@ qemuInterfaceStopDevice(virDomainNetDefPtr net)
if (virDomainNetGetActualDirectMode(net) ==
VIR_NETDEV_MACVLAN_MODE_PASSTHRU &&
physdev && virNetDevSetOnline(physdev, false) < 0)
- goto cleanup;
+ return -1;
break;
}
@@ -212,9 +208,7 @@ qemuInterfaceStopDevice(virDomainNetDefPtr net)
break;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
/**
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 0447aa73bf..487ed03d9f 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1768,7 +1768,6 @@ qemuMigrationDstOPDRelocate(virQEMUDriverPtr driver G_GNUC_UNUSED,
qemuMigrationCookiePtr cookie)
{
virDomainNetDefPtr netptr;
- int ret = -1;
size_t i;
for (i = 0; i < cookie->network->nnets; i++) {
@@ -1785,7 +1784,7 @@ qemuMigrationDstOPDRelocate(virQEMUDriverPtr driver G_GNUC_UNUSED,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to run command to set OVS port data for
"
"interface %s"), netptr->ifname);
- goto cleanup;
+ return -1;
}
break;
default:
@@ -1793,9 +1792,7 @@ qemuMigrationDstOPDRelocate(virQEMUDriverPtr driver G_GNUC_UNUSED,
}
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -1846,7 +1843,6 @@ qemuMigrationDstRun(virQEMUDriverPtr driver,
qemuDomainAsyncJob asyncJob)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
- int ret = -1;
int rv;
VIR_DEBUG("Setting up incoming migration with URI %s", uri);
@@ -1857,21 +1853,16 @@ qemuMigrationDstRun(virQEMUDriverPtr driver,
rv = qemuMonitorMigrateIncoming(priv->mon, uri);
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rv < 0)
- goto cleanup;
+ return -1;
- if (asyncJob == QEMU_ASYNC_JOB_MIGRATION_IN) {
+ if (asyncJob == QEMU_ASYNC_JOB_MIGRATION_IN)
/* qemuMigrationDstWaitForCompletion is called from the Finish phase */
- ret = 0;
- goto cleanup;
- }
+ return 0;
if (qemuMigrationDstWaitForCompletion(driver, vm, asyncJob, false) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
@@ -4657,9 +4648,9 @@ qemuMigrationSrcPerformPhase(virQEMUDriverPtr driver,
if (!(flags & VIR_MIGRATE_CHANGE_PROTECTION)) {
if (qemuMigrationJobStart(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT,
flags) < 0)
- goto cleanup;
+ return ret;
} else if (!qemuMigrationJobIsActive(vm, QEMU_ASYNC_JOB_MIGRATION_OUT)) {
- goto cleanup;
+ return ret;
}
qemuMigrationJobStartPhase(driver, vm, QEMU_MIGRATION_PHASE_PERFORM3);
@@ -4694,7 +4685,6 @@ qemuMigrationSrcPerformPhase(virQEMUDriverPtr driver,
if (!virDomainObjIsActive(vm))
qemuDomainRemoveInactiveJob(driver, vm);
- cleanup:
return ret;
}
@@ -5318,7 +5308,6 @@ qemuMigrationSrcCancel(virQEMUDriverPtr driver,
qemuDomainObjPrivatePtr priv = vm->privateData;
bool storage = false;
size_t i;
- int ret = -1;
VIR_DEBUG("Canceling unfinished outgoing migration of domain %s",
vm->def->name);
@@ -5326,7 +5315,7 @@ qemuMigrationSrcCancel(virQEMUDriverPtr driver,
qemuDomainObjEnterMonitor(driver, vm);
ignore_value(qemuMonitorMigrateCancel(priv->mon));
if (qemuDomainObjExitMonitor(driver, vm) < 0)
- goto cleanup;
+ return -1;
for (i = 0; i < vm->def->ndisks; i++) {
virDomainDiskDefPtr disk = vm->def->disks[i];
@@ -5348,12 +5337,9 @@ qemuMigrationSrcCancel(virQEMUDriverPtr driver,
if (storage &&
qemuMigrationSrcNBDCopyCancel(driver, vm, false,
QEMU_ASYNC_JOB_NONE, NULL) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 4cf4069d50..797fe849e3 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2243,24 +2243,21 @@ qemuProcessRefreshPRManagerState(virDomainObjPtr vm,
qemuDomainObjPrivatePtr priv = vm->privateData;
qemuMonitorPRManagerInfoPtr prManagerInfo;
const char *managedAlias = qemuDomainGetManagedPRAlias();
- int ret = -1;
if (!(prManagerInfo = virHashLookup(info, managedAlias))) {
virReportError(VIR_ERR_OPERATION_FAILED,
_("missing info on pr-manager %s"),
managedAlias);
- goto cleanup;
+ return -1;
}
priv->prDaemonRunning = prManagerInfo->connected;
if (!priv->prDaemonRunning &&
qemuProcessStartManagedPRDaemon(vm) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -4978,16 +4975,15 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver,
virDomainGraphicsDefPtr graphics;
bool allocate = !(flags & VIR_QEMU_PROCESS_START_PRETEND);
size_t i;
- int ret = -1;
for (i = 0; i < vm->def->ngraphics; i++) {
graphics = vm->def->graphics[i];
if (qemuProcessGraphicsSetupRenderNode(graphics, qemuCaps) < 0)
- goto cleanup;
+ return -1;
if (qemuProcessGraphicsSetupListen(driver, graphics, vm) < 0)
- goto cleanup;
+ return -1;
}
if (allocate) {
@@ -4995,7 +4991,7 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver,
graphics = vm->def->graphics[i];
if (qemuProcessGraphicsReservePorts(graphics, false) < 0)
- goto cleanup;
+ return -1;
}
}
@@ -5003,13 +4999,10 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver,
graphics = vm->def->graphics[i];
if (qemuProcessGraphicsAllocatePorts(driver, graphics, allocate) < 0)
- goto cleanup;
+ return -1;
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -5110,20 +5103,15 @@ qemuProcessMakeDir(virQEMUDriverPtr driver,
virDomainObjPtr vm,
const char *path)
{
- int ret = -1;
-
if (virFileMakePathWithMode(path, 0750) < 0) {
virReportSystemError(errno, _("Cannot create directory '%s'"),
path);
- goto cleanup;
+ return -1;
}
if (qemuSecurityDomainSetPathLabel(driver, vm, path, true) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
@@ -8502,7 +8490,6 @@ static int
qemuProcessQMPInit(qemuProcessQMPPtr proc)
{
char *template = NULL;
- int ret = -1;
VIR_DEBUG("proc=%p, emulator=%s", proc, proc->binary);
@@ -8513,11 +8500,11 @@ qemuProcessQMPInit(qemuProcessQMPPtr proc)
_("Failed to create unique directory with "
"template '%s' for probing QEMU"),
template);
- goto cleanup;
+ return -1;
}
if (qemuProcessQEMULabelUniqPath(proc) < 0)
- goto cleanup;
+ return -1;
proc->monpath = g_strdup_printf("%s/%s", proc->uniqDir,
"qmp.monitor");
@@ -8530,10 +8517,7 @@ qemuProcessQMPInit(qemuProcessQMPPtr proc)
*/
proc->pidfile = g_strdup_printf("%s/%s", proc->uniqDir,
"qmp.pid");
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -8542,7 +8526,6 @@ qemuProcessQMPLaunch(qemuProcessQMPPtr proc)
{
const char *machine;
int status = 0;
- int ret = -1;
int rc;
if (proc->forceTCG)
@@ -8586,7 +8569,7 @@ qemuProcessQMPLaunch(qemuProcessQMPPtr proc)
virCommandSetErrorBuffer(proc->cmd, &(proc->stdErr));
if (virCommandRun(proc->cmd, &status) < 0)
- goto cleanup;
+ return -1;
if (status != 0) {
VIR_DEBUG("QEMU %s exited with status %d", proc->binary, status);
@@ -8594,18 +8577,15 @@ qemuProcessQMPLaunch(qemuProcessQMPPtr proc)
_("Failed to start QEMU binary %s for probing: %s"),
proc->binary,
proc->stdErr ? proc->stdErr : _("unknown
error"));
- goto cleanup;
+ return -1;
}
if ((rc = virPidFileReadPath(proc->pidfile, &proc->pid)) < 0) {
virReportSystemError(-rc, _("Failed to read pidfile %s"),
proc->pidfile);
- goto cleanup;
+ return -1;
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -8678,21 +8658,16 @@ qemuProcessQMPConnectMonitor(qemuProcessQMPPtr proc)
int
qemuProcessQMPStart(qemuProcessQMPPtr proc)
{
- int ret = -1;
-
VIR_DEBUG("proc=%p, emulator=%s", proc, proc->binary);
if (qemuProcessQMPInit(proc) < 0)
- goto cleanup;
+ return -1;
if (qemuProcessQMPLaunch(proc) < 0)
- goto cleanup;
+ return -1;
if (qemuProcessQMPConnectMonitor(proc) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
diff --git a/src/qemu/qemu_tpm.c b/src/qemu/qemu_tpm.c
index 62b9f803bd..b435fc0bf0 100644
--- a/src/qemu/qemu_tpm.c
+++ b/src/qemu/qemu_tpm.c
@@ -316,8 +316,6 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm,
uid_t qemu_user,
const char *shortName)
{
- int ret = -1;
-
if (virTPMEmulatorInit() < 0)
return -1;
@@ -328,7 +326,7 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm,
/* ... and adjust ownership */
if (virDirCreate(logDir, 0730, swtpm_user, swtpm_group,
VIR_DIR_CREATE_ALLOW_EXIST) < 0)
- goto cleanup;
+ return -1;
/* create logfile name ... */
if (!tpm->data.emulator.logfile)
@@ -336,7 +334,7 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm,
if (!virFileExists(tpm->data.emulator.logfile) &&
virFileTouch(tpm->data.emulator.logfile, 0644) < 0) {
- goto cleanup;
+ return -1;
}
/* ... and make sure it can be accessed by swtpm_user */
@@ -344,7 +342,7 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm,
virReportSystemError(errno,
_("Could not chown on swtpm logfile %s"),
tpm->data.emulator.logfile);
- goto cleanup;
+ return -1;
}
/*
@@ -356,20 +354,16 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm,
*/
if (virDirCreate(swtpmStateDir, 0770, qemu_user, swtpm_group,
VIR_DIR_CREATE_ALLOW_EXIST) < 0)
- goto cleanup;
+ return -1;
/* create the socket filename */
if (!tpm->data.emulator.source.data.nix.path &&
!(tpm->data.emulator.source.data.nix.path =
qemuTPMCreateEmulatorSocket(swtpmStateDir, shortName)))
- goto cleanup;
+ return -1;
tpm->data.emulator.source.type = VIR_DOMAIN_CHR_TYPE_UNIX;
- ret = 0;
-
- cleanup:
-
- return ret;
+ return 0;
}
/*
--
2.21.0