1、将需要直通给虚拟机使用的USB设备插到Proxmox服务器上。
2、查看USB设备的总线和端口号。
未插入U盘之前:
root@pve04:/etc/pve/qemu-server# lsusb -t
/: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/6p, 5000M
/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/14p, 480M
|__ Port 12: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
|__ Port 12: Dev 2, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 480M
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M
插入U盘之后:
root@pve04:/etc/pve/qemu-server# lsusb -t
/: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/6p, 5000M
/: <span style="color:#FF0000;">Bus 03</span>.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/14p, 480M
|__ <span style="color:#FF0000;">Port 5:</span> Dev 19, If 0, Class=Mass Storage, Driver=usb-storage, 480M
|__ Port 12: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
|__ Port 12: Dev 2, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 480M
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M
或者:
root@pve04:/etc/pve/qemu-server# qm monitor 120
Entering Qemu Monitor for VM 120 - type 'help' for help
qm> info usbhost
<span style="color:#FF0000;"> Bus 3,</span> Addr 19, <span style="color:#FF0000;">Port 5,</span> Speed 480 Mb/s
Class 00: USB device 090c:1000, Miniking Device
Bus 3, Addr 2, Port 12, Speed 1.5 Mb/s
3 编辑虚拟机配置文件。
在/etc/pve/qemu-server下找到虚拟机的配置文件,在最后添加usb设备配置信息,格式为“usb3: 总线号-端口号”。对于前面找到的总线号和端口号,应该按如下格式添加
usb3: host=3-6
usb3: spice
如果有多个设备,可以继续添加“usb1: host=总线号-端口号”、“usb2: host=总线号-端口号”,这里不再赘述。
4 先关闭再开启虚拟机。
注意,这里不是重新启动,而是执行关机操作,再开启虚拟机。这主要是为了强制虚拟机重新读取第3步修改后的配置文件。