Description of problem: cannot delete snapshot when one of the disk's snapshot mode is 'manual' Version-Release number of selected component (if applicable): libvirt-9.0.0-7.el9.x86_64 How reproducible: 100% Steps to Reproduce: 1.have a running vm with two disks [root@dell-per740-41 ~]# virsh domstate vm1 running [root@dell-per740-41 ~]# virsh domblklist vm1 Target Source --------------------------------------------- vda /var/lib/libvirt/images/vm1.qcow2 vdb /var/lib/libvirt/images/vdb.qcow2 2. prepare a snapshot xml, in which the vda's snapshot mode is 'manual' [root@dell-per740-41 ~]# cat snap.xml <domainsnapshot> <description>Snapshot test</description> <name>snap1</name> <memory snapshot='external' file='/tmp/mem.dump'/> <disks> <disk name='vda' snapshot='manual'/> <disk name='vdb' snapshot='external'/> </disks> </domainsnapshot> 3. do the snapshot [root@dell-per740-41 ~]# virsh snapshot-create vm1 snap.xml Domain snapshot snap1 created from 'snap.xml' now the vm is moved to PAUSED state, vda's path not chaged, and vdb has a new image layer 'vdb.snap1' [root@dell-per740-41 ~]# virsh domstate vm1 paused [root@dell-per740-41 ~]# virsh domblklist vm1 Target Source --------------------------------------------- vda /var/lib/libvirt/images/vm1.qcow2 vdb /var/lib/libvirt/images/vdb.snap1 4. delete the snapshot [root@dell-per740-41 ~]# virsh snapshot-delete vm1 snap1 error: Failed to delete snapshot snap1 error: invalid argument: could not find base disk source in disk source chain [root@dell-per740-41 ~]# virsh resume vm1 Domain 'vm1' resumed [root@dell-per740-41 ~]# virsh snapshot-delete vm1 snap1 error: Failed to delete snapshot snap1 error: invalid argument: could not find base disk source in disk source chain Actual results: snapshot cannot be removed if one of the disk has 'manual' mode for snapshot Expected results: libvirt should remove the snapshot data which is maintained by libvirt, such as the memory dump, vdb's new layer and snapshot's metadata Additional info: if vda's snapshot mode is 'no' then it works.
Upstream commit: commit 22a07239f5ea3d3ccd8a057cf83dcc09d6b7b0f0 Author: Pavel Hrdina <phrdina> Date: Wed Mar 1 12:51:21 2023 +0100 qemu_snapshot: properly ignore disks with manual snapshot
Preverified with:libvirt-9.2.0-1.el9.x86_64 [root@lenovo-sr630-14 ~]# virsh start vm1 Domain 'vm1' started [root@lenovo-sr630-14 ~]# virsh domblklist vm1 Target Source -------------------------------------------------------- vda /var/lib/libvirt/images/jeos-27-x86_64.qcow2 vdb /var/lib/libvirt/images/vdb.qcow2 [root@lenovo-sr630-14 ~]# vim snap.xml <domainsnapshot> <description>Snapshot test</description> <name>snap1</name> <memory snapshot='external' file='/tmp/mem.dump'/> <disks> <disk name='vda' snapshot='manual'/> <disk name='vdb' snapshot='external'/> </disks> </domainsnapshot> [root@lenovo-sr630-14 ~]# virsh snapshot-create vm1 snap.xml Domain snapshot snap1 created from 'snap.xml' [root@lenovo-sr630-14 ~]# virsh domstate vm1 paused [root@lenovo-sr630-14 ~]# virsh domblklist vm1 Target Source -------------------------------------------------------- vda /var/lib/libvirt/images/jeos-27-x86_64.qcow2 vdb /var/lib/libvirt/images/vdb.snap1 [root@lenovo-sr630-14 ~]# virsh dumpxml vm1 --xpath //disk <disk type="file" device="disk"> <driver name="qemu" type="qcow2"/> <source file="/var/lib/libvirt/images/jeos-27-x86_64.qcow2" index="2"/> <backingStore/> <target dev="vda" bus="virtio"/> <alias name="virtio-disk0"/> <address type="pci" domain="0x0000" bus="0x04" slot="0x00" function="0x0"/> </disk> <disk type="file" device="disk"> <driver name="qemu" type="qcow2"/> <source file="/var/lib/libvirt/images/vdb.snap1" index="3"/> <backingStore type="file" index="1"> <format type="qcow2"/> <source file="/var/lib/libvirt/images/vdb.qcow2"/> <backingStore/> </backingStore> <target dev="vdb" bus="virtio"/> <alias name="virtio-disk1"/> <address type="pci" domain="0x0000" bus="0x07" slot="0x00" function="0x0"/> </disk> [root@lenovo-sr630-14 ~]# virsh snapshot-delete vm1 snap1 error: Failed to delete snapshot snap1 error: internal error: unable to execute QEMU command 'block-commit': Block node is read-only [root@lenovo-sr630-14 ~]# virsh resume vm1 Domain 'vm1' resumed [root@lenovo-sr630-14 ~]# virsh snapshot-delete vm1 snap1 Domain snapshot snap1 deleted [root@lenovo-sr630-14 ~]# virsh domblklist vm1 Target Source -------------------------------------------------------- vda /var/lib/libvirt/images/jeos-27-x86_64.qcow2 vdb /var/lib/libvirt/images/vdb.qcow2 [root@lenovo-sr630-14 ~]# virsh dumpxml vm1 --xpath //disk <disk type="file" device="disk"> <driver name="qemu" type="qcow2"/> <source file="/var/lib/libvirt/images/jeos-27-x86_64.qcow2" index="2"/> <backingStore/> <target dev="vda" bus="virtio"/> <alias name="virtio-disk0"/> <address type="pci" domain="0x0000" bus="0x04" slot="0x00" function="0x0"/> </disk> <disk type="file" device="disk"> <driver name="qemu" type="qcow2"/> <source file="/var/lib/libvirt/images/vdb.qcow2" index="1"/> <backingStore/> <target dev="vdb" bus="virtio"/> <alias name="virtio-disk1"/> <address type="pci" domain="0x0000" bus="0x07" slot="0x00" function="0x0"/> </disk>
test with libvirt-9.3.0-2.el9.x86_64 and result is PASS