[fedora-virt] USB devices get reset a few seconds after attaching them to guest and then get binded to host

Hans de Goede hdegoede at redhat.com
Tue Dec 31 09:46:38 UTC 2013


On 12/30/2013 05:03 PM, Stewart Adam wrote:
> On 2013-12-30 10:37 AM, Hans de Goede wrote:
>> Hi,
>> On 12/29/2013 08:44 AM, Stewart Adam wrote:
>>> Hi,
>>> I have been attempting to attach a USB keyboard & mouse from the host to a
>>> Windows 7 guest using QEMU's USB2 controller. The keyboard seems to attach
>>> correctly, however I have trouble with certain mice and devices. When
>>> starting the guest, the devices remain attached for a second or two, then
>>> they disconnect. the libvirt logs show that it no longer sees the USB
>>> device, and I see this in dmesg:
>>> [   10.876071] usb 3-13: reset full-speed USB device number 2 using xhci_hcd
>>> [   10.888206] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with
>>> disabled ep ffff88041917f740
>>> [   10.888209] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with
>>> disabled ep ffff88041917f800
>>> [   10.888210] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with
>>> disabled ep ffff88041917f7c0
>>> [   11.041209] usb 3-14: reset full-speed USB device number 3 using xhci_hcd
>>> [   11.054379] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with
>>> disabled ep ffff8800c8d559c0
>>> [   11.054383] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with
>>> disabled ep ffff8800c8d55440
>>> <repeats for some time>
>>> [   87.476806] usb 3-14: new full-speed USB device number 4 using xhci_hcd
>>> [   87.491908] usb 3-14: New USB device found, idVendor=046d, idProduct=c066
>>> [   87.491911] usb 3-14: New USB device strings: Mfr=1, Product=2,
>>> SerialNumber=3
>>> [   87.491912] usb 3-14: Product: G9x Laser Mouse
>>> [   87.491914] usb 3-14: Manufacturer: Logitech
>>> [   87.491914] usb 3-14: SerialNumber: 081BB92CA70018
>>> [   87.494697] input: Logitech G9x Laser Mouse as
>>> /devices/pci0000:00/0000:00:14.0/usb3/3-14/3-14:1.0/input/input16
>>> [   87.494994] hid-generic 0003:046D:C066.0008: input,hidraw0: USB HID
>>> v1.11 Mouse [Logitech G9x Laser Mouse] on usb-0000:00:14.0-14/input0
>>> [   87.498834] input: Logitech G9x Laser Mouse as
>>> /devices/pci0000:00/0000:00:14.0/usb3/3-14/3-14:1.1/input/input17
>>> [   87.499078] hid-generic 0003:046D:C066.0009: input,hiddev0,hidraw1: USB
>>> HID v1.11 Keyboard [Logitech G9x Laser Mouse] on usb-0000:00:14.0-14/input1
>>> As you can see the device re-attaches to the host. The device is plugged
>>> into a USB2 port, but it appears to be controlled by Intel's XHCI controller:
>>> 00:14.0 USB controller [0c03]: Intel Corporation 8 Series/C220 Series
>>> Chipset Family USB xHCI [8086:8c31] (rev 04)
>> What seems to be happening is that the guest is getting errors when talking
>> to the device and keeps resetting
>> the device. And at one point in time the many resets lead to a disconnect /
>> reset.
> Hi Hans,
> In the interim to get things working I ended up passing through the entire PCI controller (all USB ports) to Windows and the same device doesn't reset with the Windows native xHCI driver.
> I can easily undo that and I'll run some tests again with USB redirection.

Correct, and I've written some fixes for that recently which are not in F-20 I
believe, which are related to reset handling. So I believe that this will
likely be fixed in F-21 likely (or maybe with an F-20 update, depending on
if upstream adds them to a bugfix release of the existing qemu).

So if you've a working solution for now, it may be best to just retest with

>> So the problem is the many resets. What usb redirection are you using, are
>> you using qemu's host redirection,
>> or are you using spice's usb redirection. If you don't know please describe
>> how you're redirecting the
>> devices (ie which cmdline you use, or which gui options you choose).
> I'm using libvirt & virt-manager as well as 'virsh attach-device' from the command line, so if I am not mistaken this is QEMU's host USB passthrough.
>> If you're using qemu's host redirection code can you retry with spice's
>> usbredir code ?
> Is this possible by tweaking libvirt? Note that I'm also running VFIO VGA passthrough so I don't have a spice display... I don't know if that makes a difference.

That is a bit tricky, without a spice display you need to use usbredirserver
to export the devices (a small standalone app to share a usbdevice over tcp)
and configure a tcp connection rather then a spice one when adding a usbredir
device in virt-manager (you can do this from the ui).



More information about the virt mailing list