mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 05:17:59 +03:00
qemuDomainAttachDiskGeneric: Move setup of disk into qemuDomainAttachDeviceDiskLiveInternal
qemuDomainAttachDeviceDiskLiveInternal already sets up certain pieces of the disk definition so it's better suited to move the setup of the virStorageSource structs, granting access to the storage and allocation of the alias from qemuDomainAttachDiskGeneric which will be just handling the qemu interaction. 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
f5542ae014
commit
52f8655439
@ -699,17 +699,8 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
qemuDomainObjPrivate *priv = vm->privateData;
|
qemuDomainObjPrivate *priv = vm->privateData;
|
||||||
g_autofree char *devstr = NULL;
|
g_autofree char *devstr = NULL;
|
||||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
|
||||||
bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
|
bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
|
||||||
|
|
||||||
if (qemuDomainStorageSourceChainAccessAllow(driver, vm, disk->src) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (qemuAssignDeviceDiskAlias(vm->def, disk, priv->qemuCaps) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (qemuDomainPrepareDiskSource(disk, priv, cfg) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
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)))
|
||||||
@ -778,9 +769,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriver *driver,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (ret < 0)
|
|
||||||
ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, vm, disk->src));
|
|
||||||
qemuDomainSecretDiskDestroy(disk);
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
exit_monitor:
|
exit_monitor:
|
||||||
@ -937,11 +925,13 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
|
|||||||
virDomainObj *vm,
|
virDomainObj *vm,
|
||||||
virDomainDeviceDef *dev)
|
virDomainDeviceDef *dev)
|
||||||
{
|
{
|
||||||
|
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
||||||
qemuDomainObjPrivate *priv = vm->privateData;
|
qemuDomainObjPrivate *priv = vm->privateData;
|
||||||
size_t i;
|
size_t i;
|
||||||
virDomainDiskDef *disk = dev->data.disk;
|
virDomainDiskDef *disk = dev->data.disk;
|
||||||
bool releaseUSB = false;
|
bool releaseUSB = false;
|
||||||
bool releaseVirtio = false;
|
bool releaseVirtio = false;
|
||||||
|
bool releaseSeclabel = false;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM ||
|
if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM ||
|
||||||
@ -1037,6 +1027,17 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
|
|||||||
virDomainDiskBusTypeToString(disk->bus));
|
virDomainDiskBusTypeToString(disk->bus));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (qemuDomainStorageSourceChainAccessAllow(driver, vm, disk->src) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
releaseSeclabel = true;
|
||||||
|
|
||||||
|
if (qemuAssignDeviceDiskAlias(vm->def, disk, priv->qemuCaps) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (qemuDomainPrepareDiskSource(disk, priv, cfg) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
ret = qemuDomainAttachDiskGeneric(driver, vm, disk);
|
ret = qemuDomainAttachDiskGeneric(driver, vm, disk);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -1048,7 +1049,11 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
|
|||||||
|
|
||||||
if (releaseVirtio && ret == -1)
|
if (releaseVirtio && ret == -1)
|
||||||
qemuDomainReleaseDeviceAddress(vm, &disk->info);
|
qemuDomainReleaseDeviceAddress(vm, &disk->info);
|
||||||
|
|
||||||
|
if (releaseSeclabel)
|
||||||
|
ignore_value(qemuDomainStorageSourceChainAccessRevoke(driver, vm, disk->src));
|
||||||
}
|
}
|
||||||
|
qemuDomainSecretDiskDestroy(disk);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user