Virtio-win driver (virtio-blk and virtio-scsi) don't work when they are used on bhyve with Windows 11 as guest os

From: Mario Marietto <marietto2008_at_gmail.com>
Date: Fri, 25 Mar 2022 11:54:53 UTC
Hello.

What I want to achieve is to pass thru two of my NTFS "formatted" disks to
a Windows 11 VM,but without passing them thru using the USB controller in
FreeBSD with a bhyve virtual machine (in the example below I tried to boot
Windows 11 from the nvme disk nvd0.


I'm using this FreeBSD version :


FreeBSD marietto 13.0-RELEASE FreeBSD 13.0-RELEASE #8
n244809-dff3dead3734: Wed Feb 23 13:16:32 CET
2022     marietto@marietto:/usr/obj/usr/src/amd64.amd64/sys/GENERIC  amd64


I've configured the bhyve VM like this :


bhyve -S -c sockets=1,cores=2,threads=2 -m 4G -w -H -A \
-s 0,hostbridge \
-s 1,ahci-hd,/dev/nvd0 \
-s 2,virtio-blk,/dev/da4p2 \
-s 3,virtio-blk,/dev/da2p1 \
-s 8,virtio-net,tap4 \
-s 10,hda,play=/dev/dsp,rec=/dev/dsp \
-s 29,fbuf,tcp=[0.0.0.0:5904](http://0.0.0.0:5904/),w=1440,h=900 \
-s 30,xhci,tablet \
-s 31,lpc \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_BHF_CODE.fd \
vm4 < /dev/null & sleep 2 && vncviewer 0:4


These are the NTFS disks that I would like to see inside the Windows 11
guest os :


-s 2,virtio-blk,/dev/da4p2 \
-s 3,virtio-blk,/dev/da2p1 \


=>         34  19532873661  da4  GPT  (9.1T)
           34        32734    1  ms-reserved  (16M)
32768  19532838912    2  ms-basic-data  (9.1T)
19532871680         2015       - free -  (1.0M)


=>         34  23437705149  da2  GPT  (11T)
           34         2014       - free -  (1.0M)
2048  23437701120    1  ms-basic-data  (11T)
23437703168         2015       - free -  (1.0M)


As you can see I've used the virtio-blk driver,so inside the Windows 11 VM
I've installed the latest version of the virtio drivers. The disks attached
are 0 byte large,so they aren't recognized by Windows 11. Is this a bug or
what ? They are USB 3.0 disks. You can give a look at the images below if u
want to have a better understanding :


https://forums.freebsd.org/attachments/1-jpg.13311/
https://forums.freebsd.org/attachments/2-jpg.13312/


I've tried also like this :


bhyve -S -c sockets=1,cores=2,threads=2 -m 4G -w -H -A \
-s 0,hostbridge \
-s 1,ahci-hd,/dev/nvd0 \
-s 2,virtio-blk,/dev/da4 \
-s 3,virtio-blk,/dev/da2 \
-s 8,virtio-net,tap4 \
-s 10,hda,play=/dev/dsp,rec=/dev/dsp \
-s 29,fbuf,tcp=[0.0.0.0:5904](http://0.0.0.0:5904/),w=1440,h=900 \
-s 30,xhci,tablet \
-s 31,lpc \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_BHF_CODE.fd \
vm4 < /dev/null & sleep 2 && vncviewer 0:4


and I get this error :


*Assertion failed: (n >= 2 && n <= BLOCKIF_IOV_MAX + 2), function
pci_vtblk_proc, file /usr/src/usr.sbin/bhyve/pci_virtio_block.c, line 324.*


I have tried also with :


-s 2,virtio-scsi,/dev/da4p2 \
-s 3,virtio-scsi,/dev/da2p1 \


and I have also installed the virtio-scsi driver on Windows 11,that has
been accepted by windows,but the disks aren't recognized :


https://forums.freebsd.org/attachments/screenshot_2022-03-13_11-23-54-jpg.13321/
https://forums.freebsd.org/attachments/screenshot_2022-03-13_11-10-16-jpg.13320/


Finally I tried by virtualizing ubuntu with bhyve using the virtio-scsi
driver on ubuntu as guest os and it worked,so there is a bug only on the
drivers for windows. You can see what happens with ubuntu going on the
freebsd forum at this address :


https://forums.FreeBSD.org/threads/usb-3-0-disks-not-recognized-by-windows-if-passed-through-as-slots.84402/post-559924


I have also opened a bug request below,but no one replied until now.
https://github.com/virtio-win/kvm-guest-drivers-windows/issues/747


-- 
Mario.