qemu_driver.c: remove unneeded 'cleanup' labels

Some labels became deprecated after the previous patches.

Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
Daniel Henrique Barboza 2020-11-12 15:40:39 -03:00
parent 9c215628d6
commit 269dffd0ce

View File

@ -7764,7 +7764,6 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr vm,
g_autoptr(virDomainDeviceDef) devConf = NULL; g_autoptr(virDomainDeviceDef) devConf = NULL;
virDomainDeviceDef devConfSave = { 0 }; virDomainDeviceDef devConfSave = { 0 };
g_autoptr(virDomainDeviceDef) devLive = NULL; g_autoptr(virDomainDeviceDef) devLive = NULL;
int ret = -1;
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE | unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE |
VIR_DOMAIN_DEF_PARSE_ABI_UPDATE; VIR_DOMAIN_DEF_PARSE_ABI_UPDATE;
@ -7780,12 +7779,12 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr vm,
vmdef = virDomainObjCopyPersistentDef(vm, driver->xmlopt, vmdef = virDomainObjCopyPersistentDef(vm, driver->xmlopt,
priv->qemuCaps); priv->qemuCaps);
if (!vmdef) if (!vmdef)
goto cleanup; return -1;
if (!(devConf = virDomainDeviceDefParse(xml, vmdef, if (!(devConf = virDomainDeviceDefParse(xml, vmdef,
driver->xmlopt, priv->qemuCaps, driver->xmlopt, priv->qemuCaps,
parse_flags))) parse_flags)))
goto cleanup; return -1;
/* /*
* devConf will be NULLed out by * devConf will be NULLed out by
@ -7796,60 +7795,58 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr vm,
if (virDomainDeviceValidateAliasForHotplug(vm, devConf, if (virDomainDeviceValidateAliasForHotplug(vm, devConf,
VIR_DOMAIN_AFFECT_CONFIG) < 0) VIR_DOMAIN_AFFECT_CONFIG) < 0)
goto cleanup; return -1;
if (virDomainDefCompatibleDevice(vmdef, devConf, NULL, if (virDomainDefCompatibleDevice(vmdef, devConf, NULL,
VIR_DOMAIN_DEVICE_ACTION_ATTACH, VIR_DOMAIN_DEVICE_ACTION_ATTACH,
false) < 0) false) < 0)
goto cleanup; return -1;
if (qemuDomainAttachDeviceConfig(vmdef, devConf, priv->qemuCaps, if (qemuDomainAttachDeviceConfig(vmdef, devConf, 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) {
if (!(devLive = virDomainDeviceDefParse(xml, vm->def, if (!(devLive = virDomainDeviceDefParse(xml, vm->def,
driver->xmlopt, priv->qemuCaps, driver->xmlopt, priv->qemuCaps,
parse_flags))) parse_flags)))
goto cleanup; return -1;
if (flags & VIR_DOMAIN_AFFECT_CONFIG) if (flags & VIR_DOMAIN_AFFECT_CONFIG)
qemuDomainAttachDeviceLiveAndConfigHomogenize(&devConfSave, devLive); qemuDomainAttachDeviceLiveAndConfigHomogenize(&devConfSave, devLive);
if (virDomainDeviceValidateAliasForHotplug(vm, devLive, if (virDomainDeviceValidateAliasForHotplug(vm, devLive,
VIR_DOMAIN_AFFECT_LIVE) < 0) VIR_DOMAIN_AFFECT_LIVE) < 0)
goto cleanup; return -1;
if (virDomainDefCompatibleDevice(vm->def, devLive, NULL, if (virDomainDefCompatibleDevice(vm->def, devLive, NULL,
VIR_DOMAIN_DEVICE_ACTION_ATTACH, VIR_DOMAIN_DEVICE_ACTION_ATTACH,
true) < 0) true) < 0)
goto cleanup; return -1;
if (qemuDomainAttachDeviceLive(vm, devLive, driver) < 0) if (qemuDomainAttachDeviceLive(vm, devLive, driver) < 0)
goto cleanup; return -1;
/* /*
* update domain status forcibly because the domain status may be * update domain status forcibly because the domain status may be
* changed even if we failed to attach the device. For example, * changed even if we failed to attach the device. For example,
* a new controller may be created. * a new controller may be created.
*/ */
if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0)
goto cleanup; return -1;
} }
/* 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);
vmdef = NULL; vmdef = NULL;
} }
ret = 0; return 0;
cleanup:
return ret;
} }
static int static int
@ -8107,7 +8104,6 @@ qemuDomainDetachDeviceAliasLiveAndConfig(virQEMUDriverPtr driver,
virDomainDefPtr persistentDef = NULL; virDomainDefPtr persistentDef = NULL;
g_autoptr(virDomainDef) vmdef = NULL; g_autoptr(virDomainDef) vmdef = NULL;
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE; unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE;
int ret = -1;
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
VIR_DOMAIN_AFFECT_CONFIG, -1); VIR_DOMAIN_AFFECT_CONFIG, -1);
@ -8119,21 +8115,21 @@ qemuDomainDetachDeviceAliasLiveAndConfig(virQEMUDriverPtr driver,
parse_flags |= VIR_DOMAIN_DEF_PARSE_INACTIVE; parse_flags |= VIR_DOMAIN_DEF_PARSE_INACTIVE;
if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
goto cleanup; return -1;
if (persistentDef) { if (persistentDef) {
virDomainDeviceDef dev; virDomainDeviceDef dev;
if (!(vmdef = virDomainObjCopyPersistentDef(vm, driver->xmlopt, if (!(vmdef = virDomainObjCopyPersistentDef(vm, driver->xmlopt,
priv->qemuCaps))) priv->qemuCaps)))
goto cleanup; return -1;
if (virDomainDefFindDevice(vmdef, alias, &dev, true) < 0) if (virDomainDefFindDevice(vmdef, alias, &dev, true) < 0)
goto cleanup; return -1;
if (qemuDomainDetachDeviceConfig(vmdef, &dev, priv->qemuCaps, if (qemuDomainDetachDeviceConfig(vmdef, &dev, priv->qemuCaps,
parse_flags, driver->xmlopt) < 0) parse_flags, driver->xmlopt) < 0)
goto cleanup; return -1;
} }
if (def) { if (def) {
@ -8141,25 +8137,23 @@ qemuDomainDetachDeviceAliasLiveAndConfig(virQEMUDriverPtr driver,
int rc; int rc;
if (virDomainDefFindDevice(def, alias, &dev, true) < 0) if (virDomainDefFindDevice(def, alias, &dev, true) < 0)
goto cleanup; return -1;
if ((rc = qemuDomainDetachDeviceLive(vm, &dev, driver, true)) < 0) if ((rc = qemuDomainDetachDeviceLive(vm, &dev, driver, true)) < 0)
goto cleanup; return -1;
if (rc == 0 && qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE) < 0) if (rc == 0 && qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
goto cleanup; return -1;
} }
if (vmdef) { if (vmdef) {
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);
vmdef = NULL; vmdef = NULL;
} }
ret = 0; return 0;
cleanup:
return ret;
} }
@ -11167,39 +11161,35 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn,
g_autoptr(virDomainDef) def = NULL; g_autoptr(virDomainDef) def = NULL;
g_autofree char *origname = NULL; g_autofree char *origname = NULL;
g_autoptr(qemuMigrationParams) migParams = NULL; g_autoptr(qemuMigrationParams) migParams = NULL;
int ret = -1;
virCheckFlags(QEMU_MIGRATION_FLAGS, -1); virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
if (!(flags & VIR_MIGRATE_TUNNELLED)) { if (!(flags & VIR_MIGRATE_TUNNELLED)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("PrepareTunnel called but no TUNNELLED flag set")); _("PrepareTunnel called but no TUNNELLED flag set"));
goto cleanup; return -1;
} }
if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags, if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags,
QEMU_MIGRATION_DESTINATION))) QEMU_MIGRATION_DESTINATION)))
goto cleanup; return -1;
if (virLockManagerPluginUsesState(driver->lockManager)) { if (virLockManagerPluginUsesState(driver->lockManager)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Cannot use migrate v2 protocol with lock manager %s"), _("Cannot use migrate v2 protocol with lock manager %s"),
virLockManagerPluginGetName(driver->lockManager)); virLockManagerPluginGetName(driver->lockManager));
goto cleanup; return -1;
} }
if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname))) if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname)))
goto cleanup; return -1;
if (virDomainMigratePrepareTunnelEnsureACL(dconn, def) < 0) if (virDomainMigratePrepareTunnelEnsureACL(dconn, def) < 0)
goto cleanup; return -1;
ret = qemuMigrationDstPrepareTunnel(driver, dconn, return qemuMigrationDstPrepareTunnel(driver, dconn,
NULL, 0, NULL, NULL, /* No cookies in v2 */ NULL, 0, NULL, NULL, /* No cookies in v2 */
st, &def, origname, migParams, flags); st, &def, origname, migParams, flags);
cleanup:
return ret;
} }
/* Prepare is the first step, and it runs on the destination host. /* Prepare is the first step, and it runs on the destination host.
@ -11221,7 +11211,6 @@ qemuDomainMigratePrepare2(virConnectPtr dconn,
g_autoptr(virDomainDef) def = NULL; g_autoptr(virDomainDef) def = NULL;
g_autofree char *origname = NULL; g_autofree char *origname = NULL;
g_autoptr(qemuMigrationParams) migParams = NULL; g_autoptr(qemuMigrationParams) migParams = NULL;
int ret = -1;
virCheckFlags(QEMU_MIGRATION_FLAGS, -1); virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
@ -11232,38 +11221,35 @@ qemuDomainMigratePrepare2(virConnectPtr dconn,
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Tunnelled migration requested but invalid " _("Tunnelled migration requested but invalid "
"RPC method called")); "RPC method called"));
goto cleanup; return -1;
} }
if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags, if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags,
QEMU_MIGRATION_DESTINATION))) QEMU_MIGRATION_DESTINATION)))
goto cleanup; return -1;
if (virLockManagerPluginUsesState(driver->lockManager)) { if (virLockManagerPluginUsesState(driver->lockManager)) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Cannot use migrate v2 protocol with lock manager %s"), _("Cannot use migrate v2 protocol with lock manager %s"),
virLockManagerPluginGetName(driver->lockManager)); virLockManagerPluginGetName(driver->lockManager));
goto cleanup; return -1;
} }
if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname))) if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname)))
goto cleanup; return -1;
if (virDomainMigratePrepare2EnsureACL(dconn, def) < 0) if (virDomainMigratePrepare2EnsureACL(dconn, def) < 0)
goto cleanup; return -1;
/* Do not use cookies in v2 protocol, since the cookie /* Do not use cookies in v2 protocol, since the cookie
* length was not sufficiently large, causing failures * length was not sufficiently large, causing failures
* migrating between old & new libvirtd * migrating between old & new libvirtd
*/ */
ret = qemuMigrationDstPrepareDirect(driver, dconn, return qemuMigrationDstPrepareDirect(driver, dconn,
NULL, 0, NULL, NULL, /* No cookies */ NULL, 0, NULL, NULL, /* No cookies */
uri_in, uri_out, uri_in, uri_out,
&def, origname, NULL, 0, NULL, 0, NULL, &def, origname, NULL, 0, NULL, 0, NULL,
migParams, flags); migParams, flags);
cleanup:
return ret;
} }
@ -11606,33 +11592,29 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn,
g_autoptr(virDomainDef) def = NULL; g_autoptr(virDomainDef) def = NULL;
g_autofree char *origname = NULL; g_autofree char *origname = NULL;
g_autoptr(qemuMigrationParams) migParams = NULL; g_autoptr(qemuMigrationParams) migParams = NULL;
int ret = -1;
virCheckFlags(QEMU_MIGRATION_FLAGS, -1); virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
if (!(flags & VIR_MIGRATE_TUNNELLED)) { if (!(flags & VIR_MIGRATE_TUNNELLED)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("PrepareTunnel called but no TUNNELLED flag set")); _("PrepareTunnel called but no TUNNELLED flag set"));
goto cleanup; return -1;
} }
if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags, if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags,
QEMU_MIGRATION_DESTINATION))) QEMU_MIGRATION_DESTINATION)))
goto cleanup; return -1;
if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname))) if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname)))
goto cleanup; return -1;
if (virDomainMigratePrepareTunnel3EnsureACL(dconn, def) < 0) if (virDomainMigratePrepareTunnel3EnsureACL(dconn, def) < 0)
goto cleanup; return -1;
ret = qemuMigrationDstPrepareTunnel(driver, dconn, return qemuMigrationDstPrepareTunnel(driver, dconn,
cookiein, cookieinlen, cookiein, cookieinlen,
cookieout, cookieoutlen, cookieout, cookieoutlen,
st, &def, origname, migParams, flags); st, &def, origname, migParams, flags);
cleanup:
return ret;
} }
static int static int
@ -11652,7 +11634,6 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn,
const char *dname = NULL; const char *dname = NULL;
g_autofree char *origname = NULL; g_autofree char *origname = NULL;
g_autoptr(qemuMigrationParams) migParams = NULL; g_autoptr(qemuMigrationParams) migParams = NULL;
int ret = -1;
virCheckFlags(QEMU_MIGRATION_FLAGS, -1); virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
if (virTypedParamsValidate(params, nparams, QEMU_MIGRATION_PARAMETERS) < 0) if (virTypedParamsValidate(params, nparams, QEMU_MIGRATION_PARAMETERS) < 0)
@ -11669,26 +11650,23 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn,
if (!(flags & VIR_MIGRATE_TUNNELLED)) { if (!(flags & VIR_MIGRATE_TUNNELLED)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("PrepareTunnel called but no TUNNELLED flag set")); _("PrepareTunnel called but no TUNNELLED flag set"));
goto cleanup; return -1;
} }
if (!(migParams = qemuMigrationParamsFromFlags(params, nparams, flags, if (!(migParams = qemuMigrationParamsFromFlags(params, nparams, flags,
QEMU_MIGRATION_DESTINATION))) QEMU_MIGRATION_DESTINATION)))
goto cleanup; return -1;
if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname))) if (!(def = qemuMigrationAnyPrepareDef(driver, NULL, dom_xml, dname, &origname)))
goto cleanup; return -1;
if (virDomainMigratePrepareTunnel3ParamsEnsureACL(dconn, def) < 0) if (virDomainMigratePrepareTunnel3ParamsEnsureACL(dconn, def) < 0)
goto cleanup; return -1;
ret = qemuMigrationDstPrepareTunnel(driver, dconn, return qemuMigrationDstPrepareTunnel(driver, dconn,
cookiein, cookieinlen, cookiein, cookieinlen,
cookieout, cookieoutlen, cookieout, cookieoutlen,
st, &def, origname, migParams, flags); st, &def, origname, migParams, flags);
cleanup:
return ret;
} }