I have a HP plotter connected with a USB cable to a debian server through a USB hub. On the server there is a virtualized Windows XP. Everytime I reboot the plotter a different device number is assigned by udev to the plotter which has the effect to change the virtual printer port assigned to the plotter by Windows.
It seems that it's not possible to force udev to use the same devnum, so I should force libvirth to pass a fixed bus address.
I'm currently using the following code with libvirt attach-device
:
<hostdev mode='subsystem' type='usb' managed='yes'>
<source>
<vendor id='0x0123'/>
<product id='0x0456'/>
</source>
</hostdev>
I can write a rule for udev to create a device with a fixed name. It should be great if in this way the device could be seen from the guest as always attached to the same USB port. Do you know if it is possible?
Edit:
I'm trying to follow the suggestion of André. I'm not sure what to put on the hostbus and hostport parameters for the device #8.
# lsusb -t
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/2p, 480M
|__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/6p, 480M
|__ Port 2: Dev 3, If 0, Class=HID, Driver=usbfs, 1.5M
|__ Port 3: Dev 4, If 0, Class=hub, Driver=hub/4p, 480M
|__ Port 1: Dev 8, If 0, Class=print, Driver=usbfs, 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/6p, 480M
This was my first attempt:
<qemu:commandline>
<qemu:arg value='-device'/>
<qemu:arg value='ich9-usb-ehci1,id=passthroughehci'/>
<qemu:arg value='-device'/>
<qemu:arg value='usb-host,hostbus=002,hostport=001,bus=passthroughehci.0'/>
</qemu:commandline>
But it didn't work.