[libvirt-users] Reconnection problem with a USB device

This is going to be a bit off the wall as I doubt many people are using a VM in quite the same manner as I am in this case. I have a new scanner at home, a Mustek A3USB 1200 Pro, which requires a vendor supplied version of libsane to run. That is a pain in the behind just to start with. To use that scanner requires a 32b machine with sufficiently old versions of various libraries. My primary machine, a laptop, is 64b and runs current software. So, in order to use my inexpensive large format scanner, I had to set up a 32b VM on my laptop that is running an old linux. I tunneled the USB device to it: <hostdev mode='subsystem' type='usb' managed='no'> <source> <vendor id='0x055f'/> <product id='0x040b'/> <address bus='3' device='8'/> </source> <alias name='hostdev0'/> </hostdev> That works fine... until I have to go into the office. Once I disconnected the USB go away for 10 hours and come back, it fails to re-engage. The USB seems to get grabbed up by the laptop itself instead of the VM. The only way to get it to work again is to halt the VM and do a cold boot of it. This is annoying to say the least because I lose 'state' when I boot, ie the set of windows and files open that remind me of where I left off on a project before going to work. Any suggestions how to get around this annoying issue?

On Tue, 2012-06-12 at 11:02 -0700, Dale Amon wrote:
I tunneled the USB device to it:
<hostdev mode='subsystem' type='usb' managed='no'> <source> <vendor id='0x055f'/> <product id='0x040b'/> <address bus='3' device='8'/> </source> <alias name='hostdev0'/> </hostdev>
That works fine... until I have to go into the office. Once I disconnected the USB go away for 10 hours and come back, it fails to re-engage. The USB seems to get grabbed up by the laptop itself instead of the VM. The only way to get it to work again is to halt the VM and do a cold boot of it. This is annoying to say the least because I lose 'state' when I boot, ie the set of windows and files open that remind me of where I left off on a project before going to work.
Any suggestions how to get around this annoying issue?
I could be wrong. But I believe you want managed='yes' so that libvirtd detaches the device from the host automatically. Dax Kelson

On Tue, Jun 12, 2012 at 02:09:12PM -0600, Dax Kelson wrote:
On Tue, 2012-06-12 at 11:02 -0700, Dale Amon wrote:
I tunneled the USB device to it:
<hostdev mode='subsystem' type='usb' managed='no'> <source> <vendor id='0x055f'/> <product id='0x040b'/> <address bus='3' device='8'/> </source> <alias name='hostdev0'/> </hostdev>
I could be wrong. But I believe you want managed='yes' so that libvirtd detaches the device from the host automatically.
Sounds like a reasonable idea. I will try that this evening.

On Tue, Jun 12, 2012 at 02:00:34PM -0700, Dale Amon wrote:
On Tue, Jun 12, 2012 at 02:09:12PM -0600, Dax Kelson wrote:
On Tue, 2012-06-12 at 11:02 -0700, Dale Amon wrote:
I tunneled the USB device to it:
<hostdev mode='subsystem' type='usb' managed='no'> <source> <vendor id='0x055f'/> <product id='0x040b'/> <address bus='3' device='8'/> </source> <alias name='hostdev0'/> </hostdev>
I could be wrong. But I believe you want managed='yes' so that libvirtd detaches the device from the host automatically.
Seemed like a good idea and it may have done some good, but if I disconnect the USB connector to the scanner and then reconnect it, an lsusb in the VM does not see it again. I have to reboot the VM to get it back.

On Tue, 2012-06-12 at 18:26 -0700, Dale Amon wrote:
Seemed like a good idea and it may have done some good, but if I disconnect the USB connector to the scanner and then reconnect it, an lsusb in the VM does not see it again. I have to reboot the VM to get it back.
You might be able to use some combination of the following commands so you don't have to reboot the VM: nodedev-reset nodedev-reattach nodedev-detach (see the virsh man page) Possibly use can create a UDEV rule (running some combination of the commands above) on the host so that if you hot plug the USB scanner it will hot add it to the VM. Dax Kelson
participants (2)
-
Dale Amon
-
Dax Kelson