Snapshot are deleted from disk image but not from libvirt snapshot files
Software environment
- Operating system: Gentoo Linux
- Architecture: AMD64
- kernel version: 5.9.12-gentoo-x86_64
- libvirt version: app-emulation/libvirt-6.10.0-r1
- Hypervisor and version: app-emulation/virt-manager-3.2.0
Description of problem
When I use virsh or virt-manager to remove a snapshot, it is not removed from a libvirt or virt-manager point of view, but it is from qemu-img point of view.
Steps to reproduce
Sorry, my system is in French.
- Check that a snapshot is present
# ls -l /var/lib/libvirt/qemu/snapshot/KaliLinux/Initial.xml
-rw------- 1 root root 4941 8 déc. 23:29 /var/lib/libvirt/qemu/snapshot/KaliLinux/Initial.xml
# /usr/bin/qemu-img snapshot -l /var/lib/libvirt/images/KaliLinux.qcow2
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
1 Initial 0 B 2020-12-08 23:29:50 00:00:00.000
# virsh snapshot-list --domain KaliLinux
Nom Creation Time État
------------------------------------------------
Initial 2020-12-08 23:29:50 +0100 shutoff
- Try to remove it with virsh
# virsh snapshot-delete --domain KaliLinux --snapshotname Initial
Domain snapshot Initial deleted
- Check if it is really removed (only removed from qemu-img point of view)
# virsh snapshot-list --domain KaliLinux
Nom Creation Time État
------------------------------------------------
Initial 2020-12-08 23:29:50 +0100 shutoff
# /usr/bin/qemu-img snapshot -l /var/lib/libvirt/images/KaliLinux.qcow2
- Try to create a new snapshot (because you supposed that it was from virsh point of view, and did not checked from qemu-img point of view), here is the issue (error from virsh point of view, no new snapshot from qemu-img point of view)
# virsh snapshot-create-as --domain KaliLinux --name Initial --description 'Instantanné initial de cette machine virtuelle.'
erreur :opération échouée : domain moment Initial already exists
# /usr/bin/qemu-img snapshot -l /var/lib/libvirt/images/KaliLinux.qcow2
Additional information
If you want a temporary workaround to really remove the snapshot and take a new one here are the steps (to beperformed after step 4. in this report).
- Remove snapshot file from libvirt and restart libvirtd service (and check everything is ok from livbvirt point of view)
# rm /var/lib/libvirt/qemu/snapshot/KaliLinux/Initial.xml
# systemctl restart libvirtd.service
# virsh snapshot-list --domain KaliLinux
Nom Creation Time État
-----------------------------
- Create the new snapshot with virsh (and check everything is ok from libvirt and qemu-img point of view)
# virsh snapshot-create-as --domain KaliLinux --name Initial --description 'Instantanné initial de cette machine virtuelle.'
L'instantané du domaine Initial a été créé
# virsh snapshot-list --domain KaliLinux
Nom Creation Time État
------------------------------------------------
Initial 2020-12-09 08:38:54 +0100 shutoff
# /usr/bin/qemu-img snapshot -l /var/lib/libvirt/images/KaliLinux.qcow2
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
1 Initial 0 B 2020-12-09 08:38:54 00:00:00.000
# ls -l /var/lib/libvirt/qemu/snapshot/KaliLinux/Initial.xml
-rw------- 1 root root 4941 9 déc. 08:38 /var/lib/libvirt/qemu/snapshot/KaliLinux/Initial.xml
Edited by Julien Delquié