Libvirt should disallow the blockcopy for raw format deest image with discard_no_unref='on'
Software environment
- Operating system: Fedora rawhide
- Architecture: x86_64
- kernel version: kernel-6.5.0-0.rc2.20230721gitf7e3a1bafdea.20.fc39.x86_64
- libvirt version: v9.5.0-91-g6c3ef66c
- Hypervisor and version: qemu-8.1.0-rc0
Description of problem
Do blockcopy for raw format destination image with discard_no_unref='on'. The blockcopy sucesseds.
Steps to reproduce
- Prepare a running guest with this disk
<disk type="file" device="disk">
<driver name="qemu" type="qcow2" cache="none" io="io_uring" copy_on_read="on" discard="unmap" detect_zeroes="on" discard_no_unref="on">
<metadata_cache>
<max_size unit="bytes">1234</max_size>
</metadata_cache>
</driver>
<source file="/var/lib/libvirt/images/rhel8.qcow2" index="1"/>
<backingStore/>
<target dev="sda" bus="sata"/>
<alias name="sata0-0-0"/>
<address type="drive" controller="0" bus="0" target="0" unit="0"/>
</disk>
- Do blockcopy with the dest disk XML of type="raw" and detect_zeroes="on":
<disk type="file" device="disk">
<driver name="qemu" type="raw" cache="none" io="io_uring" copy_on_read="on" discard="unmap" detect_zeroes="on" discard_no_unref="on">
</driver>
<source file="/var/lib/libvirt/images/rhel8.clone" index="1"/>
<backingStore/>
<target dev="sda" bus="sata"/>
<alias name="sata0-0-0"/>
<address type="drive" controller="0" bus="0" target="0" unit="0"/>
</disk>
# virsh blockcopy 1 sda --xml /tmp/disk.xml --transient-job --reuse-external Block Copy started # virsh blockjob 1 sda --pivot
# virsh dumpxml 1 --xpath //disk
<disk type="file" device="disk">
<driver name="qemu" type="raw" cache="none" io="io_uring" copy_on_read="on" discard="unmap" detect_zeroes="on" discard_no_unref="on"/>
<source file="/var/lib/libvirt/images/rhel8.clone" index="6"/>
<backingStore/>
<target dev="sda" bus="sata"/>
<alias name="sata0-0-0"/>
<address type="drive" controller="0" bus="0" target="0" unit="0"/>
</disk>
As we know, the detect_zeroes is only for qcow2 format. So libvirt should disallow blockcopt for raw image with detect_zeroes.