Difference between revisions of "USB Physical Port Mapping"

From Proxmox VE
Jump to navigation Jump to search
(→‎Add the device to the VM: cosmetic changes)
m (Thomas Lamprecht moved page USB physical port mapping to USB Physical Port Mapping: fix title case)
 
(5 intermediate revisions by 2 users not shown)
Line 8: Line 8:
 
  '''qm monitor ''<VM_ID>'''''
 
  '''qm monitor ''<VM_ID>'''''
 
  qm&gt; '''info usbhost'''
 
  qm&gt; '''info usbhost'''
   '''Bus 3''', Addr 2, '''Port 1.2''', Speed 1.5 Mb/s
+
   <span style="color:#FF0000">Bus 3</span>, Addr 2, <span style="color:#FF0000">Port 1.2</span>, Speed 1.5 Mb/s
 
     Vendor Specific: USB device 0529:0001, HASP 2.17
 
     Vendor Specific: USB device 0529:0001, HASP 2.17
 
   Bus 5, Addr 3, Port 2, Speed 12 Mb/s
 
   Bus 5, Addr 3, Port 2, Speed 12 Mb/s
 
     Class 00: USB device 0624:0248, USB Composite Device-0
 
     Class 00: USB device 0624:0248, USB Composite Device-0
  
* Example: Bus 3, Port 1.2 => '''3-1.2'''
+
* Example: Bus 3, Port 1.2 => <span style="color:#FF0000">3-1.2</span>
  
 
==== Or from the host ====
 
==== Or from the host ====
Line 28: Line 28:
 
         |__ Port 3: Dev 5, If 1, Class=data, Driver=usbfs, 480M
 
         |__ Port 3: Dev 5, If 1, Class=data, Driver=usbfs, 480M
  
* Example 1: Bus 3, Port 1 => '''3-1'''
+
* Example 1: Bus 3, Port 1 => <span style="color:#FF0000">3-1</span>
* Example 2: Bus 1, Port 1, Port 3 => '''1-1.3'''
+
* Example 2: Bus 1, Port 1, Port 3 => <span style="color:#FF0000">1-1.3</span>
  
 
=== Add the device to the VM ===
 
=== Add the device to the VM ===
Line 36: Line 36:
  
 
Edit the VM's configuration file '''/etc/pve/qemu-server/''<VM_ID>''.conf''' and add this line:
 
Edit the VM's configuration file '''/etc/pve/qemu-server/''<VM_ID>''.conf''' and add this line:
 +
* Example:
 +
  usb0: host=<span style="color:#FF0000">3</span>-<span style="color:#FF0000">1.2</span>
 
* Examples 1 & 2:
 
* Examples 1 & 2:
   usb0: host='''3'''-'''1'''
+
   usb0: host=<span style="color:#FF0000">3</span>-<span style="color:#FF0000">1</span>
   usb1: host='''1'''-'''1.3'''
+
   usb1: host=<span style="color:#FF0000">1</span>-<span style="color:#FF0000">1.3</span>
  
 
==== Proxmox 1.x ====
 
==== Proxmox 1.x ====
  
 
* Example 1:
 
* Example 1:
   args: -device usb-host,hostbus='''3''',hostport='''1'''
+
   args: -device usb-host,hostbus=<span style="color:#FF0000">3</span>,hostport=<span style="color:#FF0000">1.2</span>
 +
* Example 1:
 +
  args: -device usb-host,hostbus=<span style="color:#FF0000">3</span>,hostport=<span style="color:#FF0000">1</span>
 
* Example 2:
 
* Example 2:
   args: -device usb-host,hostbus='''1''',hostport='''1.3'''
+
   args: -device usb-host,hostbus=<span style="color:#FF0000">1</span>,hostport=<span style="color:#FF0000">1.3</span>
  
 
=== Stop and restart the VM ===
 
=== Stop and restart the VM ===
Line 57: Line 61:
 
   Device 0.2, Port 1, Speed 12 Mb/s, Product QEMU USB Tablet
 
   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 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'''
+
   <span style="color:#FF0000">Device 1.1, Port 1, Speed 1.5 Mb/s, Product HASP 2.17</span>
   '''Device 1.0, Port 2, Speed 480 Mb/s, Product USB Host Device'''
+
   <span style="color:#FF0000">Device 1.0, Port 2, Speed 480 Mb/s, Product USB Host Device</span>
  
 
== References ==
 
== References ==
Line 64: Line 68:
 
* [[Manual: vm.conf|man vm.conf]]  
 
* [[Manual: vm.conf|man vm.conf]]  
 
* http://www.kraxel.org/cgit/qemu/tree/docs/usb2.txt
 
* http://www.kraxel.org/cgit/qemu/tree/docs/usb2.txt
 +
 +
== See also ==
 +
 +
* [[USB Devices in Virtual Machines]] - general aspects about assigning USB devices to VMs

Latest revision as of 11:04, 16 June 2023

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.2, 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
  • Example: Bus 3, Port 1.2 => 3-1.2

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

Proxmox 2.x and later

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

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

Proxmox 1.x

  • Example 1:
 args: -device usb-host,hostbus=3,hostport=1.2
  • 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

See also