Guest fails to boot with qcow2 created from a original qcow2 with cache.direct=on
## Host environment - Operating system: Centos Stream 9 - OS/kernel version: Linux kernel 7.0.0 - Architecture: x86 - QEMU flavor: qemu-system-x86_64 - QEMU version: 11.0.50 (v11.0.0-1497-g2db9152854) ## Emulated/Virtualized environment - Operating system: Centos Stream 9 - OS/kernel version: Linux kernel 7.0.0 - Architecture: x86 ## Description of problem Guest fails to boot with qcow2 created from a original qcow2 with cache.direct=on, I/O error before guest OS login. And error log found in host dmesg. No such issue when set cache.direct=off. ## Steps to reproduce 1. Prepare a image in qcow2 format, create a new qcow2 based on this original qcow2. ``` qemu-img create -b centos9.qcow2 -F qcow2 -f qcow2 centos9_2.qcow2 ``` 2. Boot VM with the new qcow2 with cache.direct=on ``` img=/home/test/centos9_2.qcow2 /home/qemu/build/qemu-system-x86_64 \ -name tdxvm,process=tdxvm,debug-threads=on \ -accel kvm \ -m 8G \ -smp 8 \ -cpu host \ -monitor telnet:127.0.0.1:45454,nowait,server \ -vga none \ -nodefaults -nographic \ -machine q35,kernel_irqchip=split \ -device pcie-root-port,id=pcie-root-port-0,multifunction=on,bus=pcie.0,addr=0x1,chassis=1 \ -device pcie-pci-bridge,id=pcie-pci-bridge-0,addr=0x0,bus=pcie-root-port-0 \ -blockdev node-name=file_image1,driver=file,filename=$img,cache.direct=on,cache.no-flush=off \ -blockdev node-name=drive_image1,driver=qcow2,cache.direct=on,cache.no-flush=off,file=file_image1 \ -device pcie-root-port,id=pcie-root-port-1,port=0x1,addr=0x1.0x1,bus=pcie.0,chassis=2 \ -device virtio-blk-pci,id=image1,drive=drive_image1,write-cache=on,bus=pcie-root-port-1,addr=0x0 \ -serial stdio ``` ## Additional information ``` Error log: IO error before guest OS login: [ OK ] Reached target Basic System. Starting dracut pre-mount hook... [ OK ] Finished dracut pre-mount hook. Starting File System Check on /dev…1c94-8b60-4af9-9409-4de76541f7ba... [ OK ] Finished File System Check on /dev…121c94-8b60-4af9-9409-4de76541f7ba. Mounting /sysroot... [ 3.235400] XFS (vda4): Mounting V5 Filesystem 68121c94-8b60-4af9-9409-4de76541f7ba [ 3.314335] I/O error, dev vda, sector 11852571 op 0x1:(WRITE) flags 0x1800 phys_seg 1 prio class 2 [ 3.315191] XFS (vda4): log recovery write I/O error at daddr 0x1b6eb len 4096 error -5 [ 3.315884] XFS (vda4): failed to locate log tail [ 3.316354] XFS (vda4): log mount/recovery failed: error -5 [ 3.317308] XFS (vda4): log mount failed [FAILED] Failed to mount /sysroot. See 'systemctl status sysroot.mount' for details. [DEPEND] Dependency failed for Initrd Root File System. [DEPEND] Dependency failed for Mountpoints Configured in the Real Root. [ OK ] Stopped target Basic System. [ OK ] Reached target Initrd File Systems. [ OK ] Stopped target System Initialization. [ OK ] Stopped dracut pre-mount hook. [ OK ] Stopped dracut initqueue hook. [ OK ] Stopped dracut pre-trigger hook. [ OK ] Stopped dracut pre-udev hook. [ OK ] Stopped dracut cmdline hook. [ OK ] Started Emergency Shell. [ OK ] Reached target Emergency Mode. Generating "/run/initramfs/rdsosreport.txt" Entering emergency mode. Exit the shell to continue. Type "journalctl" to view system logs. You might want to save "/run/initramfs/rdsosreport.txt" to a USB stick or /boot after mounting them and attach it to a bug report. :/# ``` Host dmesg: ``` [  194.316580] iommu: unaligned: iova 0xecdee200 pa 0x00000001ce800000 size 0x12000 min_pagesz 0x1000 [  194.326730] iommu: unaligned: iova 0xf4cae200 pa 0x00000001ce800000 size 0x12000 min_pagesz 0x1000 [  194.336861] invalid error, dev nvme0n1, sector 527681736 op 0x1:(WRITE) flags 0xc800 phys_seg 16 prio class 2 ```
issue