USBIP for FreeBSD

Can't find a port for it, and it won't be included in the base (license).
 
Hmm, ok worth a shot maybe someone knew something I didn't. Or maybe FreeBSD had it's own implementation of it.
 
I'm going to move this thread to "Emulation and virtualization". There may be someone who has a solution specifically for bhyve(8).

That said, one solution could be to passthrough the entire USB controller (or a separate PCIe USB card) and stick the key in that.
 
Yeah I know but then I need to remove the usb from the kernel and so forth that means I can't use usb at all on that system anymore.
 
Yeah I know but then I need to remove the usb from the kernel and so forth that means I can't use usb at all on that system anymore.
No, that's not needed. I have a PCIe USB card I'm passing through to a single VM. That card is excluded on the host using pptdevs. No need to disable USB on the host.

Code:
ppt0@pci0:7:0:0:        class=0x0c0330 rev=0x00 hdr=0x00 vendor=0x1b21 device=0x2142 subvendor=0x3142 subdevice=0x1b21
    vendor     = 'ASMedia Technology Inc.'
    device     = 'ASM2142/ASM3142 USB 3.1 Host Controller'
    class      = serial bus
    subclass   = USB

In loader.conf:
Code:
pptdevs="7/0/0"

And in the VM configuration:
Code:
passthru1="7/0/0=7:0"

Host isn't going to touch it and the VM has direct access to the PCIe USB card.
 
Oh that's new then I think in 10.x you where supposed to. That's good to know. Still unfortunately that would mean you'd need an entire card for one vm. And if you have plenty of pcie that's fine but most of the time you don't have enough to serve all vms.

However it's nice to know that you can now pass it through without removing usb driver from the kernel.
 
I've asked to a bhyve developer how to passthru USB keyboard and mouse and he gave me a software solution,that I didn't know :


If it’s only mouse and keyboard you could use bhyves virtio-input emulation.
As it’s one of my bhyve versions it’s likely to include virtio-input support.
Check “man bhyve”.
I’ve committed virtio-input to 13.2 and 14.0 upstream.
So, when these versions are released, virtio-input will be supported.

From “man bhyve” (https://www.freebsd.org/cgi/man.cgi...FreeBSD+14.0-CURRENT&arch=default&format=html):

Virtio input device backends:

/dev/input/eventX

Send input events of /dev/input/eventX to guest

by VirtIO Input Interface.

so,maybe it works like this :

Code:
bhyve -S -c sockets=2,cores=2,threads=2 -m 8G -w -H -A \
-s 0,hostbridge \
-s 1,ahci-hd,/dev/$vmdisk7,bootindex=1 \
-s 4,fbuf,tcp=0.0.0.0:5915,w=1600,h=950 \
-s 8:0,passthru,1/0/0 \
-s 8:1,passthru,1/0/1 \
-s 9,virtio-input,/dev/input/eventX
Code:
-s 10,virtio-net,tap15 \
-s 11,virtio-9p,sharename=/ \
-s 30,xhci,tablet \
-s 31,lpc \
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_BHF_CODE.fd \
vm15 < /dev/null & sleep 2 && vncviewer 0:15

maybe instead of /dev/input/eventX you can try your usb stick device. let me know if it works.
 
That's good to know. Still unfortunately that would mean you'd need an entire card for one vm. And if you have plenty of pcie that's fine but most of the time you don't have enough to serve all vms.
That is not correct. They make cards for virtuilization that use seperate PCIe addresses for each controller onboard.

I am using these with bhyve for USB passthrough. It has 4 independent controllers. Usable for 4 VM's.
So 1 USB3 port passed to each VM.

They also make a two channel / four port version.
Not cheap. What in server world is.

 
The time to help me here is came :

 
Could be usefull but not exactly what I'm looking for as you wouldn't be able to passthrough a crypto key such as yubikey. At least looking at it gives me the impression.
We've been using Silex DS-510 USB servers for this purpose (e.g. HASP license keys and POS crypto/signing modules) because that solution was far more flexible than passthrough of a whole controller. Also those HASP keys have been *EXTREMELY* ugly in behaviour when it comes to virtualization/passthrough and often locked up when the VM reboots (but the port didn't power-cycle) or they simply didn't work at all. According to some support/marketing droid that's intentional and because of "protecting the license key and to prevent tampering" - yet funnily they work flawlessly with USB-servers like Silex.

I suspect those silex servers might also use USBIP under the hood, at least they are running some kind of embedded linux IIRC...
 
Seems to me what is needed is a FreeBSD kernel "vhci" (USB virtual host controller interface) driver that can connect to remote USB devices over IP. Perhaps one of you bright people can work on it with some advice from FreeBSD USB experts like Selasky? I suspect a clean implementation from USB/IP description may be less or same work as porting Linux vhci code.
 
My original post included a github source that already ported some of the code not sure if it's working. But this is something they've worked on like 10years ago hence this post, I figured if someone worked on it 10 years ago it might already be functional and I'm just not aware of it.

And I think it would be great if someone where to port it then you would have a system that would be compatible with windows/bsd/linux I would do it myself, but I don't know only basic C

sko

Indeed my intend is to use it with crypto keys like yubi and wubi keys.
 
Back
Top