mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
qemu_snapshot: fix reverting to inactive snapshot
When reverting to inactive snapshot updating the domain definition needs to happen after the new overlays are created otherwise qemu-img will correctly fail with error: Trying to create an image with the same filename as the backing file Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
03a9a39c42
commit
3ad5817053
@ -2157,13 +2157,20 @@ qemuSnapshotRevertExternalInactive(virDomainObj *vm,
|
||||
{
|
||||
virQEMUDriver *driver = QEMU_DOMAIN_PRIVATE(vm)->driver;
|
||||
g_autoptr(virBitmap) created = NULL;
|
||||
int ret = -1;
|
||||
|
||||
created = virBitmapNew(tmpsnapdef->ndisks);
|
||||
|
||||
if (qemuSnapshotDomainDefUpdateDisk(domdef, tmpsnapdef, false) < 0)
|
||||
return -1;
|
||||
if (qemuSnapshotCreateQcow2Files(driver, domdef, tmpsnapdef, created) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (qemuSnapshotCreateQcow2Files(driver, domdef, tmpsnapdef, created) < 0) {
|
||||
if (qemuSnapshotDomainDefUpdateDisk(domdef, tmpsnapdef, false) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
if (ret < 0 && created) {
|
||||
ssize_t bit = -1;
|
||||
virErrorPtr err = NULL;
|
||||
|
||||
@ -2180,11 +2187,9 @@ qemuSnapshotRevertExternalInactive(virDomainObj *vm,
|
||||
}
|
||||
|
||||
virErrorRestore(&err);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user