| Branch: | Revision:

root / usb-linux.c @ a74cdab4

History | View | Annotate | Download (53.4 kB)

# Date Author Comment
0225e254 05/09/2011 05:18 pm Stefan Weil

usb-linux: Add missing break statement

cppcheck report:
usb-linux.c:661: warning: Redundant assignment of "len" in switch

Cc: Hans de Goede <>
Cc: Gerd Hoffmann <>
Signed-off-by: Stefan Weil <>
Signed-off-by: Gerd Hoffmann <>

13a9a0d3 05/04/2011 03:11 pm Gerd Hoffmann

usb: move complete callback to port ops

ed3a328d 05/04/2011 01:25 pm Hans de Goede

usb-linux: introduce a usb_linux_alt_setting function

The next patch in this series introduces multiple ways to get the
alt setting dependent upon usb_fs_type, it is cleaner to put this
into its own function.

Note that this patch also changes the assumed alt setting in case...

c43831fb 05/04/2011 01:25 pm Hans de Goede

usb-linux: Get the alt. setting from sysfs rather then asking the dev

At least one device I have lies when receiving a USB_REQ_GET_INTERFACE,
always returning 0 even if the alternate setting is different. This is
likely caused because in practice this control message is never used as...

060dc841 05/04/2011 01:25 pm Hans de Goede

usb-linux: Add support for buffering iso usb packets

Currently we are submitting iso packets to the host one at a time, as we
receive them from the emulated host controller. This has 2 problems:
1) If we were fast enough to submit every packet in time for the next host host...

a0b5fece 05/04/2011 01:25 pm Hans de Goede

usb-linux: Refuse packets for endpoints which are not in the usb descriptor

If an endpoint is not in the usb descriptor we've no idea what kind of
endpoint it is and thus how to handle it, refuse packages in this case.

Signed-off-by: Hans de Goede <>

975f2998 05/04/2011 01:25 pm Hans de Goede

usb-linux: Refuse iso packets when max packet size is 0 (alt setting 0)

Refuse iso usb packets when then max packet size for the endpoint is 0,
this avoids an abort in usb_host_alloc_iso() caused by trying to qemu_malloc
a 0 bytes large buffer.

3a4854b3 05/04/2011 01:25 pm Hans de Goede

usb-linux: We only need to keep track of 15 endpoints

Currently we reserve room for endpoint data for 16 endpoints, but given
that we only use endpoint data for endpoints 1-15, and always index the
array with the endpoint-number - 1, 15 is enough.

Signed-off-by: Hans de Goede <>

bb6d5498 05/04/2011 01:25 pm Hans de Goede

usb-linux: Add support for buffering iso out usb packets

Extend the iso buffering code to also buffer iso out packets, this
fixes for example using usb speakers with usb redirection.

Signed-off-by: Hans de Goede <>

021730f7 04/16/2011 02:24 pm Brad Hards

usb: initialise data element in Linux USB_DISCONNECT ioctl

This isn't used, but leaving it empty causes valgrind noise.

Signed-off-by: Brad Hards <>
Signed-off-by: Stefan Hajnoczi <>

a0102082 04/16/2011 02:24 pm Brad Hards

usb: fix spelling errors in usb-linux.c

Signed-off-by: Brad Hards <>
Signed-off-by: Stefan Hajnoczi <>

7bd427d8 03/21/2011 10:23 am Paolo Bonzini

change all rt_clock references to use millisecond resolution accessors

This was done with:

sed -i '/get_clock\>.*rt_clock/s/get_clock\>/get_clock_ms/' \
$(git grep -l 'get_clock\>.*rt_clock' )
sed -i '/new_timer\>.*rt_clock/s/new_timer\>/new_timer_ms/' \...
0f5160d1 11/16/2010 10:35 pm Hans de Goede

usb-linux: Store devpath into USBHostDevice when usb_fs_type == USB_FS_SYS

This allows us to recreate the sysfspath used during scanning later
(which will be used in a later patch in this series).

Signed-off-by: Anthony Liguori <>

71d71bbd 11/16/2010 10:35 pm Hans de Goede

usb-linux: introduce a usb_linux_get_configuration function

The next patch in this series introduces multiple ways to get the
configuration dependent upon usb_fs_type, it is cleaner to put this
into its own function.

Signed-off-by: Anthony Liguori <>

2cc59d8c 11/16/2010 10:35 pm Hans de Goede

usb-linux: Get the active configuration from sysfs rather then asking the dev

Some devices seem to choke on receiving a USB_REQ_GET_CONFIGURATION ctrl msg
(witnessed with a digital picture frame usb id 1908:1320).
When usb_fs_type == USB_FS_SYS, the active configuration can be read directly...

b373a63a 06/30/2010 11:51 pm Shahar Havivi

Return usb device to host on exit

Signed-off-by: Shahar Havivi <>
Acked-by: Gerd Hoffmann <>
Signed-off-by: Aurelien Jarno <>

00ff227a 06/30/2010 11:51 pm Shahar Havivi

Return usb device to host on usb_del command

Signed-off-by: Shahar Havivi <>
Acked-by: Gerd Hoffmann <>
Signed-off-by: Aurelien Jarno <>

2791104c 05/03/2010 08:39 pm David Ahern

Changes to usb-linux to conform to coding style

Signed-off-by: David Ahern <>
Signed-off-by: Anthony Liguori <>

d4c4e6fd 04/25/2010 09:23 pm Blue Swirl

usb: remove dead assignments, spotted by clang analyzer

Value stored is never read.

Signed-off-by: Blue Swirl <>

ddbda432 03/19/2010 10:27 pm Anthony Liguori

Revert "usb-linux: remove unreachable default in switch statement"

This reverts commit 3c9c706c3b66d838942aba53c0d3fdcdf06c7423.

This breaks build (gcc 4.3.2):
CC usb-linux.o
cc1: warnings being treated as errors
/src/qemu/usb-linux.c: In function 'usb_linux_update_endp_table':...

3c9c706c 03/17/2010 05:41 pm Paul Bolle

usb-linux: remove unreachable default in switch statement

Signed-off-by: Paul Bolle <>
Signed-off-by: Anthony Liguori <>

4491e0f3 03/16/2010 05:55 pm Markus Armbruster

usb: Remove disabled monitor_printf() in usb_read_file()

The monitor_printf() reports failure. Printing is wrong, because the
caller tries various arguments, and expects the function to fail for
some or all.

Disabled since commit 26a9e82a. Remove it.

d0f2c4c6 02/07/2010 01:03 am malc

Do not use dprintf

dprintf is already claimed by POSIX1, and on at least one system
is implemented as a macro


Signed-off-by: malc <>

fd7a446f 02/06/2010 06:14 pm Christian Krause

usb-linux: increase buffer for USB control requests

The WLAN USB stick ZyXEL NWD271N (0586:3417) uses very large
usb control transfers of more than 2048 bytes which won't fit
into the buffer of the ctrl_struct. This results in an error message
"husb: ctrl buffer too small" and a non-working device....

b29a7def 02/05/2010 08:13 pm Paolo Bonzini

usb-linux.c: remove write-only variable

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Blue Swirl <>

9f99cee7 01/26/2010 10:59 pm Kirill A. Shutemov

usb-linux.c: fix warning with _FORTIFY_SOURCE

CC usb-linux.o
cc1: warnings being treated as errors
usb-linux.c: In function 'usb_host_read_file':
usb-linux.c:1204: error: ignoring return value of 'fgets', declared with attribute warn_unused_result
make: *** [usb-linux.o] Error 1...

beb6f0de 01/20/2010 12:31 am Kevin Wolf


Since commit 747bbdf7 QEMU_WARN_UNUSED_RESULT is never defined as it is
conditional on a define from config-host.h which is included only later.
Include that file earlier to get the warnings back.

Reactivating it unfortunately leads to some warnings about unused qdev_init...

eba6fe87 12/18/2009 07:26 pm Gerd Hoffmann

usb-host: check mon before using it.

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

0fe6d12e 12/12/2009 03:59 pm Markus Armbruster

qdev: Rename USBDevice member devname to product_desc

It's not a device name, it's the USB product description string.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Anthony Liguori <>

06384698 12/12/2009 03:59 pm Markus Armbruster

qdev: Separate USB product description from qdev name

Using the qdev name for the product description makes for inconvenient
qdev names.

Put the product description in new USBDeviceInfo member product_desc.
Make usb_qdev_init() use it. No user or guest visible change, since...

556cd098 12/12/2009 03:59 pm Markus Armbruster

qdev: Replace device names containing whitespace

Device names with whitespace require quoting in the shell and in the
monitor. Some of the offenders are also overly long. Some have a
more convenient alias, some don't.

The place for verbose device names is DeviceInfo member desc. The...

0745eb1e 12/03/2009 11:25 pm Markus Armbruster

Fix recently introduced bugs in -usbdevice host

Commit 26a9e82a has the following flaws:

  • It enabled DEBUG.
  • It referenced two properties by the wrong name in
    usb_host_device_open(), which crashes with "qdev_prop_set: property
    "USB Host Device.bus" not found"....
26a9e82a 10/30/2009 03:39 pm Gerd Hoffmann

usb-host: use qdev for -usbdevice + rework.


  • We don't create/delete devices, we attach/detach them instead.
  • The separate autofilter list is gone, we simply walk the list
    of devices directly instead.
  • Autofiltering is done unconditionally now. Non-auto device scan...
dcc7e25f 10/27/2009 07:28 pm Paul Bolle

usb-linux: return USB_RET_STALL on -EPIPE

0) This is an attempt to get an issue in usb-linux.c, for which a patch
was posted about a year ago, finally fixed.

1) Mark Burkley submitted a "EHCI emulation module" for review in in
October 2008 (see: No...

33e66b86 10/07/2009 04:54 pm Markus Armbruster

Check return value of qdev_init()

But do so only where it may actually fail. Leave the rest for the
next commit.

Patchworks-ID: 35167
Signed-off-by: Markus Armbruster <>
Signed-off-by: Anthony Liguori <>

05a91699 10/07/2009 04:54 pm Markus Armbruster

Unbreak USB autoconnect filters

Commit 22f84e73 added a qdev_init() missing on the path through
usb_host_device_open(), but that broke the path through
usb_host_auto_scan(), which already had one. Remove that one.

Patchworks-ID: 35169
Signed-off-by: Markus Armbruster <>...

22f84e73 09/25/2009 06:40 pm Gerd Hoffmann

unbreak usb pass-through on linux.

Changes: * Re-add the 'dev->fd = fd;' line which the qdev patches dropped
by mistake. * call qdev_init() so the newly created usb device is plugged into
a usb port and thus actually visible to the guest.

Signed-off-by: Gerd Hoffmann <>...

b2e3b6e9 09/12/2009 02:18 am malc

Use proper format conversion specifier when printing size_t value

And untabify this while we are at it.

Signed-off-by: malc <>

c4c0e236 09/11/2009 06:19 pm Jim Paris

usb-linux.c: fix buffer overflow

In usb-linux.c:usb_host_handle_control, we pass a 1024-byte buffer and
length to the kernel. However, the length was provided by the caller
of dev->handle_packet, and is not checked, so the kernel might provide
too much data and overflow our buffer....

806b6024 09/09/2009 10:55 pm Gerd Hoffmann

qdev/usb: add usb bus support to qdev, convert drivers.

  • Add USBBus. * Add USBDeviceInfo, move device callbacks here. * Add usb-qdev helper functions. * Switch drivers to qdev.

TODO: * make the rest of qemu aware of usb busses and kill the FIXMEs
added by this patch....

a5d2f727 09/09/2009 10:55 pm Gerd Hoffmann

qdev/usb: make qemu aware of usb busses.

Move usb code from vl.c to usb-bus.c and make it use the new data
structures added by qdev conversion. qemu usb core should be able
to handle multiple USB busses just fine now (untested though).

Kill some usb_*_init() legacy functions, use usb_create_simple()...

179da8af 09/07/2009 10:00 pm Blue Swirl

USB: use opaque parameter passing for monitor handle

Signed-off-by: Blue Swirl <>

660f11be 08/01/2009 12:16 am Blue Swirl

Fix Sparse warnings: "Using plain integer as NULL pointer"

Signed-off-by: Blue Swirl <>

55496240 07/10/2009 09:44 pm Mark McLoughlin

Prefer sysfs for USB host devices

Scanning for devices via /sys/bus/usb/devices/ and using them via the
/dev/bus/usb/<bus>/<device> character devices is the prefered method
on modern kernels, so try that first.

When using SELinux and libvirt, qemu will have access to /sys/bus/usb...

d55ebf55 05/22/2009 06:50 pm Jason Wessel

USB serial device support

Add in a workaround to allow the usb serial devices to work with the
usb pass through mechanism. The ioctl() to request an alternate
interface will always return < 0 for a usb-serial device based on the
kernel driver. This means there is no alternate interface end point....

376253ec 03/06/2009 01:01 am aliguori

monitor: Rework API (Jan Kiszka)

Refactor the monitor API and prepare it for decoupled terminals:
term_print functions are renamed to monitor_* and all monitor services
gain a new parameter (mon) that will once refer to the monitor instance
the output is supposed to appear on. However, the argument remains...

1eec614b 02/06/2009 12:06 am aliguori

toplevel: remove error handling from qemu_malloc() callers (Avi Kivity)

Signed-off-by: Avi Kivity <>
Signed-off-by: Anthony Liguori <>

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

b4e237aa 12/28/2008 05:45 pm blueswir1

Suppress a -Werror=format-security warning

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

68063649 11/22/2008 11:03 pm blueswir1

Native BSD host USB support (Juergen Lock, Lonnie Mendez)

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

47398b9c 11/22/2008 10:04 pm blueswir1

Use qemu_isfoobar and qemu_towombat versions, based on patch by Christoph Egger

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

e41b3910 10/28/2008 08:22 pm pbrook

Use locally defined structure.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

5be8e1f2 10/25/2008 02:47 pm blueswir1

Silence warnings about unused variables

Signed-off-by: Jan Kiszka <>

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

f16a0db3 10/21/2008 07:34 pm aliguori

Keep usb host scanning from leaking file descriptors

If the first case does not succeed, then the usb scanning code will leak file
descriptors on every scan.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

22babebb 10/21/2008 07:27 pm aliguori

Fix broken USB support for Linux host (Bjorn Danielsson)

Make "host:" usb devices work again on systems that have the
file /proc/bus/usb/devices. This was broken in r5441 due to
incorrect logic for the USB_FS_SYS case in usb_host_scan().

Signed-off-by: Bjorn Danielsson <>...

0f431527 10/07/2008 11:06 pm aliguori

Add USB sys file-system support (v8) (TJ)

This patch adds support for host USB devices discovered via:

/sys/bus/usb/devices/* and opened from /dev/bus/usb/*/*
/dev/bus/usb/devices and opened from /dev/bus/usb/*/*

in addition to the existing discovery via:...

ac4ffb5a 09/22/2008 06:04 pm aliguori

Don't use sprintf() or strcpy()

They are unsafe. The current code is correct, but to be safer, we should pass
an explicit size.

Signed-off-by: Anthony Liguori <>

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

d9cf1578 09/15/2008 05:57 pm blueswir1

Define a few structures instead of including a file, add "static"

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

5d0c5750 09/14/2008 04:07 am aliguori

usb: Support for removing device by host addr, improved auto filter syntax (Max Krasnyansky)

This patch adds support for removing USB devices by host address.
Which is usefull for things like libvirtd because there is no easy way to
find guest USB address of the host device....

446ab128 09/14/2008 04:06 am aliguori

husb: Make control transactions asynchronous (Max Krasnyansky)

USB is 99.8% async now :). 0.2% is the three control requests that
we need to execute synchronously. We could off-load that to a thread
or something but it's not worth the pain since those requests are...

0d380648 08/21/2008 10:32 pm aliguori

husb: Fixup printfs and stuff based on the review comments (Max Krasnyansky)

Addressing Anthony's comments regarding printf and stuff.

Anthony, if you you want I can fold this commit and resend
the original patch.

Signed-off-by: Max Krasnyansky <>...

24772c1e 08/21/2008 10:31 pm aliguori

husb: remove disconnect detection timer (Max Krasnyansky)

On top of my previous USB patchset.

Async completion handler can detect device disconnects without polling.
We do not need the timer anymore.

Signed-off-by: Max Krasnyansky <>
Signed-off-by: Anthony Liguori <>...

64838171 08/21/2008 10:31 pm aliguori

husb: rewrite Linux host USB layer, fully async operation (Max Krasnyansky)

This is a follow up to the async UHCI patch. Both BULK and ISOC transactions
are now fully asynchrounous. I left CONTROL synchronous for now, ideally
we want it to be async too and it should not be that hard to do now....

4b096fc9 08/21/2008 10:28 pm aliguori

husb: support for USB host device auto connect (Max Krasnyansky)

QEMU can now automatically grab host USB devices that match the filter.
For now I just extended 'host:X.Y' and 'host:VID:PID' syntax to handle
wildcards. So for example if you do something like...

1f3870ab 08/21/2008 10:27 pm aliguori

husb: support for USB host device auto disconnect (Max Krasnyansky)

I got really annoyed by the fact that you have to manually do
usb_del in the monitor when host device is unplugged and decided
to fix it :)

Basically we now automatically remove guest USB device...

9596ebb7 11/18/2007 03:44 am pbrook

Add statics and missing #includes for prototypes.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

87ecb68b 11/17/2007 07:14 pm pbrook

Break up vl.h.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

046833ea 10/31/2007 02:27 am balrog

Use a O_NONBLOCK pipe for iso completion signals for thread-safety, by Arnon Gilboa.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

4d043a09 10/05/2007 01:55 am balrog

Quiet warnings introduced with the USB iso support.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

b9dc033c 10/05/2007 01:47 am balrog

USB iso transfers support for the linux redirector and for UHCI, by Arnon Gilboa.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

3b46e624 09/17/2007 11:09 am ths

find -type f | xargs sed -i 's/[\t ]*$//g' # Yes, again. Note the star in the regex.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

5fafdf24 09/17/2007 12:08 am ths

find -type f | xargs sed -i 's/[\t ]$//g' # on most files

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

a42aa815 12/11/2006 12:11 am ths

Build fix for newer kernel headers, thanks Jason Wessel.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

4d611c9a 08/12/2006 04:04 am pbrook

SCSI and USB async IO support.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

059809e4 07/19/2006 09:06 pm bellard

usb destroy API change (Lonnie Mendez)

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

3b2ccc57 07/19/2006 08:54 pm bellard

Linux compilation fix

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

1f6e24e7 06/27/2006 12:00 am bellard

display device identifier string for user with info usb (Lonnie Mendez)

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

2e5d83bb 05/26/2006 02:58 am pbrook

Rearrange SCSI disk emulation code.
Add USB mass storage device emulation.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

38ca0f6d 03/11/2006 08:03 pm pbrook

Tweak UHCI device settings. Ignore host root hubs.

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

868bfe2b 11/13/2005 11:53 pm bellard


git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

a594cfbf 11/06/2005 06:13 pm bellard

USB user interface

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162

bb36d470 11/05/2005 04:22 pm bellard

initial USB support

git-svn-id: svn:// c046a42c-6fe2-441c-8c8c-71466251a162