Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/qemu/qemu_cgroup.c | 15 ++--
src/qemu/qemu_domain.c | 92 ++++++++--------------
src/qemu/qemu_domain_address.c | 31 +++-----
src/qemu/qemu_driver.c | 140 ++++++++++++---------------------
src/qemu/qemu_hotplug.c | 45 +++++------
src/qemu/qemu_interface.c | 26 +++---
src/qemu/qemu_migration.c | 38 +++------
src/qemu/qemu_process.c | 77 ++++++------------
src/qemu/qemu_tpm.c | 20 ++---
9 files changed, 172 insertions(+), 312 deletions(-)
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index f8bb270117..96d77542ba 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -1077,7 +1077,6 @@ qemuSetupCgroup(virDomainObjPtr vm,
int *nicindexes)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
- int ret = -1;
if (!vm->pid) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -1092,23 +1091,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 3e8da13794..72bcd74a3a 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2300,7 +2300,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");
@@ -2315,7 +2314,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);
@@ -2328,12 +2327,9 @@ qemuStorageSourcePrivateDataFormat(virStorageSourcePtr src,
virBufferAsprintf(&tmp, "<TLSx509 alias='%s'/>\n",
src->tlsAlias);
if (virXMLFormatElement(buf, "objects", NULL, &tmp) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
@@ -2615,7 +2611,6 @@ qemuDomainObjPrivateXMLFormatNBDMigrationSource(virBufferPtr buf,
{
g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
g_auto(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
- int ret = -1;
virBufferSetChildIndent(&childBuf, buf);
@@ -2625,15 +2620,12 @@ qemuDomainObjPrivateXMLFormatNBDMigrationSource(virBufferPtr buf,
if (virDomainDiskSourceFormat(&childBuf, src, "source", 0, false,
VIR_DOMAIN_DEF_FORMAT_STATUS, xmlopt) < 0)
- goto cleanup;
+ return -1;
if (virXMLFormatElement(buf, "migrationSource", &attrBuf,
&childBuf) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
@@ -2647,7 +2639,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];
@@ -2662,16 +2653,13 @@ qemuDomainObjPrivateXMLFormatNBDMigration(virBufferPtr buf,
qemuDomainObjPrivateXMLFormatNBDMigrationSource(&childBuf,
diskPriv->migrSource,
priv->driver->xmlopt)
< 0)
- goto cleanup;
+ return -1;
if (virXMLFormatElement(buf, "disk", &attrBuf, &childBuf) <
0)
- goto cleanup;
+ return -1;
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -2683,7 +2671,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;
@@ -2709,18 +2696,15 @@ 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);
if (virXMLFormatElement(buf, "job", &attrBuf, &childBuf) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
@@ -4032,11 +4016,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) {
@@ -4149,12 +4132,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);
@@ -4169,11 +4152,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;
}
}
@@ -4192,18 +4175,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;
@@ -4238,14 +4221,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;
@@ -4264,14 +4247,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;
}
@@ -13323,19 +13304,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;
}
@@ -13686,7 +13664,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");
@@ -13694,16 +13671,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:
@@ -13713,9 +13690,7 @@ qemuDomainSetupLoader(virQEMUDriverConfigPtr cfg G_GNUC_UNUSED,
}
VIR_DEBUG("Setup loader");
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -14307,7 +14282,6 @@ qemuDomainDetachDeviceUnlink(virQEMUDriverPtr driver
G_GNUC_UNUSED,
char * const *devMountsPath,
size_t ndevMountsPath)
{
- int ret = -1;
size_t i;
if (STRPREFIX(file, QEMU_DEVPREFIX)) {
@@ -14322,13 +14296,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 fa40ba4f7d..092357f5f7 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 af8cbf40f4..1b9469ad1d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3671,7 +3671,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) {
@@ -3688,14 +3687,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;
}
@@ -3739,19 +3735,18 @@ qemuDumpToFd(virQEMUDriverPtr driver,
dumpformat);
ret = -1;
ignore_value(qemuDomainObjExitMonitor(driver, vm));
- goto cleanup;
+ return ret;
}
}
ret = qemuMonitorDumpToFd(priv->mon, fd, dumpformat, detach);
if ((qemuDomainObjExitMonitor(driver, vm) < 0) || ret < 0)
- goto cleanup;
+ return ret;
if (detach)
ret = qemuDumpWaitForCompletion(vm);
- cleanup:
return ret;
}
@@ -7417,13 +7412,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;
}
@@ -7433,13 +7427,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;
}
@@ -7976,22 +7969,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 */
@@ -8000,12 +7992,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;
}
@@ -8013,9 +8005,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
@@ -12334,20 +12324,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;
}
@@ -12356,20 +12342,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;
}
@@ -12385,7 +12367,7 @@ qemuConnectDomainEventRegisterAny(virConnectPtr conn,
int ret = -1;
if (virConnectDomainEventRegisterAnyEnsureACL(conn) < 0)
- goto cleanup;
+ return -1;
if (virDomainEventStateRegisterID(conn,
driver->domainEventState,
@@ -12393,7 +12375,6 @@ qemuConnectDomainEventRegisterAny(virConnectPtr conn,
callback, opaque, freecb, &ret) < 0)
ret = -1;
- cleanup:
return ret;
}
@@ -12403,20 +12384,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;
}
@@ -15025,7 +15002,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;
@@ -15039,7 +15015,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:
@@ -15050,12 +15026,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) {
@@ -15065,7 +15041,7 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
disk->name,
virStorageFileFormatTypeToString(
vm->def->disks[i]->src->format));
- goto cleanup;
+ return -1;
}
break;
@@ -15079,12 +15055,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;
@@ -15100,7 +15076,7 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
case VIR_DOMAIN_SNAPSHOT_LOCATION_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("unexpected code path"));
- goto cleanup;
+ return -1;
}
}
@@ -15108,7 +15084,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
@@ -15118,7 +15094,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 */
@@ -15126,7 +15102,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.
@@ -15138,7 +15114,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:
@@ -15155,17 +15131,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;
}
@@ -17420,7 +17393,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:
@@ -17429,7 +17402,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:
@@ -17440,7 +17413,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);
@@ -17450,18 +17423,17 @@ qemuDomainBlockPivot(virQEMUDriverPtr driver,
ret = qemuMonitorDrivePivot(priv->mon, job->name);
if (qemuDomainObjExitMonitor(driver, vm) < 0) {
ret = -1;
- goto cleanup;
+ return ret;
}
/* The pivot failed. The block job in QEMU remains in the synchronised state */
if (ret < 0)
- goto cleanup;
+ return ret;
if (disk && disk->mirror)
disk->mirrorState = VIR_DOMAIN_DISK_MIRROR_STATE_PIVOT;
job->state = QEMU_BLOCKJOB_STATE_PIVOTING;
- cleanup:
return ret;
}
@@ -19806,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 *
@@ -19879,7 +19847,7 @@ qemuConnectDomainQemuMonitorEventRegister(virConnectPtr conn,
int ret = -1;
if (virConnectDomainQemuMonitorEventRegisterEnsureACL(conn) < 0)
- goto cleanup;
+ return -1;
if (virDomainQemuMonitorEventStateRegisterID(conn,
driver->domainEventState,
@@ -19888,7 +19856,6 @@ qemuConnectDomainQemuMonitorEventRegister(virConnectPtr conn,
&ret) < 0)
ret = -1;
- cleanup:
return ret;
}
@@ -19898,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;
}
@@ -20792,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++) {
@@ -20813,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) {
@@ -20846,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 fd4bafef0c..e70bc018f7 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -3300,23 +3300,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;
}
@@ -3331,7 +3327,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",
@@ -3340,7 +3336,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);
@@ -3364,12 +3360,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
@@ -4019,14 +4013,14 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
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++) {
@@ -4037,7 +4031,7 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("cannot change the type of listen address "
"on '%s' graphics"), type);
- goto cleanup;
+ return ret;
}
switch (newlisten->type) {
@@ -4046,7 +4040,7 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("cannot change listen address setting "
"on '%s' graphics"), type);
- goto cleanup;
+ return ret;
}
break;
@@ -4056,7 +4050,7 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("cannot change listen address setting "
"on '%s' graphics"), type);
- goto cleanup;
+ return ret;
}
break;
@@ -4066,7 +4060,7 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("cannot change listen socket setting "
"on '%s' graphics"), type);
- goto cleanup;
+ return ret;
}
break;
@@ -4084,12 +4078,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 ret;
}
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 ret;
}
/* If a password lifetime was, or is set, or action if connected has
@@ -4108,7 +4102,7 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
cfg->vncPassword,
QEMU_ASYNC_JOB_NONE);
if (ret < 0)
- goto cleanup;
+ return ret;
/* Steal the new dev's char * reference */
VIR_FREE(olddev->data.vnc.auth.passwd);
@@ -4130,13 +4124,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 ret;
}
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 ret;
}
/* We must reset the password if it has changed but also if:
@@ -4160,7 +4154,7 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
QEMU_ASYNC_JOB_NONE);
if (ret < 0)
- goto cleanup;
+ return ret;
/* Steal the new dev's char * reference */
VIR_FREE(olddev->data.spice.auth.passwd);
@@ -4188,7 +4182,6 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver,
break;
}
- cleanup:
return ret;
}
diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c
index 70832e0c9a..5846f636cb 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 3f90536339..02787e81d8 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1771,7 +1771,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++) {
@@ -1788,7 +1787,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:
@@ -1796,9 +1795,7 @@ qemuMigrationDstOPDRelocate(virQEMUDriverPtr driver G_GNUC_UNUSED,
}
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -1849,7 +1846,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);
@@ -1860,21 +1856,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;
}
@@ -4666,9 +4657,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);
@@ -4703,7 +4694,6 @@ qemuMigrationSrcPerformPhase(virQEMUDriverPtr driver,
if (!virDomainObjIsActive(vm))
qemuDomainRemoveInactiveJob(driver, vm);
- cleanup:
return ret;
}
@@ -5327,7 +5317,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);
@@ -5335,7 +5324,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];
@@ -5357,12 +5346,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 7e0dc26658..20bf67568b 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2255,24 +2255,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;
}
@@ -4998,16 +4995,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) {
@@ -5015,7 +5011,7 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver,
graphics = vm->def->graphics[i];
if (qemuProcessGraphicsReservePorts(graphics, false) < 0)
- goto cleanup;
+ return -1;
}
}
@@ -5023,13 +5019,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;
}
@@ -5130,20 +5123,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;
}
@@ -8499,30 +8487,29 @@ static int
qemuProcessQMPInit(qemuProcessQMPPtr proc)
{
char *template = NULL;
- int ret = -1;
VIR_DEBUG("proc=%p, emulator=%s", proc, proc->binary);
if (virAsprintf(&template, "%s/qmp-XXXXXX", proc->libDir) < 0)
- goto cleanup;
+ return -1;
if (!(proc->uniqDir = mkdtemp(template))) {
virReportSystemError(errno,
_("Failed to create unique directory with "
"template '%s' for probing QEMU"),
template);
- goto cleanup;
+ return -1;
}
if (qemuProcessQEMULabelUniqPath(proc) < 0)
- goto cleanup;
+ return -1;
if (virAsprintf(&proc->monpath, "%s/%s", proc->uniqDir,
"qmp.monitor") < 0)
- goto cleanup;
+ return -1;
if (virAsprintf(&proc->monarg, "unix:%s,server,nowait",
proc->monpath) < 0)
- goto cleanup;
+ return -1;
/*
* Normally we'd use runDir for pid files, but because we're using
@@ -8530,12 +8517,9 @@ qemuProcessQMPInit(qemuProcessQMPPtr proc)
* than libvirtd. So we're using libDir which QEMU can write to
*/
if (virAsprintf(&proc->pidfile, "%s/%s", proc->uniqDir,
"qmp.pid") < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
@@ -8544,7 +8528,6 @@ qemuProcessQMPLaunch(qemuProcessQMPPtr proc)
{
const char *machine;
int status = 0;
- int ret = -1;
int rc;
if (proc->forceTCG)
@@ -8588,7 +8571,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);
@@ -8596,18 +8579,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;
}
@@ -8680,21 +8660,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 f21dbf9727..18390f9278 100644
--- a/src/qemu/qemu_tpm.c
+++ b/src/qemu/qemu_tpm.c
@@ -320,8 +320,6 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm,
uid_t qemu_user,
const char *shortName)
{
- int ret = -1;
-
if (virTPMEmulatorInit() < 0)
return -1;
@@ -332,17 +330,17 @@ 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 &&
virAsprintf(&tpm->data.emulator.logfile, "%s/%s-swtpm.log",
logDir, vmname) < 0)
- goto cleanup;
+ return -1;
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 */
@@ -350,7 +348,7 @@ qemuTPMEmulatorPrepareHost(virDomainTPMDefPtr tpm,
virReportSystemError(errno,
_("Could not chown on swtpm logfile %s"),
tpm->data.emulator.logfile);
- goto cleanup;
+ return -1;
}
/*
@@ -362,20 +360,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