USB passthrough doesn't work anymore with qemu-kvm 1.1.1

Bug #1033727 reported by Klaus Hochlehnert on 2012-08-07
62
This bug affects 11 people
Affects Status Importance Assigned to Milestone
QEMU
Undecided
Unassigned
qemu (Ubuntu)
Undecided
Unassigned
Raring
Undecided
Unassigned
qemu-kvm (Debian)
Fix Released
Unknown
qemu-kvm (Ubuntu)
Medium
Unassigned
Quantal
Medium
Unassigned

Bug Description

====================================
SRU Justification:
1. Impact: usb devices which worked with qemu previously stop working
2. Development fix: a patch upstream entitled uhci: Don't queue up packets after one with the SPD flag set fixes the problem
3. Stable fix: same patch as development fix.
4. Test case: you must test with certain usb devices - see below for the exact kvm arguments to use.
5. Regression potential: this patch is cherrypicked from upstream so should be safe.
====================================

Hi,

I have a "Bus 006 Device 002: ID 0d46:3003 Kobil Systems GmbH mIDentity Light / KAAN SIM III" (kind of smart card) in an USB port which I make available to a Windows XP guest.
This worked fine with every older qemu-kvm version I've used so far.

But since 1.1.0 it doesn't work anymore.
The device shows up in the guest, but the software can't access it anymore (and the guest is pretty unresponsive).

On the host I get every 2 seconds this message:
[ 7719.239528] usb 6-1: reset full-speed USB device number 2 using uhci_hcd

Command line options are:
/usr/bin/kvm
...
-device usb-host,vendorid=0x0d46,productid=0x3003,bus=usb.0,port=3
...

When I switch back to qemu-kvm 1.0.1 everything works fine again.
Any idea what the problem could be?

Thanks
Klaus

description: updated
description: updated
Iggy (iggy-theiggy) wrote :

You should use git to bisect (the qemu tree) where it broke.

I think similar bug has been filed against qemu-kvm debian package (http://bugs.debian.org/683983). Will try to reproduce/bisect as time permits. Note the debian bugreport also mentions segfault on usb_del in monitor.

Ok. I tried to bisect this, but it appears to be not so easy. The problem is that between 1.0 and 1.1, there's a lot of usb breakage, and bisection leads to segfaults or assertion failures.

(qemu) usb_add host:003.002
usb_create: no bus specified, using "usb.0" for "usb-host"
(qemu) Segmentation fault

This is fixed in 8db36e9dddb1b6fab3554a8c00d92268b33a487b.

(qemu) usb_add host:003.002
(qemu) qemu-system-x86_64: /build/kvm/git/hw/usb.c:358: usb_packet_complete: Assertion `p->state == USB_PACKET_QUEUED' failed.

I skipped this commit, which lead to:

(qemu) usb_add host:003.002
(qemu) qemu-system-x86_64: /build/kvm/git/hw/usb.c:410: usb_packet_complete: Assertion `((&ep->queue)->tqh_first) == p' failed.

I'm continuing, but I've no much hope this will lead to anything useful at this rate.

Changed in qemu-kvm (Debian):
status: Unknown → Confirmed

I just tested with qemu-kvm 1.2.0
But basically still the same problem. Device shows up in the guest, but the software can't access it anymore.

Just the guest isn't unresponsive anymore.
And the dmesg message happens now only once in a while (but always two very close together):
[ 4066.239358] usb 6-1: reset full-speed USB device number 2 using uhci_hcd
[ 4066.498921] usb 6-1: reset full-speed USB device number 2 using uhci_hcd

FWIW, Gerd Hoffmann suggested to enable all usb_host_* tracepoints & send log.

I guess he is referring to --enable-trace-backend configure option. See docs/tracing.txt in the qemu source for more details (http://git.qemu.org/?p=qemu.git;a=blob;f=docs/tracing.txt)

Uwe (gandalf.the.grey) wrote :

I have made the same experiences with Ubuntu 12.10 (qemu-kvm 1.2.0). My SmartCard reader Omnikey 3121 shows up in the guest but no card can be found. No problem with quemu-kvm 1.0 under Ubuntu 12.04. See also my report Bug #1073815.

Just an FYI for people that come across this bug: not all USB devices are affected. USB passthrough is working for me with a Logitech C920 webcam in Ubuntu 12.10 (qemu-kvm 1.2.0), albeit with some video freezing.

Serge Hallyn (serge-hallyn) wrote :

Can someone go ahead and follow up on comment #6? (Marking incomplete in the meantime)

I'll mark as affecting the QEMU project since it has been confirmed against 1.2.0 per comment #4.

Changed in qemu-kvm (Ubuntu):
importance: Undecided → Medium
status: New → Confirmed
Beastyvoid (yvan-skywalker) wrote :

Same here as what Uwe is experiencing : my SmartCard reader Omnikey 3121 shows up in the guest but no card can be found.
With qemu-kvm 1.2.0. Was working great with previous versions.

Peter Schaefer (derschaefer) wrote :

Just confirming the bug. I'm having the same issues with the same USB smart card reader as the submitter (Kobil mIDentity) on Debian Squeeze using the qemu-kvm version 1.2.0 from debian-backports. Going back to 1.0 fixes the problem (http://snapshot.debian.org/package/qemu-kvm/1.0%2Bdfsg-8~bpo60%2B1).

Since I can easily toggle between versions i could provide more support, if wanted and instructions provided...

Peter Schaefer (derschaefer) wrote :

Referring to my last comment: The URL does only work if you add a backslash at the end, sorry about that.

One last note: In Germany, the Kobil USB Reader is/was supplied by DATEV (see http://www.datev.com/) to their members/partners. So, anybody who's running DATEV software on kvm-virtualized systems will run into this problem.

Falk Seyboldt (r1-shopping) wrote :

same here with AVM ISDN-Controller FRITZ!Card v2.1 on openSUSE 12.2.

daniel pecka (dpecka) wrote :

same here with:
Bus 002 Device 006: ID 16d5:6603 AnyDATA Corporation

^^ it is modem and my qemu-kvm version is:
QEMU emulator version 1.2.0 (kvm-1.2.0-178.2)

i can also confirm freezing in previous version ..

regards, d

Serge Hallyn (serge-hallyn) wrote :

@Peter Schaefer,

(replying to comment #12) could you please follow up on comments #6 and #7?

It also would be worthwhile, at this point, checking whether latest upstream (1.3) is still broken.

Am 1/8/2013 6:08 PM, Serge Hallyn wrote:
>
> (replying to comment #12) could you please follow up on comments #6 and
> #7?
>
> It also would be worthwhile, at this point, checking whether latest
> upstream (1.3) is still broken.

Just a short note: I somehow produced a backported *.deb for 1.3.0 and
i managed to recompile the debs of 1.1.2 and 1.0 from debian backports
with "--enable-trace-backend=simple". The problematic box runs Debian
Squeeze with Kernel 3.2.35 (and some other packages) from backports.

Tomorrow evening i'm going to make test runs on the system. I'll keep
you posted.

Regards,
   Peter

Peter Schaefer (derschaefer) wrote :

Hi again!

The good news: 1.3.0 works (at least with my setup). The bad news is that this might lower the motivation to fix 1.1.2 ;-) ...

Attached is the USB trace file from the non-working case with V 1.1.2.

If decompressed, it's an 185 MB text file and - honestly - i cannot make any sense of it, but here you have it... ;-)

There's two USB devices passed-through:

1) vendor=0x529 product=0x1 -> Hardlock USB Dongle
2) vendor=0xd46 product=0x3003 -> Kobil USB Smartcard Reader

HTH,
  Peter

Peter, are you able to run git bisect or something like that, to try to pinpoint either the commit which introduced this issue or which fixed it?

I tried to reproduce this issue several times with various devices, but I can't do it reliable, it always more or less works on my machine. If I were able to, I'd bisect it long time ago.

Now, to clarify things, I've no idea how USB works internally and how it is implemented in qemu, for this issue I can only do a bisection to find the changes which change the issue.

You can ping me by email or hit me on IRC (I'm mjt at freenode.net and oftc.net) if you're willing to debug it further and need help in doing that.

Besides, what are the sympthoms of the device non-working? Does it happen with linux guest too? Have you tried re-running the guest again when the problem occur, using the same problematic version of qemu - I mean, is it 100% reproducible or happens at random?

Thank you!

Peter Schaefer (derschaefer) wrote :

Hello Michael,

Am 1/12/2013 1:24 PM, Michael Tokarev wrote:

> Peter, are you able to run git bisect or something like that, to try to
> pinpoint either the commit which introduced this issue or which fixed
> it?

Well, i'm no expert at git, but i made some progress, see below.

> Besides, what are the sympthoms of the device non-working? Does it
> happen with linux guest too? Have you tried re-running the guest again
> when the problem occur, using the same problematic version of qemu - I
> mean, is it 100% reproducible or happens at random?

In my case it's the SmartCard-Reader that's not working, i.e. the DATEV Software called "Sicherheitspaket" does not
work. The background process called "SiPaHost.exe" just hangs; any client program trying to display SmartCard
information does also just hang forever. That behaviour is 100% reproducible and persists over reboots of the Linux host
and/or the Windows guest (Windows XP SP3). I did not try Linux guests.

Yesterday, i used git to checkout all qemu-kvm versions from kernel.org and build Debian packets from it (source kept
vanilla, i just applied the two patches that rename paths from 'qemuXXX' to 'kvmXXX').

The findings were:

- v1.0 -> ok
- v1.0.1 -> ok
- v1.1.0 -> not ok
- v1.1.1 -> not ok
- v1.1.2 -> not ok
- v1.2.0 -> not ok

So far, this is consistent with the findings in this bug report.

BUT: The latest HEAD from kernel.org (called "v1.2.50") also does work again!

So, i'm now learning about git bisect (however, today i won't have time for this).

Regards,
Peter

Peter Schaefer (derschaefer) wrote :

Hi,

well - it's probably only for historic interest, but if i made no bisecting mistake, this commit has fixed it (note that
the meaning of 'good' and 'bad' is swapped due to how git bisect works):

root@debian:~/qemu_git/qemu-kvm# git bisect good
Bisecting: 87 revisions left to test after this (roughly 7 steps)
[c26032b2c91721245bfec542d94f37a0238e986e] target-xtensa: don't emit extra tcg_gen_goto_tb
root@debian:~/qemu_git/qemu-kvm# git bisect good
Bisecting: 43 revisions left to test after this (roughly 6 steps)
[1fd959466574c3d46f4898f2e27cd3b1060338e4] tcg-sparc: Mask shift immediates to avoid illegal insns.
root@debian:~/qemu_git/qemu-kvm# git bisect bad
Bisecting: 24 revisions left to test after this (roughly 5 steps)
[e55f523d7977480462151d8abb0ebb4b1747eabf] tcg-hppa: Fix broken load/store helpers
root@debian:~/qemu_git/qemu-kvm# git bisect good
Bisecting: 12 revisions left to test after this (roughly 4 steps)
[09054d19e72f6991cd359d41c479badd92f62a06] usb-redir: Add chardev open / close debug logging
root@debian:~/qemu_git/qemu-kvm# git bisect good
Bisecting: 6 revisions left to test after this (roughly 3 steps)
[a221ae3fcc55fcc3911587bc572af88eed3342dd] tcg-sparc: Fix ADDX opcode.
root@debian:~/qemu_git/qemu-kvm# git bisect bad
Bisecting: 2 revisions left to test after this (roughly 2 steps)
[cfb75cb9807463ebe18b127096b48b5d0db1ce03] Merge branch 'usb.65' of git://git.kraxel.org/qemu
root@debian:~/qemu_git/qemu-kvm# git bisect bad
Bisecting: 0 revisions left to test after this (roughly 1 step)
[72a04d0c178f01908d74539230d9de64ffc6da19] uhci: Don't queue up packets after one with the SPD flag set
root@debian:~/qemu_git/qemu-kvm# git bisect bad
Bisecting: 0 revisions left to test after this (roughly 0 steps)
[35efba2cc6812dc980c336d7b9bf81dbfb5daf00] usb-redir: Revert usb-redir part of commit 93bfef4c
root@debian:~/qemu_git/qemu-kvm# git bisect good
72a04d0c178f01908d74539230d9de64ffc6da19 is the first bad commit
commit 72a04d0c178f01908d74539230d9de64ffc6da19
Author: Hans de Goede <email address hidden>
Date: Wed Sep 12 15:08:40 2012 +0200

     uhci: Don't queue up packets after one with the SPD flag set

     Don't queue up packets after a packet with the SPD (short packet detect)
     flag set. Since we won't know if the packet will actually be short until it
     has completed, and if it is short we should stop the queue.

     This fixes a miniature photoframe emulating a USB cdrom with the windows
     software for it not working.

     Signed-off-by: Hans de Goede <email address hidden>
     Signed-off-by: Gerd Hoffmann <email address hidden>

:040000 040000 18e7490171762dec04cb8ce49fd21e0b685b53b2 86f7cb33d8b77828e671c5fb39c9d137d39eca06 M hw
root@debian:~/qemu_git/qemu-kvm#

HTH.

Regards,
  Peter

Nikolaus Rath (nikratio) wrote :

Thanks a lot Peter! I can confirm that this patch fixes the problems when added on top of Debian's qemu-kvm 1.1.2+dfsg-4 package. I have attached a patch against the Debian git tree.

Nikolaus Rath (nikratio) wrote :

The attachment "Patch against debian package" of this bug report has been identified as being a patch in the form of a debdiff. The ubuntu-sponsors team has been subscribed to the bug report so that they can review and hopefully sponsor the debdiff. In the event that this is in fact not a patch you can resolve this situation by removing the tag 'patch' from the bug report and editing the attachment so that it is not flagged as a patch. Additionally, if you are member of the ubuntu-sponsors team please also unsubscribe the team from this bug report.

[This is an automated message performed by a Launchpad user owned by Brian Murray. Please contact him regarding any issues with the action taken in this bug report.]

tags: added: patch

Thank you very much Peter for the work you did. That is not of historic interest, not at all - it is of a good value for Debian users!

And thank you Nikolaus for the testing, as well!

I take your (both of you!) words that the problem is now solved, and am uploading new release to debian archives right now. At least it didn't break things for me, -- I tested the resulting build and it works with my usb devices, there's no immediately visible regression. So hopefully the bug is now fixed and I'm closing it in Debian.

Thank you again!

Changed in qemu:
status: New → Fix Released
Changed in qemu-kvm (Debian):
status: Confirmed → Fix Released
Marc Deslauriers (mdeslaur) wrote :

This is likely fixed with the qemu version in raring. Unsubscribing ubuntu-sponsors.

Changed in qemu (Ubuntu Raring):
status: New → Fix Released
Changed in qemu (Ubuntu Quantal):
status: New → Invalid
Changed in qemu-kvm (Ubuntu Quantal):
status: New → Confirmed
importance: Undecided → Medium
Changed in qemu-kvm (Ubuntu Raring):
status: Confirmed → Invalid
no longer affects: qemu-kvm (Ubuntu Raring)
Changed in qemu-kvm (Ubuntu Quantal):
assignee: nobody → Serge Hallyn (serge-hallyn)
no longer affects: qemu (Ubuntu Quantal)
description: updated
Changed in qemu-kvm (Ubuntu Quantal):
status: Confirmed → In Progress
assignee: Serge Hallyn (serge-hallyn) → nobody

Hello Klaus, or anyone else affected,

Accepted qemu-kvm into quantal-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/qemu-kvm/1.2.0+noroms-0ubuntu2.12.10.3 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in qemu-kvm (Ubuntu Quantal):
status: In Progress → Fix Committed
tags: added: verification-needed
Stefan Mühlbacher (freisei) wrote :

High!

Tryed:
apt-get install qemu-kvm/quantal-proposed
reboot

Feb 26 18:24:03 wbmain1 kernel: [ 651.947372] usb 8-2: reset full-speed USB device number 2 using uhci_hcd
Feb 26 18:24:06 wbmain1 kernel: [ 655.077459] usb 8-2: reset full-speed USB device number 2 using uhci_hcd

root@wbmain1:~# lsusb
Bus 005 Device 002: ID 0000:0000
Bus 008 Device 002: ID 0d46:3003 Kobil Systems GmbH mIDentity Light / KAAN SIM III
[..]
root@wbmain1:~# uname -a
Linux wbmain1 3.5.0-25-generic #38-Ubuntu SMP Mon Feb 18 23:27:42 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
root@wbmain1:~# kvm -version
QEMU emulator version 1.2.0 (qemu-kvm-1.2.0+noroms-0ubuntu2.12.10.3, Debian), Copyright (c) 2003-2008 Fabrice Bellard

Same problem as before update: Can see Kobil-Reader in Win-VM but doesnt work correctly. Even it seems to be faster then before update.

Greets Freisei

Just tried and plugged in a Smartphone. Results in a BSOD.

Stefan Mühlbacher (freisei) wrote :

Tryed Mainline-Kernel 3.8

root@wbmain1:~# uname -a
Linux wbmain1 3.8.0-030800-generic #201302181935 SMP Tue Feb 19 00:36:19 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Same problem...

Stefan Mühlbacher (freisei) wrote :

Very intresting News:

After reverting to Ubuntu 9.10/Qemu 0.11.0 the USB-SIM-Reader didn´t work anymore. Same results as above.

Maybe the qemu-version 1.2.0 caused the "Kobil Systems GmbH mIDentity Light / KAAN SIM III" to hang! After unplugging and plugin in to another usb-port it works again. Now the server is in production use for 12 hours, then i can test again on the patched 1.2.0-version (qemu-kvm-1.2.0+noroms-0ubuntu2.12.10.3, Debian)

Greets Freisei

Stefan Mühlbacher (freisei) wrote :

Hello,

OK now.

Linux wbmain1 3.5.0-25-generic #38-Ubuntu SMP Mon Feb 18 23:27:42 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
root@wbmain1:~# kvm -version
QEMU emulator version 1.2.0 (qemu-kvm-1.2.0+noroms-0ubuntu2.12.10.3, Debian), Copyright (c) 2003-2008 Fabrice Bellard (Proposal)

Usb-Passthrough with "Kobil Systems GmbH mIDentity Light / KAAN SIM III" WORKS!

Greets Freisei.

The verification of this Stable Release Update has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regresssions.

tags: added: verification-done
removed: verification-needed
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package qemu-kvm - 1.2.0+noroms-0ubuntu2.12.10.3

---------------
qemu-kvm (1.2.0+noroms-0ubuntu2.12.10.3) quantal-proposed; urgency=low

  [ Nikolaus Rath ]
  * fix-usb-passthrough.patch: fix problems with accessing some host
    USB devices (Closes: 683983) (LP: #1033727)
 -- Serge Hallyn <email address hidden> Tue, 29 Jan 2013 22:26:54 -0600

Changed in qemu-kvm (Ubuntu Quantal):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.