USB device passthrough implementation
Peter Grehan
grehan at freebsd.org
Tue Mar 17 12:58:21 UTC 2020
Hi Daniel,
> * We need to disconnect the USB device from host: we are currently not very
> familiar with the kernel API to perform this
See usbconfig(8) and the detach_kernel_driver command. It's probably
fine to request a user to issue that command, similar to how external
commands are required to detach a PCI driver before using it for
passthru in bhyve.
> * We need to emulate a USB device controller: we are currently looking into
> pci_xhci.c and usb_mouse.c to reuse some of the code from there and we
> would like to know if there is some sort of in depth documentation
> regarding these.
pci_xhci.c is an implementation of a USB XHCI host controller so
should be the place to start: it either has the functionality that is
needed, or requires slight modifications.
(Lots of info and pointer to the spec at
https://en.wikipedia.org/wiki/Extensible_Host_Controller_Interface)
usb_mouse.c is just an example of a USB device interface, that in turn
passes through VNC mouse-movement events to the guest o/s.
> * We need to pass the USB device to the guest through an emulated port of
> the device controller: we know that project ACRN implements USB device
> passthrough and we are trying to figure out how they do it.
ACRN uses libusb as the interface to USB devices on the host (see
devicemodel/hw/platform/usb_pmapper.c).
later,
Peter.
More information about the freebsd-virtualization
mailing list