The g_auto*() changes made by the previous patches made a lot
of 'cleanup' labels obsolete. Let's remove them.
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/qemu/qemu_process.c | 199 ++++++++++++++++------------------------
1 file changed, 77 insertions(+), 122 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 6ed69bef27..8843ed20da 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -109,10 +109,9 @@ qemuProcessRemoveDomainStatus(virQEMUDriverPtr driver,
g_autofree char *file = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
- int ret = -1;
if (virAsprintf(&file, "%s/%s.xml", cfg->stateDir,
vm->def->name) < 0)
- goto cleanup;
+ return -1;
if (unlink(file) < 0 && errno != ENOENT && errno != ENOTDIR)
VIR_WARN("Failed to remove domain XML for %s: %s",
@@ -124,9 +123,7 @@ qemuProcessRemoveDomainStatus(virQEMUDriverPtr driver,
VIR_WARN("Failed to remove PID file for %s: %s",
vm->def->name, virStrerror(errno, ebuf, sizeof(ebuf)));
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -2085,7 +2082,6 @@ qemuProcessLookupPTYs(virDomainChrDefPtr *devices,
{
g_autofree char *id = NULL;
size_t i;
- int ret = -1;
for (i = 0; i < count; i++) {
virDomainChrDefPtr chr = devices[i];
@@ -2104,7 +2100,7 @@ qemuProcessLookupPTYs(virDomainChrDefPtr *devices,
*/
virReportError(VIR_ERR_INTERNAL_ERROR,
_("no assigned pty for device %s"), id);
- goto cleanup;
+ return -1;
} else {
/* 'info chardev' had no pty path for this chardev,
* but the log output had, so we're fine
@@ -2115,13 +2111,11 @@ qemuProcessLookupPTYs(virDomainChrDefPtr *devices,
VIR_FREE(chr->source->data.file.path);
if (VIR_STRDUP(chr->source->data.file.path, entry->ptyPath) < 0)
- goto cleanup;
+ return -1;
}
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
static int
@@ -2174,7 +2168,6 @@ qemuProcessRefreshChannelVirtioState(virQEMUDriverPtr driver,
qemuMonitorChardevInfoPtr entry;
virObjectEventPtr event = NULL;
g_autofree char *id = NULL;
- int ret = -1;
if (booted)
agentReason = VIR_CONNECT_DOMAIN_EVENT_AGENT_LIFECYCLE_REASON_DOMAIN_STARTED;
@@ -2185,7 +2178,7 @@ qemuProcessRefreshChannelVirtioState(virQEMUDriverPtr driver,
VIR_FREE(id);
if (virAsprintf(&id, "char%s", chr->info.alias) < 0)
- goto cleanup;
+ return -1;
/* port state not reported */
if (!(entry = virHashLookup(info, id)) ||
@@ -2202,9 +2195,7 @@ qemuProcessRefreshChannelVirtioState(virQEMUDriverPtr driver,
}
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -2726,7 +2717,6 @@ static int
qemuProcessResctrlCreate(virQEMUDriverPtr driver,
virDomainObjPtr vm)
{
- int ret = -1;
size_t i = 0;
g_autoptr(virCaps) caps = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
@@ -2745,7 +2735,7 @@ qemuProcessResctrlCreate(virQEMUDriverPtr driver,
if (virResctrlAllocCreate(caps->host.resctrl,
vm->def->resctrls[i]->alloc,
priv->machineName) < 0)
- goto cleanup;
+ return -1;
for (j = 0; j < vm->def->resctrls[i]->nmonitors; j++) {
virDomainResctrlMonDefPtr mon = NULL;
@@ -2753,13 +2743,11 @@ qemuProcessResctrlCreate(virQEMUDriverPtr driver,
mon = vm->def->resctrls[i]->monitors[j];
if (virResctrlMonitorCreate(mon->instance,
priv->machineName) < 0)
- goto cleanup;
+ return -1;
}
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -2974,10 +2962,9 @@ qemuProcessInitPasswords(virQEMUDriverPtr driver,
}
if (ret < 0)
- goto cleanup;
+ return ret;
}
- cleanup:
return ret;
}
@@ -3207,7 +3194,7 @@ qemuProcessStartCPUs(virQEMUDriverPtr driver, virDomainObjPtr vm,
/* Bring up netdevs before starting CPUs */
if (qemuInterfaceStartDevices(vm->def) < 0)
- goto cleanup;
+ return -1;
VIR_DEBUG("Using lock state '%s'", NULLSTR(priv->lockState));
if (virDomainLockProcessResume(driver->lockManager, cfg->uri,
@@ -3216,7 +3203,7 @@ qemuProcessStartCPUs(virQEMUDriverPtr driver, virDomainObjPtr vm,
* to make sure we have state still present if the user
* tries to resume again
*/
- goto cleanup;
+ return -1;
}
VIR_FREE(priv->lockState);
@@ -3237,7 +3224,6 @@ qemuProcessStartCPUs(virQEMUDriverPtr driver, virDomainObjPtr vm,
* lifecycle event.
*/
- cleanup:
return ret;
release:
@@ -3245,7 +3231,7 @@ qemuProcessStartCPUs(virQEMUDriverPtr driver, virDomainObjPtr vm,
if (virDomainLockProcessPause(driver->lockManager, vm, &priv->lockState)
< 0)
VIR_WARN("Unable to release lease on %s", vm->def->name);
VIR_DEBUG("Preserving lock state '%s'",
NULLSTR(priv->lockState));
- goto cleanup;
+ return ret;
}
@@ -3846,7 +3832,6 @@ qemuProcessBuildDestroyMemoryPaths(virQEMUDriverPtr driver,
size_t i;
bool shouldBuildHP = false;
bool shouldBuildMB = false;
- int ret = -1;
if (build) {
shouldBuildHP = qemuProcessNeedHugepagesPath(vm->def, mem);
@@ -3858,11 +3843,11 @@ qemuProcessBuildDestroyMemoryPaths(virQEMUDriverPtr driver,
path = qemuGetDomainHugepagePath(vm->def, &cfg->hugetlbfs[i]);
if (!path)
- goto cleanup;
+ return -1;
if (qemuProcessBuildDestroyMemoryPathsImpl(driver, vm,
path, build) < 0)
- goto cleanup;
+ return -1;
VIR_FREE(path);
}
@@ -3870,16 +3855,14 @@ qemuProcessBuildDestroyMemoryPaths(virQEMUDriverPtr driver,
if (!build || shouldBuildMB) {
if (qemuGetMemoryBackingDomainPath(vm->def, cfg, &path) < 0)
- goto cleanup;
+ return -1;
if (qemuProcessBuildDestroyMemoryPathsImpl(driver, vm,
path, build) < 0)
- goto cleanup;
+ return -1;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -3890,20 +3873,17 @@ qemuProcessDestroyMemoryBackingPath(virQEMUDriverPtr driver,
{
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
g_autofree char *path = NULL;
- int ret = -1;
if (qemuGetMemoryBackingPath(vm->def, cfg, mem->info.alias, &path) < 0)
- goto cleanup;
+ return -1;
if (unlink(path) < 0 &&
errno != ENOENT) {
virReportSystemError(errno, _("Unable to remove %s"), path);
- goto cleanup;
+ return -1;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -3947,7 +3927,6 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
unsigned short tlsPort;
size_t i;
int defaultMode = graphics->data.spice.defaultMode;
- int ret = -1;
bool needTLSPort = false;
bool needPort = false;
@@ -3993,13 +3972,12 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
if (needTLSPort || graphics->data.spice.tlsPort == -1)
graphics->data.spice.tlsPort = 5902;
- ret = 0;
- goto cleanup;
+ return 0;
}
if (needPort || graphics->data.spice.port == -1) {
if (virPortAllocatorAcquire(driver->remotePorts, &port) < 0)
- goto cleanup;
+ return -1;
graphics->data.spice.port = port;
@@ -4012,11 +3990,11 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Auto allocation of spice TLS port requested "
"but spice TLS is disabled in qemu.conf"));
- goto cleanup;
+ return -1;
}
if (virPortAllocatorAcquire(driver->remotePorts, &tlsPort) < 0)
- goto cleanup;
+ return -1;
graphics->data.spice.tlsPort = tlsPort;
@@ -4024,10 +4002,7 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
graphics->data.spice.tlsPortReserved = true;
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -4844,7 +4819,6 @@ qemuProcessGraphicsSetupListen(virQEMUDriverPtr driver,
char *listenAddr = NULL;
bool useSocket = false;
size_t i;
- int ret = -1;
switch (graphics->type) {
case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
@@ -4878,12 +4852,12 @@ qemuProcessGraphicsSetupListen(virQEMUDriverPtr driver,
memset(glisten, 0, sizeof(virDomainGraphicsListenDef));
if (virAsprintf(&glisten->socket, "%s/%s.sock",
priv->libDir, type) < 0)
- goto cleanup;
+ return -1;
glisten->fromConfig = true;
glisten->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET;
} else if (listenAddr) {
if (VIR_STRDUP(glisten->address, listenAddr) < 0)
- goto cleanup;
+ return -1;
glisten->fromConfig = true;
}
}
@@ -4895,14 +4869,14 @@ qemuProcessGraphicsSetupListen(virQEMUDriverPtr driver,
if (qemuProcessGraphicsSetupNetworkAddress(glisten,
listenAddr) < 0)
- goto cleanup;
+ return -1;
break;
case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET:
if (!glisten->socket) {
if (virAsprintf(&glisten->socket, "%s/%s.sock",
priv->libDir, type) < 0)
- goto cleanup;
+ return -1;
glisten->autoGenerated = true;
}
break;
@@ -4913,10 +4887,7 @@ qemuProcessGraphicsSetupListen(virQEMUDriverPtr driver,
}
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
@@ -5655,7 +5626,6 @@ qemuProcessNetworkPrepareDevices(virQEMUDriverPtr driver,
{
virDomainDefPtr def = vm->def;
qemuDomainObjPrivatePtr priv = vm->privateData;
- int ret = -1;
size_t i;
g_autoptr(virConnect) conn = NULL;
@@ -5669,9 +5639,9 @@ qemuProcessNetworkPrepareDevices(virQEMUDriverPtr driver,
*/
if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
if (!conn && !(conn = virGetConnectNetwork()))
- goto cleanup;
+ return -1;
if (virDomainNetAllocateActualDevice(conn, def, net) < 0)
- goto cleanup;
+ return -1;
}
actualType = virDomainNetGetActualType(net);
@@ -5695,10 +5665,10 @@ qemuProcessNetworkPrepareDevices(virQEMUDriverPtr driver,
pcisrc->addr.domain, pcisrc->addr.bus,
pcisrc->addr.slot, pcisrc->addr.function,
net->data.network.name, def->name);
- goto cleanup;
+ return -1;
}
if (virDomainHostdevInsert(def, hostdev) < 0)
- goto cleanup;
+ return -1;
} else if (actualType == VIR_DOMAIN_NET_TYPE_USER &&
!priv->disableSlirp &&
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DBUS_VMSTATE)) {
@@ -5708,9 +5678,7 @@ qemuProcessNetworkPrepareDevices(virQEMUDriverPtr driver,
}
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -6214,18 +6182,17 @@ qemuProcessPrepareDomain(virQEMUDriverPtr driver,
virDomainObjPtr vm,
unsigned int flags)
{
- int ret = -1;
size_t i;
qemuDomainObjPrivatePtr priv = vm->privateData;
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
g_autoptr(virCaps) caps = NULL;
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
- goto cleanup;
+ return -1;
priv->machineName = qemuDomainGetMachineName(vm);
if (!priv->machineName)
- goto cleanup;
+ return -1;
if (!(flags & VIR_QEMU_PROCESS_START_PRETEND)) {
/* If you are using a SecurityDriver with dynamic labelling,
@@ -6233,12 +6200,12 @@ qemuProcessPrepareDomain(virQEMUDriverPtr driver,
VIR_DEBUG("Generating domain security label (if required)");
if (qemuSecurityGenLabel(driver->securityManager, vm->def) < 0) {
virDomainAuditSecurityLabel(vm, false);
- goto cleanup;
+ return -1;
}
virDomainAuditSecurityLabel(vm, true);
if (qemuProcessPrepareDomainNUMAPlacement(vm, caps) < 0)
- goto cleanup;
+ return -1;
}
/* Whether we should use virtlogd as stdio handler for character
@@ -6272,51 +6239,51 @@ qemuProcessPrepareDomain(virQEMUDriverPtr driver,
VIR_DEBUG("Assigning domain PCI addresses");
if ((qemuDomainAssignAddresses(vm->def, priv->qemuCaps, driver, vm,
!!(flags & VIR_QEMU_PROCESS_START_NEW))) < 0)
{
- goto cleanup;
+ return -1;
}
if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0)
- goto cleanup;
+ return -1;
VIR_DEBUG("Setting graphics devices");
if (qemuProcessSetupGraphics(driver, vm, priv->qemuCaps, flags) < 0)
- goto cleanup;
+ return -1;
VIR_DEBUG("Create domain masterKey");
if (qemuDomainMasterKeyCreate(vm) < 0)
- goto cleanup;
+ return -1;
VIR_DEBUG("Setting up storage");
if (qemuProcessPrepareDomainStorage(driver, vm, priv, cfg, flags) < 0)
- goto cleanup;
+ return -1;
VIR_DEBUG("Prepare chardev source backends for TLS");
qemuDomainPrepareChardevSource(vm->def, cfg);
VIR_DEBUG("Prepare device secrets");
if (qemuDomainSecretPrepare(driver, vm) < 0)
- goto cleanup;
+ return -1;
VIR_DEBUG("Prepare bios/uefi paths");
if (qemuFirmwareFillDomain(driver, vm, flags) < 0)
- goto cleanup;
+ return -1;
VIR_DEBUG("Preparing external devices");
if (qemuExtDevicesPrepareDomain(driver, vm) < 0)
- goto cleanup;
+ return -1;
for (i = 0; i < vm->def->nchannels; i++) {
if (qemuDomainPrepareChannel(vm->def->channels[i],
priv->channelTargetDir) < 0)
- goto cleanup;
+ return -1;
}
if (!(priv->monConfig = virDomainChrSourceDefNew(driver->xmlopt)))
- goto cleanup;
+ return -1;
VIR_DEBUG("Preparing monitor state");
if (qemuProcessPrepareMonitorChr(priv->monConfig, priv->libDir) < 0)
- goto cleanup;
+ return -1;
priv->monError = false;
priv->monStart = 0;
@@ -6325,16 +6292,14 @@ qemuProcessPrepareDomain(virQEMUDriverPtr driver,
VIR_DEBUG("Updating guest CPU definition");
if (qemuProcessUpdateGuestCPU(vm->def, priv->qemuCaps, caps, flags) < 0)
- goto cleanup;
+ return -1;
for (i = 0; i < vm->def->nshmems; i++) {
if (qemuDomainPrepareShmemChardev(vm->def->shmems[i]) < 0)
- goto cleanup;
+ return -1;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -6346,7 +6311,6 @@ qemuProcessSEVCreateFile(virDomainObjPtr vm,
qemuDomainObjPrivatePtr priv = vm->privateData;
virQEMUDriverPtr driver = priv->driver;
g_autofree char *configFile = NULL;
- int ret = -1;
if (!(configFile = virFileBuildPath(priv->libDir, name, ".base64")))
return -1;
@@ -6354,15 +6318,13 @@ qemuProcessSEVCreateFile(virDomainObjPtr vm,
if (virFileRewriteStr(configFile, S_IRUSR | S_IWUSR, data) < 0) {
virReportSystemError(errno, _("failed to write data to config
'%s'"),
configFile);
- goto cleanup;
+ return -1;
}
if (qemuSecurityDomainSetPathLabel(driver, vm, configFile, true) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -6489,17 +6451,16 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver,
virDomainObjPtr vm,
unsigned int flags)
{
- int ret = -1;
unsigned int hostdev_flags = 0;
qemuDomainObjPrivatePtr priv = vm->privateData;
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
if (qemuPrepareNVRAM(cfg, vm) < 0)
- goto cleanup;
+ return -1;
if (vm->def->vsock) {
if (qemuProcessOpenVhostVsock(vm->def->vsock) < 0)
- goto cleanup;
+ return -1;
}
/* network devices must be "prepared" before hostdevs, because
* setting up a network device might create a new hostdev that
@@ -6507,7 +6468,7 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver,
*/
VIR_DEBUG("Preparing network devices");
if (qemuProcessNetworkPrepareDevices(driver, vm) < 0)
- goto cleanup;
+ return -1;
/* Must be run before security labelling */
VIR_DEBUG("Preparing host devices");
@@ -6517,17 +6478,17 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver,
hostdev_flags |= VIR_HOSTDEV_COLD_BOOT;
if (qemuHostdevPrepareDomainDevices(driver, vm->def, priv->qemuCaps,
hostdev_flags) < 0)
- goto cleanup;
+ return -1;
VIR_DEBUG("Preparing chr devices");
if (virDomainChrDefForeach(vm->def,
true,
qemuProcessPrepareChardevDevice,
NULL) < 0)
- goto cleanup;
+ return -1;
if (qemuProcessBuildDestroyMemoryPaths(driver, vm, NULL, true) < 0)
- goto cleanup;
+ return -1;
/* Ensure no historical cgroup for this VM is lying around bogus
* settings */
@@ -6538,14 +6499,14 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver,
virReportSystemError(errno,
_("cannot create log directory %s"),
cfg->logDir);
- goto cleanup;
+ return -1;
}
VIR_FREE(priv->pidfile);
if (!(priv->pidfile = virPidFileBuildPath(cfg->stateDir, vm->def->name)))
{
virReportSystemError(errno,
"%s", _("Failed to build pidfile
path."));
- goto cleanup;
+ return -1;
}
if (unlink(priv->pidfile) < 0 &&
@@ -6553,7 +6514,7 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver,
virReportSystemError(errno,
_("Cannot remove stale PID file %s"),
priv->pidfile);
- goto cleanup;
+ return -1;
}
/*
@@ -6562,26 +6523,24 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver,
*/
if (qemuProcessMakeDir(driver, vm, priv->libDir) < 0 ||
qemuProcessMakeDir(driver, vm, priv->channelTargetDir) < 0)
- goto cleanup;
+ return -1;
VIR_DEBUG("Write domain masterKey");
if (qemuDomainWriteMasterKeyFile(driver, vm) < 0)
- goto cleanup;
+ return -1;
VIR_DEBUG("Preparing disks (host)");
if (qemuProcessPrepareHostStorage(driver, vm, flags) < 0)
- goto cleanup;
+ return -1;
VIR_DEBUG("Preparing external devices");
if (qemuExtDevicesPrepareHost(driver, vm) < 0)
- goto cleanup;
+ return -1;
if (qemuProcessPrepareSEVGuestInput(vm) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
@@ -7068,7 +7027,6 @@ qemuProcessFinishStartup(virQEMUDriverPtr driver,
bool startCPUs,
virDomainPausedReason pausedReason)
{
- int ret = -1;
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
if (startCPUs) {
@@ -7079,7 +7037,7 @@ qemuProcessFinishStartup(virQEMUDriverPtr driver,
if (virGetLastErrorCode() == VIR_ERR_OK)
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
_("resume operation failed"));
- goto cleanup;
+ return -1;
}
} else {
virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, pausedReason);
@@ -7087,17 +7045,14 @@ qemuProcessFinishStartup(virQEMUDriverPtr driver,
VIR_DEBUG("Writing domain status to disk");
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps)
< 0)
- goto cleanup;
+ return -1;
if (qemuProcessStartHook(driver, vm,
VIR_HOOK_QEMU_OP_STARTED,
VIR_HOOK_SUBOP_BEGIN) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
--
2.21.0