Bug 1382331

Summary: Redirected usb-hid devices do not work when using an emulated xhci controller
Product: [Fedora] Fedora Reporter: Hans de Goede <hdegoede>
Component: qemuAssignee: Fedora Virtualization Maintainers <virt-maint>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 25CC: amit.shah, berrange, cfergeau, dwmw2, hdegoede, itamar, kraxel, pbonzini, rjones, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-2.7.0-3.fc25 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-10-12 18:57:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
qemu-2.7.0-usb-redirect-wakeup.patch none

Description Hans de Goede 2016-10-06 11:27:06 UTC
Description of problem:
Redirected usb-hid devices do not work when using an emulated xhci controller

Version-Release number of selected component (if applicable):
qemu-2.7.0-1.fc25.x86_64


How reproducible:

Steps to Reproduce:
1. Start qemu-system-x86_64 with -device nec-usb-xhci + options needed for spice usb-redirection
2. Connect to qemu with e.g. remote-viewer, select a usb-hid device keyboard to redirect
3. Try to use redirected keyboard in guest, nothing happings

Actual results:
Try to use redirected keyboard in guest, nothing happings.

Expected results:
Redirected keyboard can be used to type in guest.

Additional info:

Things do work when replacing "-device nec-usb-xhci" with "-readconfig /etc/qemu/ich9-ehci-uhci.cfg" on the qemu commandline, suggesting that this is a problem with interrupt endpoint handling in the xhci emulation.

remote-viewer in Fedora 25 currently has issues with updating the guest screen, see bug 1382325, when testing with spice either use the workaround described there, or a Fedora 24 spice-client. Note this should reproduce with host-redirection too, so using spice is not necessary.

Comment 1 Gerd Hoffmann 2016-10-07 09:28:50 UTC
> Things do work when replacing "-device nec-usb-xhci" with "-readconfig
> /etc/qemu/ich9-ehci-uhci.cfg" on the qemu commandline, suggesting that this
> is a problem with interrupt endpoint handling in the xhci emulation.
> 
> Note this should reproduce
> with host-redirection too, so using spice is not necessary.

Well, it doesn't, usb-host is doing fine.

I suspect it is a missing usb_wakeup() call somewhere in the redirection code.

ehci and uhci don't fall over in that case because we must poll anyway for correctness reasons.  Worst case is a delay in case ehci throttles polling due to inactivity on the usb bus.  xhci depends on wakeup calls though.  The different hardware design allows us to *not* poll constantly.

Care to have a look?  You know the redirection code better than me ...

Comment 2 Hans de Goede 2016-10-10 08:54:12 UTC
Created attachment 1208771 [details]
qemu-2.7.0-usb-redirect-wakeup.patch

Hi Gerd,

You were right, although the wakeup was there it was being called too early, it seems that now a days more work is done directly (rather then being scheduled) as a result of the call to wakeup and usbredir.c was not ready to handle this when it called usb_wakeup(). This patch fixes this. I've kicked of F25+ builds with this patch and I'll create an update.

Can you take care of upstreaming this ? Feel free to add my S-o-b, I created the patch using the Fedora pkgs, as I no longer have a qemu git clone around.

Regards,

Hans

Comment 3 Fedora Update System 2016-10-11 04:56:21 UTC
qemu-2.7.0-3.fc25 has been pushed to the Fedora 25 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-1db1147b8e

Comment 4 Fedora Update System 2016-10-12 18:57:56 UTC
qemu-2.7.0-3.fc25 has been pushed to the Fedora 25 stable repository. If problems still persist, please make note of it in this bug report.