[PATCH] qemu: snapshot: Translate 'volume' disks before attempting offline snapshot manipulation

Peter Krempa posted 1 patch 2 years, 8 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/5b0405d89bef373b80115072210796530d99959c.1629897778.git.pkrempa@redhat.com
src/qemu/qemu_domain.c   | 6 ++++++
src/qemu/qemu_snapshot.c | 7 +++++++
2 files changed, 13 insertions(+)
[PATCH] qemu: snapshot: Translate 'volume' disks before attempting offline snapshot manipulation
Posted by Peter Krempa 2 years, 8 months ago
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>
---
 src/qemu/qemu_domain.c   | 6 ++++++
 src/qemu/qemu_snapshot.c | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 50a921c80d..962343cb2d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -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 {
diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index 4e74ddd7f8..fa1f9ce973 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -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;
-- 
2.31.1

Re: [PATCH] qemu: snapshot: Translate 'volume' disks before attempting offline snapshot manipulation
Posted by Ján Tomko 2 years, 8 months ago
On a Wednesday in 2021, Peter Krempa wrote:
>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>
>---
> src/qemu/qemu_domain.c   | 6 ++++++
> src/qemu/qemu_snapshot.c | 7 +++++++
> 2 files changed, 13 insertions(+)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano