mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +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)
|
virDomainDiskDef *disk)
|
||||||
{
|
{
|
||||||
g_autoptr(qemuBlockStorageSourceChainData) data = NULL;
|
g_autoptr(qemuBlockStorageSourceChainData) data = NULL;
|
||||||
int ret = -1;
|
|
||||||
qemuDomainObjPrivate *priv = vm->privateData;
|
qemuDomainObjPrivate *priv = vm->privateData;
|
||||||
g_autofree char *devstr = NULL;
|
g_autofree char *devstr = NULL;
|
||||||
bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
|
bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
|
||||||
|
|
||||||
if (virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_VHOST_USER) {
|
if (virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_VHOST_USER) {
|
||||||
if (!(data = qemuBuildStorageSourceChainAttachPrepareChardev(disk)))
|
if (!(data = qemuBuildStorageSourceChainAttachPrepareChardev(disk)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
} else if (blockdev) {
|
} else if (blockdev) {
|
||||||
if (!(data = qemuBuildStorageSourceChainAttachPrepareBlockdev(disk->src,
|
if (!(data = qemuBuildStorageSourceChainAttachPrepareBlockdev(disk->src,
|
||||||
priv->qemuCaps)))
|
priv->qemuCaps)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (disk->copy_on_read == VIR_TRISTATE_SWITCH_ON) {
|
if (disk->copy_on_read == VIR_TRISTATE_SWITCH_ON) {
|
||||||
if (!(data->copyOnReadProps = qemuBlockStorageGetCopyOnReadProps(disk)))
|
if (!(data->copyOnReadProps = qemuBlockStorageGetCopyOnReadProps(disk)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
data->copyOnReadNodename = g_strdup(QEMU_DOMAIN_DISK_PRIVATE(disk)->nodeCopyOnRead);
|
data->copyOnReadNodename = g_strdup(QEMU_DOMAIN_DISK_PRIVATE(disk)->nodeCopyOnRead);
|
||||||
}
|
}
|
||||||
@ -719,14 +718,14 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver,
|
|||||||
} else {
|
} else {
|
||||||
if (!(data = qemuBuildStorageSourceChainAttachPrepareDrive(disk,
|
if (!(data = qemuBuildStorageSourceChainAttachPrepareDrive(disk,
|
||||||
priv->qemuCaps)))
|
priv->qemuCaps)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(devstr = qemuBuildDiskDeviceStr(vm->def, disk, priv->qemuCaps)))
|
if (!(devstr = qemuBuildDiskDeviceStr(vm->def, disk, priv->qemuCaps)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuHotplugAttachManagedPR(driver, vm, disk->src, QEMU_ASYNC_JOB_NONE) < 0)
|
if (qemuHotplugAttachManagedPR(driver, vm, disk->src, QEMU_ASYNC_JOB_NONE) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
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);
|
VIR_WARN("failed to set blkdeviotune for '%s' of '%s'", disk->dst, vm->def->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0) {
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
ret = -2;
|
return -2;
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
exit_monitor:
|
exit_monitor:
|
||||||
qemuBlockStorageSourceChainDetach(priv->mon, data);
|
qemuBlockStorageSourceChainDetach(priv->mon, data);
|
||||||
|
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
ret = -2;
|
return -2;
|
||||||
|
|
||||||
if (virStorageSourceChainHasManagedPR(disk->src) &&
|
if (virStorageSourceChainHasManagedPR(disk->src) &&
|
||||||
qemuHotplugRemoveManagedPR(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
|
qemuHotplugRemoveManagedPR(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
|
||||||
ret = -2;
|
return -2;
|
||||||
|
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user