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(a)redhat.com>
---
src/qemu/qemu_snapshot.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index 1962ba4027..5fc0b82e79 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -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 (qemuSnapshotCreateQcow2Files(driver, domdef, tmpsnapdef, created) < 0)
+ goto cleanup;
+
if (qemuSnapshotDomainDefUpdateDisk(domdef, tmpsnapdef, false) < 0)
- return -1;
+ goto cleanup;
- if (qemuSnapshotCreateQcow2Files(driver, domdef, tmpsnapdef, created) < 0) {
+ 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;
}
--
2.41.0