USB passtrough with 2 identical USB devices

tordan32

New Member
Jan 8, 2023
1
0
1
Hello,

I struggle with a USB problem since a few days, may anybody here has a solution for this issue

* proxmox host system is an older Intel NUC, newest proxmox ve installed
* the host running a few VMs and Containers
* One of them is a Ubuntu Server VM in which I would passhtrough two identical USB devices (conncted to the host/intel nuc)
* first i made the easy way and added the tow usb devices on the proxmox webgui: vm -> hardware -> add usb -> Use USB Port (e.g. host=4-1.5.1
* so i selected the both devices and added them to the vm
* on the VM I created a udev rule and assigned the USB devices a symlink by the serial id of the usb devices -> everything works great

As i booted the VM host a few days later i realized that the usb devices / symlinks at the VM did not work anly onger, they got a new bus/addr id on the host - i know that ubuntu assigns random bus/addr id after connecting or restart.

How can i manage that the hosts passthroughs the usb devices correctly to the vm? In my opinion the easiest way would be if i can passhthrough the two identicial devices by a unique value (the serial id from /dev/serial/by-id) from the host to the vm? is this possible? I only found tutorials for passthrough by vendor/product id (I also tried this -> but then only one of the usb devices is visible at the VM guest system)
 
Hello,

I struggle with a USB problem since a few days, may anybody here has a solution for this issue

* proxmox host system is an older Intel NUC, newest proxmox ve installed
* the host running a few VMs and Containers
* One of them is a Ubuntu Server VM in which I would passhtrough two identical USB devices (conncted to the host/intel nuc)
* first i made the easy way and added the tow usb devices on the proxmox webgui: vm -> hardware -> add usb -> Use USB Port (e.g. host=4-1.5.1
* so i selected the both devices and added them to the vm
* on the VM I created a udev rule and assigned the USB devices a symlink by the serial id of the usb devices -> everything works great

As i booted the VM host a few days later i realized that the usb devices / symlinks at the VM did not work anly onger, they got a new bus/addr id on the host - i know that ubuntu assigns random bus/addr id after connecting or restart.

How can i manage that the hosts passthroughs the usb devices correctly to the vm? In my opinion the easiest way would be if i can passhthrough the two identicial devices by a unique value (the serial id from /dev/serial/by-id) from the host to the vm? is this possible? I only found tutorials for passthrough by vendor/product id (I also tried this -> but then only one of the usb devices is visible at the VM guest system)
Unfortunately not possible directly. As you mentioned you can specify the device by vendor/product or bus/port only (kvm would allow also bus/address, but it is not safe either). The only one what you can do: run a script before sarting the vm which figures out the current bus and port by specifying the serial-id, in principle:
Code:
lsusb -v | grep -B 14 iSerial.*<serial-id> | grep Bus
which returns Bus and Device-ID, then you have to get the port number by
Code:
lsusb -t | grep "Bus.<bus-no>\|Dev.*<dev-no>"
The results have to be processed by a script which adapts the VM config file and start finally the VM.
 
That's quite interesting... How a script can do the assignment change ? Is it by doing a change to the vmidxx.conf .. Do you have an example ?
 
That's quite interesting... How a script can do the assignment change ? Is it by doing a change to the vmidxx.conf .. Do you have an example ?
Assuming you have VM 4000, with an already configured usb device (whatever it currently is) and you want to start this VM using the following usb device as ist is found via `lsusb` respectively 'lsusb -t' instead:
Code:
lsusb
Bus 001 Device 006: ID 0fe6:9700 ICS Advent DM9601 Fast Ethernet Adapter

lsusb -t
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/9p, 480M
    |__ Port 3: Dev 6, If 0, Class=, Driver=dm9601, 12M
The script for doing so may loook as follows:
Code:
#!/bin/bash
#startscript for VM 4000 assigning the current device with pattern "9601" in driver name
BUS=`lsusb | grep 9601 | cut -b 7`
PORT=`lsusb -t | grep 9601 | cut -b 14`
sed -i 's/usb0:.*/usb0: host='$BUS'-'$PORT'/g' /etc/pve/qemu-server/4000.conf
qm start 4000

The above is of course a simplified example, in case of more devices from the same type you have to struggle a little bit in order to figure out by an identification criteria (depends on the equipment, there is no general method for this, in some cases it may be really impossible) which is the proper one.