qemuDomainDetachDeviceLiveAndConfig: Refactor cleanup

Remove the 'cleanup' label and 'ret' variable as we can now directly
return form all cases.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-11-22 17:07:58 +01:00
parent 333fb6714e
commit c2a0d09046

View File

@ -7869,7 +7869,6 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriver *driver,
g_autoptr(virDomainDeviceDef) dev_live = NULL; g_autoptr(virDomainDeviceDef) dev_live = NULL;
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE; unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE;
g_autoptr(virDomainDef) vmdef = NULL; g_autoptr(virDomainDef) vmdef = NULL;
int ret = -1;
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
VIR_DOMAIN_AFFECT_CONFIG, -1); VIR_DOMAIN_AFFECT_CONFIG, -1);
@ -7883,35 +7882,35 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriver *driver,
if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
if (!(dev_config = virDomainDeviceDefParse(xml, vm->def, driver->xmlopt, if (!(dev_config = virDomainDeviceDefParse(xml, vm->def, driver->xmlopt,
priv->qemuCaps, parse_flags))) priv->qemuCaps, parse_flags)))
goto cleanup; return -1;
} }
if (flags & VIR_DOMAIN_AFFECT_LIVE) { if (flags & VIR_DOMAIN_AFFECT_LIVE) {
if (!(dev_live = virDomainDeviceDefParse(xml, vm->def, driver->xmlopt, if (!(dev_live = virDomainDeviceDefParse(xml, vm->def, driver->xmlopt,
priv->qemuCaps, parse_flags))) priv->qemuCaps, parse_flags)))
goto cleanup; return -1;
} }
if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
/* Make a copy for updated domain. */ /* Make a copy for updated domain. */
vmdef = virDomainObjCopyPersistentDef(vm, driver->xmlopt, priv->qemuCaps); vmdef = virDomainObjCopyPersistentDef(vm, driver->xmlopt, priv->qemuCaps);
if (!vmdef) if (!vmdef)
goto cleanup; return -1;
if (qemuDomainDetachDeviceConfig(vmdef, dev_config, priv->qemuCaps, if (qemuDomainDetachDeviceConfig(vmdef, dev_config, priv->qemuCaps,
parse_flags, parse_flags,
driver->xmlopt) < 0) driver->xmlopt) < 0)
goto cleanup; return -1;
} }
if (flags & VIR_DOMAIN_AFFECT_LIVE) { if (flags & VIR_DOMAIN_AFFECT_LIVE) {
int rc; int rc;
if ((rc = qemuDomainDetachDeviceLive(vm, dev_live, driver, false)) < 0) if ((rc = qemuDomainDetachDeviceLive(vm, dev_live, driver, false)) < 0)
goto cleanup; return -1;
if (rc == 0 && qemuDomainUpdateDeviceList(vm, VIR_ASYNC_JOB_NONE) < 0) if (rc == 0 && qemuDomainUpdateDeviceList(vm, VIR_ASYNC_JOB_NONE) < 0)
goto cleanup; return -1;
qemuDomainSaveStatus(vm); qemuDomainSaveStatus(vm);
} }
@ -7919,15 +7918,12 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriver *driver,
/* Finally, if no error until here, we can save config. */ /* Finally, if no error until here, we can save config. */
if (flags & VIR_DOMAIN_AFFECT_CONFIG) { if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
if (virDomainDefSave(vmdef, driver->xmlopt, cfg->configDir) < 0) if (virDomainDefSave(vmdef, driver->xmlopt, cfg->configDir) < 0)
goto cleanup; return -1;
virDomainObjAssignDef(vm, &vmdef, false, NULL); virDomainObjAssignDef(vm, &vmdef, false, NULL);
} }
ret = 0; return 0;
cleanup:
return ret;
} }