sr-iov 我们常说的usb设备直通,其实准确的来说,不应该说是直通,usb设备要想真正的直通,最简单的办法是把相关的usb控制器——它是一个pci设备,通过直通这个pci设备,才能做到真正的usb设备直通。不过这样做不是很方便,大部分的主板都只有一到两个usb控制器。为什么要在这里说不是直通呢 ,这个透传的原理是模拟一个usb控制器,所以多少都会影响性能,如果通过直通usb控制器的办法,性能损失更小,如何选择? 根据使用场景在性能和方便这两个方案中自行抉择。
下面用我的一个usb网卡来示例如何做到usb设备的透传。此次主角 绿联 usb 千兆网卡
第一步 登录 TrueNAS 管理面板
1.1 插上usb网卡
网卡
第二步 打开虚拟化相关页面
第三步 关闭虚拟机
第四步 添加设备
4.1 选择设备类型
设备类型
4.2 usb控制器类型
建议选择xhci
这里进行一点小科普:XHCI controller support
-----------------------
QEMU has XHCI host adapter support. The XHCI hardware design is much
more virtualization-friendly when compared to EHCI and UHCI, thus XHCI
emulation uses less resources (especially cpu). So if your guest
supports XHCI (which should be the case for any operating system
released around 2010 or later) we recommend using it:
XHCI supports USB 1.1, USB 2.0 and USB 3.0 devices, so this is the
only controller you need. With only a single USB controller (and
therefore only a single USB bus) present in the system there is no
need to use the bus= parameter when adding USB devices.
EHCI controller support
----------------------- The QEMU EHCI Adapter supports USB 2.0 devices. It can be used either
standalone or with companion controllers (UHCI, OHCI) for USB 1.1
devices. The companion controller setup is more convenient to use
because it provides a single USB bus supporting both USB 2.0 and USB
1.1 devices. See next section for details.