[libvirt PATCH v3 07/10] qemu_snapshot: fix reverting external snapshot when not all disks are included

Pavel Hrdina posted 10 patches 5 months, 1 week ago
[libvirt PATCH v3 07/10] qemu_snapshot: fix reverting external snapshot when not all disks are included
Posted by Pavel Hrdina 5 months, 1 week ago
We need to skip all disks that have snapshot type other than 'external'.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 src/qemu/qemu_snapshot.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index cdc8e12cff..44bd97e564 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -2054,6 +2054,9 @@ qemuSnapshotRevertExternalPrepare(virDomainObj *vm,
         virDomainSnapshotDiskDef *snapdisk = &tmpsnapdef->disks[i];
         virDomainDiskDef *domdisk = domdef->disks[i];
 
+        if (snapdisk->snapshot != VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL)
+            continue;
+
         if (qemuSnapshotPrepareDiskExternal(domdisk, snapdisk, active, false) < 0)
             return -1;
     }
@@ -2094,6 +2097,9 @@ qemuSnapshotRevertExternalActive(virDomainObj *vm,
         return -1;
 
     for (i = 0; i < tmpsnapdef->ndisks; i++) {
+        if (tmpsnapdef->disks[i].snapshot != VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL)
+            continue;
+
         if (qemuSnapshotDiskPrepareOne(snapctxt,
                                        vm->def->disks[i],
                                        tmpsnapdef->disks + i,
@@ -2184,6 +2190,9 @@ qemuSnapshotRevertExternalFinish(virDomainObj *vm,
         for (i = 0; i < curdef->nrevertdisks; i++) {
             virDomainSnapshotDiskDef *snapdisk = &(curdef->revertdisks[i]);
 
+            if (snapdisk->snapshot != VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL)
+                continue;
+
             if (virStorageSourceInit(snapdisk->src) < 0 ||
                 virStorageSourceUnlink(snapdisk->src) < 0) {
                 VIR_WARN("Failed to remove snapshot image '%s'",
@@ -2199,6 +2208,9 @@ qemuSnapshotRevertExternalFinish(virDomainObj *vm,
         for (i = 0; i < curdef->ndisks; i++) {
             virDomainSnapshotDiskDef *snapdisk = &(curdef->disks[i]);
 
+            if (snapdisk->snapshot != VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL)
+                continue;
+
             if (virStorageSourceInit(snapdisk->src) < 0 ||
                 virStorageSourceUnlink(snapdisk->src) < 0) {
                 VIR_WARN("Failed to remove snapshot image '%s'",
-- 
2.41.0