Skip to content

qemu-7.2: virtio-blk-pci I/O errors with detect-zeroes=unmap

Host environment

  • Operating system: Debian-11.6 (amd64)
  • OS/kernel version: 6.0.0-0.deb11.2-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.0.3-1~bpo11+1 (2022-10-29) x86_64 GNU/Linux
  • Architecture: x86_64
  • QEMU flavor: qemu-system-x86_64
  • QEMU version: 7.2.0
  • QEMU command line:
    qemu-system-x86_64 -machine q35 -enable-kvm -cpu kvm64 -smp 2 -m 1024 \
         -drive if=none,media=disk,id=drive-0be1d180e4d3,file=deb11.img,cache=writeback,discard=unmap,detect-zeroes=unmap \
         -device virtio-blk-pci,drive=drive-0be1d180e4d3,bootindex=0

Emulated/Virtualized environment

  • Operating system:
  • OS/kernel version:
  • Architecture:

Description of problem

Since upgrading from qemu-7.1 to qemu-7.2 I have seen many anomalies with VMs that use the virtio-blk-pci device for the root filesystem and the detect-zeroes=unmap option, typically in the form of I/O errors or huge decreases in read/write performance. This has been observed for both pre-existing Linux & Windows systems using the QCOW2 disk format, and a freshly created Linux system.

  • For an existing x86_64 Windows-10 guest system, hosted on Debian-11, the guest system takes many minutes to boot and Task Manager shows the virtual disk showing read/write latencies measured in seconds rather than milliseconds.
  • Attempts to create a new x86_64 Debian-11 guest on a Debian-11 host produce an input/output error when trying to partition the QCOW2 hard disk /dev/vda (as per attached screenshot) deb11-partition-error
  • Using a pre-existing Debian-11 guest that works perfectly with qemu-7.1, fails to format a basic ext3 /dev/loop filesystem when this guest is booted with qemu-7.2, giving mke2fs: Input/output error while writing out and closing file system

Steps to reproduce (installer error)

  1. Create fresh QCOW2 image: qemu-img create -f qcow2 deb11.img 8G
  2. Run standard Debian-11 installer from ISO image and virtio-blk-pci drive and options -drive if=none,media=disk,id=drive0,file=deb11.img,cache=writeback,discard=unmap,detect-zeroes=unmap
  3. Use default options with "guided partitioning"

Steps to reproduce (losetup error)

  1. Boot existing Debian-11 virtual machine, created using qemu-7.1, still using the discard=unmap,detect-zeroes=unmap options
  2. Try to create filesystem on loopback device within the guest machine:
    dd if=/dev/zero of=/var/tmp/empty.fs bs=1M count=32
    sudo losetup /dev/loop0 /var/tmp/empty.fs 
    sudo mke2fs -t ext3 /var/tmp/empty.fs
    This fails with mke2fs: Input/output error while writing out and closing file system

Additional information

I'm not aware of any changes to the setup of my system that would account for these problems, and have successfully tried many similar experiments with QEMU version up to and including version 7.1. Obviously, I'm hoping there's some trivial configuration error I've overlooked in qemu-7.2 - any suggestions would be much appreciated.

Edited by RW Penney
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information