mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 21:34:54 +03:00
qemu: driver: Move around code to avoid need to rollback
qemuDomainChangeDiskLive rolled back few changes to the disk definition if changing of the media failed. This can be avoided by moving some code around.
This commit is contained in:
parent
cab28101ee
commit
e78794c95f
@ -7655,8 +7655,6 @@ qemuDomainChangeDiskLive(virConnectPtr conn,
|
||||
{
|
||||
virDomainDiskDefPtr disk = dev->data.disk;
|
||||
virDomainDiskDefPtr orig_disk = NULL;
|
||||
int startupPolicy;
|
||||
int snapshot;
|
||||
int ret = -1;
|
||||
|
||||
if (virStorageTranslateDiskSourcePool(conn, disk) < 0)
|
||||
@ -7674,18 +7672,12 @@ qemuDomainChangeDiskLive(virConnectPtr conn,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
startupPolicy = orig_disk->startupPolicy;
|
||||
snapshot = orig_disk->snapshot;
|
||||
|
||||
switch ((virDomainDiskDevice) disk->device) {
|
||||
case VIR_DOMAIN_DISK_DEVICE_CDROM:
|
||||
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
|
||||
if (!qemuDomainDiskChangeSupported(disk, orig_disk))
|
||||
goto cleanup;
|
||||
|
||||
orig_disk->startupPolicy = dev->data.disk->startupPolicy;
|
||||
orig_disk->snapshot = dev->data.disk->snapshot;
|
||||
|
||||
if (qemuDomainDiskSourceDiffers(disk, orig_disk)) {
|
||||
/* Add the new disk src into shared disk hash table */
|
||||
if (qemuAddSharedDevice(driver, dev, vm->def->name) < 0)
|
||||
@ -7696,11 +7688,14 @@ qemuDomainChangeDiskLive(virConnectPtr conn,
|
||||
force) < 0) {
|
||||
ignore_value(qemuRemoveSharedDisk(driver, dev->data.disk,
|
||||
vm->def->name));
|
||||
goto rollback;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
dev->data.disk->src = NULL;
|
||||
}
|
||||
|
||||
orig_disk->startupPolicy = dev->data.disk->startupPolicy;
|
||||
orig_disk->snapshot = dev->data.disk->snapshot;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DISK_DEVICE_DISK:
|
||||
@ -7719,11 +7714,6 @@ qemuDomainChangeDiskLive(virConnectPtr conn,
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
|
||||
rollback:
|
||||
orig_disk->snapshot = snapshot;
|
||||
orig_disk->startupPolicy = startupPolicy;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
Reference in New Issue
Block a user