]> git.ipfire.org Git - thirdparty/libvirt.git/commit
qemu_snapshot: fix detection if non-leaf snapshot isn't in active chain
authorPavel Hrdina <phrdina@redhat.com>
Tue, 30 Jan 2024 12:05:22 +0000 (13:05 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Tue, 30 Jan 2024 12:32:04 +0000 (13:32 +0100)
commit7143c4e1f95b4dc804f67cc5de98fba746193892
tree9e7643a919bd4fc339c748651a3cdbaa9e065eda
parent18f2bf0a43ab2154c9628245b3982e1a0184ab83
qemu_snapshot: fix detection if non-leaf snapshot isn't in active chain

The condition was completely wrong. As per the comment for function
virDomainMomentIsAncestor() it checks that the first argument is
descendant of the second argument.

Consider the following snapshot tree for VM:

  s1
    |
    +- s2
    |   |
    |   +- s3
    |
    +- s4
        |
        +- s5 (current)

When deleting s2 with the original code we checked if
virDomainMomentIsAncestor(s2, s5) which would return false basically for
any snapshot as s5 is leaf snapshot so no children.

When deleting s2 with fixed code we check if
virDomainMomentIsAncestor(s5, s2) which still returns false but when
deleting s4 it will correctly return true.

Before this fix it fails with the following error:

    error: Failed to delete snapshot s2
    error: invalid argument: could not find base disk source in disk source chain

After the fix it fails with correct error:

    error: Failed to delete snapshot s2
    error: unsupported configuration: deletion of non-leaf external snapshot that is not in active chain is not supported

Resolves: https://issues.redhat.com/browse/RHEL-23212
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/qemu/qemu_snapshot.c