[PATCH] qemu: Fix logic bug in inactive snapshot deletion

Peter Krempa posted 1 patch 3 years, 4 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/b2ff52509d4c11ab52b5891a3a3a957dbceb4c73.1607505354.git.pkrempa@redhat.com
src/qemu/qemu_domain.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] qemu: Fix logic bug in inactive snapshot deletion
Posted by Peter Krempa 3 years, 4 months ago
Commit 926563dc3a6 which refactored the function call deleting the
snapshot's on disk state introduced a logic bug, which skips over the
deletion of libvirt metadata after the disk state deletion is done.

To fix it we must not return early.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/109
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 src/qemu/qemu_domain.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index d6fded9dd1..1af1e4dac8 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -6667,7 +6667,8 @@ qemuDomainSnapshotDiscard(virQEMUDriverPtr driver,
             if (!def)
                 def = vm->def;

-            return qemuDomainSnapshotForEachQcow2(driver, def, snap, "-d", true);
+            if (qemuDomainSnapshotForEachQcow2(driver, def, snap, "-d", true) < 0)
+                return -1;
         } else {
             priv = vm->privateData;
             qemuDomainObjEnterMonitor(driver, vm);
-- 
2.29.2

Re: [PATCH] qemu: Fix logic bug in inactive snapshot deletion
Posted by Erik Skultety 3 years, 4 months ago
On Wed, Dec 09, 2020 at 10:15:54AM +0100, Peter Krempa wrote:
> Commit 926563dc3a6 which refactored the function call deleting the
> snapshot's on disk state introduced a logic bug, which skips over the
> deletion of libvirt metadata after the disk state deletion is done.
> 
> To fix it we must not return early.
> 
> Resolves: https://gitlab.com/libvirt/libvirt/-/issues/109
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
Reviewed-by: Erik Skultety <eskultet@redhat.com>