Re: [Call For Test] Single USB device passthrough for Bhyve
- In reply to: Shawn Webb : "Re: [Call For Test] Single USB device passthrough for Bhyve"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 26 Aug 2025 16:50:37 UTC
Hello: Sorry, I forgot to mention this in the mail—it’s already summarized in the patch. Currently, we only support device selection based on VID and PID. If there are multiple identical devices, the chosen one depends on the order that /dev/usbctl ioctl returns to userspace. A simpler way to determine which device is selected is by checking the usbconfig order—the topmost entry is the one that gets selected. In libusb, there is a function called libusb_wrap_sys_device that can open a /dev/usb/ugen device using a file descriptor and build a libusb_device context from it. This approach would let us manually select a specific ugen device instead of relying solely on VID/PID, which solves the problem of handling multiple identical devices. However, the FreeBSD ugen interface uses two file descriptors, which makes this implementation a bit more complicated. Shawn Webb <shawn.webb@hardenedbsd.org> writes: > On Wed, Aug 27, 2025 at 12:36:12AM +0800, ShengYi Hung wrote: >> >> Hello all: >> >> >> I am currently working on implementing single USB device passthrough for >> bhyve. >> >> The patch is over here: https://reviews.freebsd.org/D52166 >> >> At this stage, all four types of transfers are supported: control, bulk, interrupt, >> and isochronous. I have verified functionality with a few devices, but broader >> testing is definitely needed to ensure stability and >> compatibility. The isochornous xfer remain untested since it is >> a little bit hard for me to setup uvc test in guest. >> >> In addition, device hotplug is supported. This means that once the guest is >> running, you can physically remove a device and reattach it without >> requiring a restart. >> >> To build this feature, please apply all parent patches listed on >> Phabricator and rebuild kernel, libusb, and usbconfig. >> >> To test passthrough, append the following argument in your bhyve >> config, -s 30,xhci,passthru.vid.pid >> Here, vid and pid are the hexadecimal value of the vendor id >> and product id of the target device. You can obtain these values with: >> usbconfig dump_all_desc. >> >> I would greatly appreciate it if more people could test this feature and >> provide feedback. Thanks! > > Thanks for working on this! If I have multiple of the same device > connected (two Yubikeys for example), would this pass through both > devices or just one? If just one, which would it be? > > Thanks, -- Best Regards. ShengYi Hung.