USB Physical Port Mapping

From Proxmox VE
Jump to navigation Jump to search

The main reason to use physical USB port mapping is to be able to connect several usb devices which have the same IDs to different virtual machines (device-1 to VM1, device-2 to VM2, etc).

Map hardware USB port

Find out physical port parameters (bus and port)

Through Qemu/KVM tool (simpler):

qm monitor <VM_ID>
qm> info usbhost
 Bus 3, Addr 2, Port 1, Speed 1.5 Mb/s
   Vendor Specific: USB device 0529:0001, HASP 2.17
 Bus 5, Addr 3, Port 2, Speed 12 Mb/s
   Class 00: USB device 0624:0248, USB Composite Device-0
 Auto filters:
   Bus 1, Addr *, Port 1.3, ID *:*
  • Example 1: Bus 3, Port 1 => 3-1
  • Example 2: Bus 1, Port 1.3 => 1-1.3

Or from the host:

lsusb -t
/: Bus 05.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
/: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
    |__ Port 1: Dev 4, If 0, Class=vend., Driver=usbfs, 1.5M
    |__ Port 2: Dev 5, If 0, Class=vend., Driver=usbfs, 1.5M
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/4p, 480M
        |__ Port 3: Dev 5, If 0, Class=comm., Driver=usbfs, 480M
        |__ Port 3: Dev 5, If 1, Class=data, Driver=usbfs, 480M
  • Example 1: Bus 3, Port 1 => 3-1
  • Example 2: Bus 1, Port 1, Port 3 => 1-1.3

Add the device to the VM

Edit the VM's configuration file /etc/pve/qemu-server/<VM_ID>.conf and add this line:

  • Examples 1 & 2:
 usb0: host=3-1
 usb1: host=1-1.3

For Proxmox before version 1.9, try this line:

  • Example 1:
 args: -device usb-host,hostbus=3,hostport=1
  • Example 2:
 args: -device usb-host,hostbus=1,hostport=1.3

Stop and restart the VM

Stop and start the VM (a reboot is not enought).

Check that the USB devices are seen by the VM:

qm monitor <VM_ID>
qm> info usb
 Device 0.2, Port 1, Speed 12 Mb/s, Product QEMU USB Tablet
 Device 0.3, Port 2, Speed 12 Mb/s, Product QEMU USB Hub
 Device 1.1, Port 1, Speed 1.5 Mb/s, Product HASP 2.17
 Device 1.0, Port 2, Speed 480 Mb/s, Product USB Host Device

References