USB Physical Port Mapping: Difference between revisions

From Proxmox VE
Jump to navigation Jump to search
No edit summary
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
== PVE version 2.x  ==
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).


To map hardware usb port use the following instructions:
== Map hardware USB port ==


1. Find out physical port parameters (bus and port). On host run:
=== Find out physical port parameters (bus and port) ===


==== Through Qemu/KVM tool (simpler) ====
'''qm monitor ''<VM_ID>'''''
qm&gt; '''info usbhost'''
  <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
  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 => <span style="color:#FF0000">3-1.2</span>
==== Or from the host ====
  '''lsusb -t'''
  '''lsusb -t'''
  /: Bus 05.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
  /: 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 04.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
  /: Bus 0'''3'''.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 1''': Dev 4, If 0, Class=vend., Driver=usbfs, 1.5M
|__ Port 2: Dev 5, 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 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/8p, 480M  
  /: '''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
2. Edit the VM config file and add the following entry:<br>
        |__ '''Port 3''': Dev 5, If 0, Class=comm., Driver=usbfs, 480M
 
        |__ Port 3: Dev 5, If 1, Class=data, Driver=usbfs, 480M
'''usb0: host=3-1'''
 
Which corresponds to Bus number 3 and Port number 1.
 
3. Power off/power on VM.


<br>  
* Example 1: Bus 3, Port 1 => <span style="color:#FF0000">3-1</span>
* Example 2: Bus 1, Port 1, Port 3 => <span style="color:#FF0000">1-1.3</span>


----
=== Add the device to the VM ===


== PVE version 1.==
==== Proxmox 2.x and later ====


To map hardware usb port use the following instructions:  
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:
  usb0: host=<span style="color:#FF0000">3</span>-<span style="color:#FF0000">1</span>
  usb1: host=<span style="color:#FF0000">1</span>-<span style="color:#FF0000">1.3</span>


1. Find out physical port parameters (bus and port)
==== Proxmox 1.x ====


   qm monitor NNN
* Example 1:
qm&gt; info usbhost
   args: -device usb-host,hostbus=<span style="color:#FF0000">3</span>,hostport=<span style="color:#FF0000">1.2</span>
'''Bus 3''', Addr 2, '''Port 1''', Speed 1.5 Mb/s
* Example 1:
Vendor Specific: USB device 0529:0001, HASP 2.17
  args: -device usb-host,hostbus=<span style="color:#FF0000">3</span>,hostport=<span style="color:#FF0000">1</span>
Bus 5, Addr 3, Port 2, Speed 12 Mb/s
* Example 2:
Class 00: USB device 0624:0248, USB Composite Device-0
  args: -device usb-host,hostbus=<span style="color:#FF0000">1</span>,hostport=<span style="color:#FF0000">1.3</span>


2. Add the device to the particular VM (/etc/qemu-server/NNN.conf)
=== Stop and restart the VM ===


  args: -device usb-host,hostbus='''3''',hostport='''1'''
Stop and start the VM (a reboot is not enought).


or (as Proxmox 2.x supports usbN in vm.conf)
Check that the USB devices are seen by the VM:


  usb0: host='''3'''-'''1'''
'''qm monitor ''<VM_ID>'''''
qm&gt; '''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
  <span style="color:#FF0000">Device 1.1, Port 1, Speed 1.5 Mb/s, Product HASP 2.17</span>
  <span style="color:#FF0000">Device 1.0, Port 2, Speed 480 Mb/s, Product USB Host Device</span>


3. Power off/power on VM and check
== References ==


  qm monitor NNN
* [[Manual: vm.conf|man vm.conf]]
qm&gt; info usb
* http://www.kraxel.org/cgit/qemu/tree/docs/usb2.txt
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.4, Port 2.1, Speed 1.5 Mb/s, Product HASP 2.17'''


More information:
== See also ==


#[[Manual: vm.conf|man vm.conf]]  
* [[USB Devices in Virtual Machines]] - general aspects about assigning USB devices to VMs
#http://www.kraxel.org/cgit/qemu/tree/docs/usb2.txt

Revision as of 12:33, 20 January 2016

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