mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
qemuDomainAttachDiskGeneric: Refactor cleanup
Remove the 'ret' variable and 'cleanup' label in favor of directly returning the value since we don't have anything under the 'cleanup:' label. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
26a10ddeff
commit
b01e701a01
@ -696,22 +696,21 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver,
|
||||
virDomainDiskDef *disk)
|
||||
{
|
||||
g_autoptr(qemuBlockStorageSourceChainData) data = NULL;
|
||||
int ret = -1;
|
||||
qemuDomainObjPrivate *priv = vm->privateData;
|
||||
g_autofree char *devstr = NULL;
|
||||
bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
|
||||
|
||||
if (virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_VHOST_USER) {
|
||||
if (!(data = qemuBuildStorageSourceChainAttachPrepareChardev(disk)))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
} else if (blockdev) {
|
||||
if (!(data = qemuBuildStorageSourceChainAttachPrepareBlockdev(disk->src,
|
||||
priv->qemuCaps)))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (disk->copy_on_read == VIR_TRISTATE_SWITCH_ON) {
|
||||
if (!(data->copyOnReadProps = qemuBlockStorageGetCopyOnReadProps(disk)))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
data->copyOnReadNodename = g_strdup(QEMU_DOMAIN_DISK_PRIVATE(disk)->nodeCopyOnRead);
|
||||
}
|
||||
@ -719,14 +718,14 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver,
|
||||
} else {
|
||||
if (!(data = qemuBuildStorageSourceChainAttachPrepareDrive(disk,
|
||||
priv->qemuCaps)))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(devstr = qemuBuildDiskDeviceStr(vm->def, disk, priv->qemuCaps)))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qemuHotplugAttachManagedPR(driver, vm, disk->src, QEMU_ASYNC_JOB_NONE) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
qemuDomainObjEnterMonitor(driver, vm);
|
||||
|
||||
@ -756,27 +755,22 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver,
|
||||
VIR_WARN("failed to set blkdeviotune for '%s' of '%s'", disk->dst, vm->def->name);
|
||||
}
|
||||
|
||||
if (qemuDomainObjExitMonitor(driver, vm) < 0) {
|
||||
ret = -2;
|
||||
goto cleanup;
|
||||
}
|
||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||
return -2;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
|
||||
exit_monitor:
|
||||
qemuBlockStorageSourceChainDetach(priv->mon, data);
|
||||
|
||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||
ret = -2;
|
||||
return -2;
|
||||
|
||||
if (virStorageSourceChainHasManagedPR(disk->src) &&
|
||||
qemuHotplugRemoveManagedPR(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
|
||||
ret = -2;
|
||||
return -2;
|
||||
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user