]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: snapshot: Translate 'volume' disks before attempting offline snapshot manipulation
authorPeter Krempa <pkrempa@redhat.com>
Fri, 2 Jul 2021 14:00:05 +0000 (16:00 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 25 Aug 2021 13:48:25 +0000 (15:48 +0200)
When the VM is inactive the 'virStorageSource' struct doesn't have the
necessary data pointing to the actual storage. This is a problem for
inactive snapshot operations on VMs which use disk type='volume'.

Add the translation steps for reversion and deletion of snapshots.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1977155
Resolves: https://gitlab.com/libvirt/libvirt/-/issues/202
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_domain.c
src/qemu/qemu_snapshot.c

index 65c3394d9968764488e4a04b99ab6cae37587a0b..25b7f0320476e2f0ea2556bad9f952fa8dac7fd0 100644 (file)
@@ -7088,6 +7088,7 @@ qemuDomainSnapshotDiscard(virQEMUDriver *driver,
 
     if (!metadata_only) {
         if (!virDomainObjIsActive(vm)) {
+            size_t i;
             /* Ignore any skipped disks */
 
             /* Prefer action on the disks in use at the time the snapshot was
@@ -7098,6 +7099,11 @@ qemuDomainSnapshotDiscard(virQEMUDriver *driver,
             if (!def)
                 def = vm->def;
 
+            for (i = 0; i < def->ndisks; i++) {
+                if (virDomainDiskTranslateSourcePool(def->disks[i]) < 0)
+                    return -1;
+            }
+
             if (qemuDomainSnapshotForEachQcow2(driver, def, snap, "-d", true) < 0)
                 return -1;
         } else {
index 4e74ddd7f86c5bde3733f477a8f8bec970ae9c0d..fa1f9ce9733d0a1804250ad0adb3e4586cad9de7 100644 (file)
@@ -1813,6 +1813,8 @@ qemuSnapshotRevertInactive(virQEMUDriver *driver,
                            virDomainObj *vm,
                            virDomainMomentObj *snap)
 {
+    size_t i;
+
     /* Prefer action on the disks in use at the time the snapshot was
      * created; but fall back to current definition if dealing with a
      * snapshot created prior to libvirt 0.9.5.  */
@@ -1821,6 +1823,11 @@ qemuSnapshotRevertInactive(virQEMUDriver *driver,
     if (!def)
         def = vm->def;
 
+    for (i = 0; i < def->ndisks; i++) {
+        if (virDomainDiskTranslateSourcePool(def->disks[i]) < 0)
+            return -1;
+    }
+
     /* Try all disks, but report failure if we skipped any.  */
     if (qemuDomainSnapshotForEachQcow2(driver, def, snap, "-a", true) != 0)
         return -1;