mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 09:17:52 +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 disk = dev->data.disk;
|
||||||
virDomainDiskDefPtr orig_disk = NULL;
|
virDomainDiskDefPtr orig_disk = NULL;
|
||||||
int startupPolicy;
|
|
||||||
int snapshot;
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (virStorageTranslateDiskSourcePool(conn, disk) < 0)
|
if (virStorageTranslateDiskSourcePool(conn, disk) < 0)
|
||||||
@ -7674,18 +7672,12 @@ qemuDomainChangeDiskLive(virConnectPtr conn,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
startupPolicy = orig_disk->startupPolicy;
|
|
||||||
snapshot = orig_disk->snapshot;
|
|
||||||
|
|
||||||
switch ((virDomainDiskDevice) disk->device) {
|
switch ((virDomainDiskDevice) disk->device) {
|
||||||
case VIR_DOMAIN_DISK_DEVICE_CDROM:
|
case VIR_DOMAIN_DISK_DEVICE_CDROM:
|
||||||
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
|
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
|
||||||
if (!qemuDomainDiskChangeSupported(disk, orig_disk))
|
if (!qemuDomainDiskChangeSupported(disk, orig_disk))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
orig_disk->startupPolicy = dev->data.disk->startupPolicy;
|
|
||||||
orig_disk->snapshot = dev->data.disk->snapshot;
|
|
||||||
|
|
||||||
if (qemuDomainDiskSourceDiffers(disk, orig_disk)) {
|
if (qemuDomainDiskSourceDiffers(disk, orig_disk)) {
|
||||||
/* Add the new disk src into shared disk hash table */
|
/* Add the new disk src into shared disk hash table */
|
||||||
if (qemuAddSharedDevice(driver, dev, vm->def->name) < 0)
|
if (qemuAddSharedDevice(driver, dev, vm->def->name) < 0)
|
||||||
@ -7696,11 +7688,14 @@ qemuDomainChangeDiskLive(virConnectPtr conn,
|
|||||||
force) < 0) {
|
force) < 0) {
|
||||||
ignore_value(qemuRemoveSharedDisk(driver, dev->data.disk,
|
ignore_value(qemuRemoveSharedDisk(driver, dev->data.disk,
|
||||||
vm->def->name));
|
vm->def->name));
|
||||||
goto rollback;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev->data.disk->src = NULL;
|
dev->data.disk->src = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
orig_disk->startupPolicy = dev->data.disk->startupPolicy;
|
||||||
|
orig_disk->snapshot = dev->data.disk->snapshot;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_DISK_DEVICE_DISK:
|
case VIR_DOMAIN_DISK_DEVICE_DISK:
|
||||||
@ -7719,11 +7714,6 @@ qemuDomainChangeDiskLive(virConnectPtr conn,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
rollback:
|
|
||||||
orig_disk->snapshot = snapshot;
|
|
||||||
orig_disk->startupPolicy = startupPolicy;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user