Bug 279659 - virtualization/bhyve: When bhyve virtualizes Windows 10/11 Rufus does not recognizes any USB sticks
Summary: virtualization/bhyve: When bhyve virtualizes Windows 10/11 Rufus does not rec...
Status: Closed Not A Bug
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Many People
Assignee: freebsd-virtualization (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-10 22:08 UTC by mario felicioni
Modified: 2024-06-14 18:36 UTC (History)
3 users (show)

See Also:


Attachments
The images below shows that the USB stick is not recognized by Rufus. (105.48 KB, image/png)
2024-06-10 22:08 UTC, mario felicioni
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description mario felicioni 2024-06-10 22:08:41 UTC
Created attachment 251370 [details]
The images below shows that the USB stick is not recognized by Rufus.

Hello.

I'm running Windows 11 virtualized with bhyve using these parameters :

bhyve -S -c sockets=4,cores=2,threads=1 -m 8G -w -H \
-S -c sockets=4,cores=2,threads=1 -m 8G -w -H \
-s 0,hostbridge \
-s 1,ahci-hd,/mnt/$vmdisk0'p2'/bhyve/img/Windows/Windows11.img,bootindex=1 \
-s 2,ahci-hd,/dev/da2 \
-s 13,virtio-net,tap18 \
-s 29,fbuf,tcp=0.0.0.0:5918,w=1600,h=950,wait \
-s 30,xhci,tablet \
-s 31,lpc \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI_CODE.fd \
vm0:18 < /dev/null & sleep 2 && vncviewer 0:18

Where /dev/da2 is :

Geom name: da2
Providers:
1. Name: da2
   Mediasize: 16053960192 (15G)
   Sectorsize: 512
   Mode: r0w0e0
   descr: SanDisk Cruzer
   ident: 0774911DDC4200A6
   rotationrate: unknown
   fwsectors: 63
   fwheads: 255

my intention was to create an USB drive with Rufus. Well,it is not able to detect my USB stick : I have a SanDisk Cruzer.

The images below shows that it is not recognized and even the log registry.

https://ibb.co/vHSbHQN
https://ibb.co/0FYCBfs

I've contacted the developer of Rufus,who said :

Most likely, the FreeBSB folks did not emulate a full USB stack in their virtualization platform, so they probably use a custom driver to present the USB drive as a non-USB disk to Windows, in which case,Rufus will obviously not detect it.

Unfortunately, while I may do so for a *limited* set of virtual platforms (i.e. the most popular ones out there), I just can't go around trying every virtualization software out there to figure out what kind of non-USB driver a virtualization platform uses to present USB drives to Windows. I did add VMDK (VMWARE) and VHD (Hyper-V) support to Rufus in the past, but I am not going to go out of my way for BSD. I may however accept a patch...

Would someone give more information why this problem occurs ? thanks.
Comment 1 Oleksandr Kryvulia 2024-06-11 05:47:22 UTC
You pass your pendrive as block device to the guest, not usb device. Since FreeBSD does not support usb device passthrough try to pass a usb controller as pci-device.
Comment 2 mario felicioni 2024-06-11 09:16:19 UTC
That's not good. For many reasons :

1) I can see the usb stick in Windows,so it works,at least in Windows,it is recognized and I can copy and paste files from/to the usb stick

2) I don't have and you can't ask me to BUY a dedicated USB controller to be able to allow Rufus to detect the usb stick when Windows detects it

3) I can't pass the whole PCIe device / USB controller that in my case is : (00:14.0 USB controller: Intel Corporation Cannon Lake PCH USB 3.1 xHCI Host Controller) because I have several peripherals connected there that I can't disconnect from the host os

4) My mobo has only two PCIe lines,I have no space on the mobo to add another USB Controller.
Comment 3 Oleksandr Kryvulia 2024-06-11 19:58:24 UTC
I understand you. But I think It is not a bug, it is a feature request.
Comment 4 mario felicioni 2024-06-11 21:04:29 UTC
Where can I make the request ?
Comment 5 churchers 2024-06-12 09:41:34 UTC
"
1) I can see the usb stick in Windows,so it works,at least in Windows,it is recognized and I can copy and paste files from/to the usb stick

2) I don't have and you can't ask me to BUY a dedicated USB controller to be able to allow Rufus to detect the usb stick when Windows detects it
"

These two comments are irrelevant. Windows is not seeing a USB device at all; Your bhyve host is seeing a USB device that provides storage and is creating a block device on the host. You are then passing that block device through to the guest as a standard ACHI hard drive. Windows sees a "standard" hard drive.

Windows being able to use the provided disk does not in any way suggest that a tool designed to interface directly with raw USB devices should be able to see the USB stick itself.

I understand the frustration that currently the only way to achieve what you're after is to pass an entire USB controller through to the guest, but as mentioned, what you are really after is individual USB device passthrough, which would require support in bhyve.

You could try asking on the virtualisation mailing list to see if any work has been done or is being considered for usb device pass through. This particular use case for usb storage probably isn't that much in demand seeing as the storage can be passed through as you already are (and it's not exactly a difficult work around to just dump whatever image you want onto the stick on the host itself), but there are many other types of usb device that would be useful to pass through without having to go the route of reserving and passing a full controller.

Also, even though you clearly state you don't want to pass through a controller, it's worth checking if you have more than one. I for example could very easily pass through the front usb2 controller on my board (it has 4, usb2/3 front & usb2/3 rear), put the usb stick in the front, and have all my host usb devices in the rear ports.
Comment 6 mario felicioni 2024-06-12 12:39:42 UTC
I've realized that my GPU has one integrated USB controller. It is the RTX 2080 Ti and FreeBSD detect 4 slots :

02:00.0 VGA compatible controller: NVIDIA Corporation TU102 [GeForce RTX 2080 Ti] (rev a1)
02:00.1 Audio device: NVIDIA Corporation TU102 High Definition Audio Controller (rev a1)
02:00.2 USB controller: NVIDIA Corporation TU102 USB 3.1 Host Controller (rev a1)
02:00.3 Serial bus controller: NVIDIA Corporation TU102 USB Type-C UCSI Controller (rev a1)

So I tried to pass only the slots 2 and 3,because I don't need to pass the GPU itself and / or the audio slot (2/0/1),like this :

-s 8:2,passthru,2/0/2 \
-s 8:3,passthru,2/0/3 \

This is what happened :

Assertion failed: (mr->name == memp->name), function unregister_mem, file /usr/src/usr.sbin/bhyve/mem.c, line 344.

So,now. We have two different problems to deal with.
Comment 7 Mark Peek freebsd_committer freebsd_triage 2024-06-12 16:56:52 UTC
There is another way to get this working which is to follow the rufus developer suggestion of providing a patch.

Here is a working branch of rufus that has a simple patch to allow bhyve disks to show up in the rufus UI and can write through to a mapped SD. Give it a try and let me know if it works for you. If so, then I'll PR it back to the rufus main repo.

https://github.com/markpeek/rufus/tree/markpeek-bhyve
Comment 8 mario felicioni 2024-06-12 17:23:35 UTC
I'm trying to compile your fork of Rufus on my Ubuntu 23.10 box,but I'm having some troubles. I see that your github does not accept the bug tickets.
Comment 9 Mark Peek freebsd_committer freebsd_triage 2024-06-12 17:33:57 UTC
Mario, I turned issues on for my repo so we can discuss any issues there.
Comment 10 mario felicioni 2024-06-12 17:38:27 UTC
Its too late :P

https://github.com/pbatard/rufus/issues/2500
Comment 11 mario felicioni 2024-06-14 07:34:09 UTC
I have compiled the source code of Mark Peek with the patch and it worked. So now Rufus can detect the USB disks inside a Windows vm. Very thanks.
Comment 12 Mark Peek freebsd_committer freebsd_triage 2024-06-14 18:36:59 UTC
I'm closing this as "not a bug" for FreeBSD since the needed change/workaround was PR'd back into the rufus repo.