Bug 2133261

Summary: [virtio-blk] [virtio-scsi] The format can not complete successfully when 'Perform a quick format' uncheck with win11(22h2)
Product: Red Hat Enterprise Linux 9 Reporter: menli <menli>
Component: virtio-winAssignee: Vadim Rozenfeld <vrozenfe>
virtio-win sub component: virtio-win-prewhql QA Contact: menli <menli>
Status: CLOSED MIGRATED Docs Contact:
Severity: high    
Priority: medium CC: coli, jinzhao, juzhang, phou, qinwang, qizhu, vrozenfe
Version: 9.2Keywords: CustomerScenariosInitiative, MigratedToJIRA, Triaged
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Windows   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-06-23 00:50:52 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description menli@redhat.com 2022-10-09 09:10:18 UTC
Description of problem:

The format can not complete successfully when 'Perform a quick format' is uncheck with win11(22h2)

Version-Release number of selected component (if applicable):

kernel-5.14.0-167.el9.x86_64
qemu-kvm-7.1.0-1.el9.x86_64
edk2-ovmf-20220526git16779ede2d36-4.el9.noarch
seabios-bin-1.16.0-4.el9.noarch
virtio-win-prewhql-227.iso

How reproducible:
100%

Steps to Reproduce:
1. Boot a win11(22H2) guest with a data disk (stg1.qcow2).

 /usr/libexec/qemu-kvm \
    -name 'avocado-vt-vm3' \
    -machine q35 \
    -nodefaults \
    -vga std  \
    -device pcie-root-port,port=0x10,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x3 \
    -device pcie-root-port,port=0x11,chassis=2,id=pci.2,bus=pcie.0,addr=0x3.0x1 \
    -device pcie-root-port,port=0x12,chassis=3,id=pci.3,bus=pcie.0,addr=0x3.0x2 \
    -device pcie-root-port,port=0x13,chassis=4,id=pci.4,bus=pcie.0,addr=0x3.0x3 \
    -device pcie-root-port,port=0x14,chassis=5,id=pci.5,bus=pcie.0,addr=0x3.0x4 \
    -device pcie-root-port,port=0x15,chassis=6,id=pci.6,bus=pcie.0,addr=0x3.0x5 \
    -device pcie-root-port,port=0x16,chassis=7,id=pci.7,bus=pcie.0,addr=0x3.0x6 \
    -device pcie-root-port,port=0x17,chassis=8,id=pci.8,bus=pcie.0,addr=0x3.0x7 \
    -device virtio-net-pci,mac=9a:36:83:b6:3d:05,id=idJVpmsF,netdev=id23ZUK6,bus=pci.3  \
    -netdev tap,id=id23ZUK6,vhost=on \
    -m 14336  \
    -smp 2,maxcpus=4 \
    -cpu 'Skylake-Server',hv_stimer,hv_synic,hv_vpindex,hv_reset,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time,hv-tlbflush,+kvm_pv_unhalt \
    -drive id=drive_cd1,if=none,snapshot=off,aio=threads,cache=none,media=cdrom,file=/home/kvm_autotest_root/iso/windows/virtio-win-prewhql-0.1-224.iso\
    -device ide-cd,id=cd2,drive=drive_cd1,bus=ide.0,unit=0 \
    -device piix3-usb-uhci,id=usb -device usb-tablet,id=input0 \
    -vnc :10  \
    -rtc base=localtime,clock=host,driftfix=slew  \
    -boot order=cdn,once=c,menu=off,strict=off \
    -enable-kvm \
    -qmp tcp:0:1231,server,nowait \
    -monitor stdio \
    -device pvpanic,id=pvpanic0,ioport=0x0505  \
    -device virtio-serial-pci,id=virtio-serial1,max_ports=31,bus=pci.5  \
    -chardev socket,id=channel2,path=/tmp/helloworld2,server=on,wait=off  -device virtserialport,bus=virtio-serial1.0,chardev=channel2,name=org.qemu.guest_agent.0  \
    -drive file=/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd,if=pflash,format=raw,unit=0,readonly=on  \
    -drive file=/home/OVMF_VARS.fd,if=pflash,format=raw,unit=1  \
    -tpmdev emulator,id=tpm-tpm0,chardev=chrtpm \
    -chardev socket,id=chrtpm,path=/tmp/guest-swtpm.sock \
    -device tpm-crb,tpmdev=tpm-tpm0,id=tpm0 \
    -blockdev node-name=file_stg2,driver=file,cache.direct=on,cache.no-flush=off,filename=/home/win11-64-virtio.qcow2,aio=threads \
    -blockdev node-name=drive_stg2,driver=qcow2,cache.direct=on,cache.no-flush=off,file=file_stg2 \
    -device virtio-blk-pci,id=stg2,drive=drive_stg2 \
    -blockdev node-name=file_stg3,driver=file,cache.direct=on,cache.no-flush=off,auto-read-only=on,discard=unmap,aio=threads,filename=/home/kvm_autotest_root/images/stg1.qcow2,aio=threads \
    -blockdev node-name=drive_stg3,driver=qcow2,read-only=off,cache.direct=on,cache.no-flush=off,file=file_stg3,discard=unmap \
    -device virtio-blk-pci,id=st32,drive=drive_stg3 \


2. Try to format data disk stg1.qcow2 via disk manager(uncheck 'Perform a quick format' )


Actual results:
After step2, The format did not complete successfully.

Expected results:
The format can complete successfully.

Additional info:
1. not reproduce this issue with win11(21H2).

Comment 2 qing.wang 2022-10-10 06:53:14 UTC
Hit same issue on scsi disk when execute NTFS format  

Red Hat Enterprise Linux release 9.2 Beta (Plow)
5.14.0-162.el9.x86_64
qemu-kvm-7.1.0-1.el9.x86_64
seabios-bin-1.16.0-4.el9.noarch
edk2-ovmf-20220526git16779ede2d36-3.el9.noarch
libvirt-8.5.0-6.el9.x86_64
python3-libvirt-8.5.0-2.el9.x86_64
virtio-win-prewhql-0.1-225.iso


qemu-img create -f qcow2 /home/kvm_autotest_root/images/stg1.qcow2 10G


/usr/libexec/qemu-kvm \
     -name 'avocado-vt-vm1'  \
     -sandbox on  \
     -blockdev node-name=file_ovmf_code,driver=file,filename=/usr/share/OVMF/OVMF_CODE.secboot.fd,auto-read-only=on,discard=unmap \
     -blockdev node-name=drive_ovmf_code,driver=raw,read-only=on,file=file_ovmf_code \
     -blockdev node-name=file_ovmf_vars,driver=file,filename=/home/ovmf/OVMF_VARS.fd,auto-read-only=on,discard=unmap \
     -blockdev node-name=drive_ovmf_vars,driver=raw,read-only=off,file=file_ovmf_vars \
     -machine q35,memory-backend=mem-machine_mem,pflash0=drive_ovmf_code,pflash1=drive_ovmf_vars \
     -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  \
     -nodefaults \
     -device VGA,bus=pcie.0,addr=0x2 \
     -m 12288 \
     -object memory-backend-ram,size=12288M,id=mem-machine_mem  \
     -smp 16,maxcpus=16,cores=8,threads=1,dies=1,sockets=2  \
     -cpu 'EPYC-Rome',x2apic=on,tsc-deadline=on,hypervisor=on,tsc-adjust=on,spec-ctrl=on,stibp=on,arch-capabilities=on,ssbd=on,xsaves=on,cmp-legacy=on,ibrs=on,amd-ssbd=on,virt-ssbd=on,lbrv=on,tsc-scale=on,vmcb-clean=on,svme-addr-chk=on,rdctl-no=on,skip-l1dfl-vmentry=on,mds-no=on,pschange-mc-no=on,hv_stimer,hv_synic,hv_vpindex,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time,hv_frequencies,hv_runtime,hv_tlbflush,hv_reenlightenment,hv_stimer_direct,hv_ipi,kvm_pv_unhalt=on \
     -chardev socket,id=qmp_id_qmpmonitor1,server=on,wait=off,path=/var/tmp/avocado_l20ses_2/monitor-qmpmonitor1-20220928-220503-Y6ZWjk2i  \
     -mon chardev=qmp_id_qmpmonitor1,mode=control \
     -chardev socket,id=qmp_id_catch_monitor,server=on,wait=off,path=/var/tmp/avocado_l20ses_2/monitor-catch_monitor-20220928-220503-Y6ZWjk2i  \
     -mon chardev=qmp_id_catch_monitor,mode=control \
     -device pvpanic,ioport=0x505,id=idGfvu9b \
     -chardev socket,id=chardev_serial0,server=on,wait=off,path=/var/tmp/avocado_l20ses_2/serial-serial0-20220928-220503-Y6ZWjk2i \
     -device isa-serial,id=serial0,chardev=chardev_serial0  \
     -chardev socket,id=seabioslog_id_20220928-220503-Y6ZWjk2i,path=/var/tmp/avocado_l20ses_2/seabios-20220928-220503-Y6ZWjk2i,server=on,wait=off \
     -device isa-debugcon,chardev=seabioslog_id_20220928-220503-Y6ZWjk2i,iobase=0x402 \
     -device pcie-root-port,id=pcie-root-port-1,port=0x1,addr=0x1.0x1,bus=pcie.0,chassis=2 \
     -device qemu-xhci,id=usb1,bus=pcie-root-port-1,addr=0x0 \
     -device usb-tablet,id=usb-tablet1,bus=usb1.0,port=1 \
     -object iothread,id=iothread0 \
     -object iothread,id=iothread1 \
     -device pcie-root-port,id=pcie-root-port-2,port=0x2,addr=0x1.0x2,bus=pcie.0,chassis=3 \
     -device virtio-scsi-pci,id=virtio_scsi_pci0,bus=pcie-root-port-2,addr=0x0,iothread=iothread0 \
     -blockdev node-name=file_image1,driver=file,auto-read-only=on,discard=unmap,aio=threads,filename=/home/kvm_autotest_root/images/win11-64-virtio-scsi.qcow2,cache.direct=on,cache.no-flush=off \
     -blockdev node-name=drive_image1,driver=qcow2,read-only=off,cache.direct=on,cache.no-flush=off,file=file_image1 \
     -device scsi-hd,id=image1,drive=drive_image1,write-cache=on \
     -blockdev node-name=file_stg1,driver=file,auto-read-only=on,discard=unmap,aio=threads,filename=/home/kvm_autotest_root/images/stg1.qcow2,cache.direct=on,cache.no-flush=off \
     -blockdev node-name=drive_stg1,driver=qcow2,read-only=off,cache.direct=on,cache.no-flush=off,file=file_stg1,discard=unmap \
     -device scsi-hd,id=stg1,drive=drive_stg1,write-cache=on \
     -device pcie-root-port,id=pcie-root-port-3,port=0x3,addr=0x1.0x3,bus=pcie.0,chassis=4 \
     -device virtio-net-pci,mac=9a:2f:74:a8:90:a1,id=idqBegdA,netdev=id0UWe8v,bus=pcie-root-port-3,addr=0x0  \
     -netdev tap,id=id0UWe8v,vhost=on \
     -blockdev node-name=file_cd1,driver=file,auto-read-only=on,discard=unmap,aio=threads,filename=/home/kvm_autotest_root/iso/windows/winutils.iso,cache.direct=on,cache.no-flush=off \
     -blockdev node-name=drive_cd1,driver=raw,read-only=on,cache.direct=on,cache.no-flush=off,file=file_cd1 \
     -device scsi-cd,id=cd1,drive=drive_cd1,write-cache=on \
     -blockdev node-name=file_virtio,driver=file,auto-read-only=on,discard=unmap,aio=threads,filename=/home/kvm_autotest_root/iso/windows/virtio-win-prewhql-0.1-225.iso,cache.direct=on,cache.no-flush=off \
     -blockdev node-name=drive_virtio,driver=raw,read-only=on,cache.direct=on,cache.no-flush=off,file=file_virtio \
     -device scsi-cd,id=virtio,drive=drive_virtio,write-cache=on  \
     -vnc :5  \
     -monitor stdio \
     -rtc base=localtime,clock=host,driftfix=slew  \
     -boot menu=off,order=cdn,once=c,strict=off \
     -chardev socket,id=char_vtpm_avocado-vt-vm1_tpm0,path=/home/kar/workspace/root/avocado/data/avocado-vt/swtpm/avocado-vt-vm1_tpm0_swtpm.sock \
     -tpmdev emulator,chardev=char_vtpm_avocado-vt-vm1_tpm0,id=emulator_vtpm_avocado-vt-vm1_tpm0 \
     -device tpm-crb,id=tpm-crb_vtpm_avocado-vt-vm1_tpm0,tpmdev=emulator_vtpm_avocado-vt-vm1_tpm0 \
     -enable-kvm \
     -device pcie-root-port,id=pcie_extra_root_port_0,multifunction=on,bus=pcie.0,addr=0x3,chassis=5

Comment 3 Peixiu Hou 2022-11-01 02:05:23 UTC
Hit the same issue with vioscsi + build 228 on RHEL9.1.z host.

Versions:
kernel-5.14.0-162.6.1.el9_1.x86_64
qemu-kvm-7.0.0-13.el9.x86_64
edk2-ovmf-20220526git16779ede2d36-3.el9.noarch
virtio-win-prewhql-228

Thanks~
Peixiu

Comment 5 menli@redhat.com 2023-05-23 10:50:54 UTC
Both reproduce both qcow2 and raw format.

Comment 9 Vadim Rozenfeld 2023-06-16 04:45:25 UTC
Apparently W11 22H2 can perform only quick format on a thinly provisioning volume (https://bugzilla.redhat.com/attachment.cgi?id=1971081).
Windows can recognize such volume by checking ProvisioningType == PROVISIONING_TYPE_THIN
reported in VPD_LOGICAL_BLOCK_PROVISIONING VPD. in case of virtio-scsi the ProvisioningType
can be changed from PROVISIONING_TYPE_THIN to PROVISIONING_TYPE_RESOURCE by setting discard_granularity to 0.
virtio-blk driver sets ProvisioningType based on discard type but not on discard_granularity value, which 
makes it different from virtio-scsi. I prepared a patch for viostor driver to fix this difference and going to push it shoptly.

Meanwhile, can QE please check if setting discard_granularity to 0 can solve this issue for virtio-scsi
driver?

Thanks,
Vadim.

Comment 10 menli@redhat.com 2023-06-16 09:12:55 UTC
(In reply to Vadim Rozenfeld from comment #9)
> Apparently W11 22H2 can perform only quick format on a thinly provisioning
> volume (https://bugzilla.redhat.com/attachment.cgi?id=1971081).
> Windows can recognize such volume by checking ProvisioningType ==
> PROVISIONING_TYPE_THIN
> reported in VPD_LOGICAL_BLOCK_PROVISIONING VPD. in case of virtio-scsi the
> ProvisioningType
> can be changed from PROVISIONING_TYPE_THIN to PROVISIONING_TYPE_RESOURCE by
> setting discard_granularity to 0.
> virtio-blk driver sets ProvisioningType based on discard type but not on
> discard_granularity value, which 
> makes it different from virtio-scsi. I prepared a patch for viostor driver
> to fix this difference and going to push it shoptly.
Thanks for explanation!

> Meanwhile, can QE please check if setting discard_granularity to 0 can solve
> this issue for virtio-scsi
> driver?
Test virtio-scsi with 237 build with discard_granularity=0, it can format success.

-blockdev '{"node-name": "file_stg1", "driver": "file", "auto-read-only": true, "discard": "unmap", "aio": "threads", "filename": "/home/kvm_autotest_root/images/stg1.qcow2", "cache": {"direct": true, "no-flush": false}}' \
-blockdev '{"node-name": "drive_stg1", "driver": "qcow2", "read-only": false, "cache": {"direct": true, "no-flush": false}, "file": "file_stg1", "discard": "unmap"}' \
-device scsi-hd,id=stg1,drive=drive_stg1,write-cache=on,discard_granularity=0 \


> Thanks,
> Vadim.

Comment 11 Vadim Rozenfeld 2023-06-16 12:31:10 UTC
post upstream https://github.com/virtio-win/kvm-guest-drivers-windows/pull/927

Comment 12 Vadim Rozenfeld 2023-06-19 03:26:29 UTC
virio-blk fix available in build 238
https://brewweb.engineering.redhat.com/brew/buildinfo?buildID=2557016

please try with discard_granularity=0 and discard_granularity=32M
it should behave the same way as vioscsi
Thanks,
Vadim.