2

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.

stenio
  • 63
  • 1
  • 1
  • 6
  • 1
    Try getting rid of the USB hub. – Michael Hampton Jan 27 '15 at 18:04
  • Without the hub the printing process does not complete properly. – stenio Jan 27 '15 at 18:07
  • Just tried to attach the USB cable directly to the server. The printer is seen perfectly by the guest which assigns to it virtual port USB001. But now when I try to print something the page is splitted in different parts! During the printing of the page I can see that 193KB/1.02MB where sent and then the job stops and restarts with a different page. This was the reason that forced me to use the hub. – stenio Jan 28 '15 at 09:06
  • What about passing through the physical port of the host rather than a particular device ? Try something like [the following](http://pastebin.com/raw.php?i=9hMceQ10), replace XXX with the bus number on the host and YYY with the port number. Also the fact that (as far as I know) it attaches the `usb-host` device to the first (0) port of the newly created USB device `passthroughehci` may help. –  Feb 12 '15 at 11:29
  • Thank you @AndréDaniel It seems a great idea. I've just edited the post with new infos. – stenio Feb 12 '15 at 15:33
  • I forgot to set the namespace in the libvirt xml file... – stenio Feb 12 '15 at 15:39
  • Looks like your printer is an USB1 device (12M), try using `ich9-usb-uhci1` as the controller instead of `ich9-usb-ehci1`. –  Feb 12 '15 at 19:17

0 Answers0