summaryrefslogtreecommitdiff
path: root/usb-linux.c
AgeCommit message (Collapse)AuthorFilesLines
2010-06-30Return usb device to host on exitShahar Havivi1-0/+14
Signed-off-by: Shahar Havivi <shaharh@redhat.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-06-30Return usb device to host on usb_del commandShahar Havivi1-0/+1
Signed-off-by: Shahar Havivi <shaharh@redhat.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-05-03Changes to usb-linux to conform to coding styleDavid Ahern1-149/+224
Signed-off-by: David Ahern <daahern@cisco.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-04-25usb: remove dead assignments, spotted by clang analyzerBlue Swirl1-2/+1
Value stored is never read. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-03-19Revert "usb-linux: remove unreachable default in switch statement"Anthony Liguori1-0/+3
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': /src/qemu/usb-linux.c:759: error: 'type' may be used uninitialized in this function Reported-by: Blue Swirl <blauwirbel@gmail.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-03-17usb-linux: remove unreachable default in switch statementPaul Bolle1-3/+0
Signed-off-by: Paul Bolle <pebolle@tiscali.nl> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-03-16usb: Remove disabled monitor_printf() in usb_read_file()Markus Armbruster1-8/+0
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.
2010-02-07Do not use dprintfmalc1-26/+26
dprintf is already claimed by POSIX[1], and on at least one system is implemented as a macro [1] http://www.opengroup.org/onlinepubs/9699919799/functions/dprintf.html Signed-off-by: malc <av1474@comtv.ru>
2010-02-06usb-linux: increase buffer for USB control requestsChristian Krause1-1/+1
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. Increasing the buffer size to 8192 seems to be a safe choice. Signed-off-by: Christian Krause <chkr@plauener.de> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-02-05usb-linux.c: remove write-only variablePaolo Bonzini1-2/+0
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-01-26usb-linux.c: fix warning with _FORTIFY_SOURCEKirill A. Shutemov1-2/+1
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 Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name> Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-19Fix QEMU_WARN_UNUSED_RESULTKevin Wolf1-1/+1
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 results. These calls are changed to qdev_init_nofail to avoid build failures. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-18usb-host: check mon before using it.Gerd Hoffmann1-4/+7
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-12qdev: Replace device names containing whitespaceMarkus Armbruster1-3/+2
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 name should be short & sweet. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-12qdev: Separate USB product description from qdev nameMarkus Armbruster1-0/+1
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 the value is still the same. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-12qdev: Rename USBDevice member devname to product_descMarkus Armbruster1-2/+2
It's not a device name, it's the USB product description string. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03Fix recently introduced bugs in -usbdevice hostMarkus Armbruster1-12/+16
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". * It broke "-usbdevice host:auto:..." by calling parse_filter() incorrectly. * It broke parsing of "-usbdevice host:BUS.ADDR" and "-usbdevice host:VID:PRID" with a trivial pasto. * It broke wildcards in "-usbdevice host:auto:...". Before, the four filter components were stored as int, and the wildcard was encoded as -1. The faulty commit changed storage to uint32_t, and the wildcard encoding to 0. But it failed to update parse_filter() accordingly. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-30usb-host: use qdev for -usbdevice + rework.Gerd Hoffmann1-266/+144
Changes: * 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 code got dropped. * Autofiltering turns off the timer if there is nothing to do, it runs only in case there are unattached host devices. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-27usb-linux: return USB_RET_STALL on -EPIPEPaul Bolle1-1/+3
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: http://lists.gnu.org/archive/html/qemu-devel/2008-10/msg01326.html). No EHCI emulation module was ever committed to qemu. 2) Part of that (large) patch was a fix for a separate issue in usb-linux.c. Max Krasnyansky has ACK'ed that fix (see: http://lists.gnu.org/archive/html/qemu-devel/2008-11/msg00032.html). 3) I already asked whether this fix was ready to be committed in last April (see: http://lists.gnu.org/archive/html/qemu-devel/2009-04/msg01763.html) 4) Maybe submitting this fix as a separate patch (with a really long commit message but without a Signed-off-by) and cc-ing everbody involved will help if actually getting this issue fixed. Paul Bolle Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-07Check return value of qdev_init()Markus Armbruster1-2/+4
But do so only where it may actually fail. Leave the rest for the next commit. Patchworks-ID: 35167 Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-07Unbreak USB autoconnect filtersMarkus Armbruster1-2/+0
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 <armbru@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-25unbreak usb pass-through on linux.Gerd Hoffmann1-0/+2
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 <kraxel@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-09-12Use proper format conversion specifier when printing size_t valuemalc1-3/+3
And untabify this while we are at it. Signed-off-by: malc <av1474@comtv.ru>
2009-09-11usb-linux.c: fix buffer overflowJim Paris1-2/+10
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. For example, hw/usb-uhci.c could set the length to 2047. hw/usb-ohci.c looks like it might go up to 4096 or 8192. This causes a qemu crash, as reported here: http://www.mail-archive.com/kvm@vger.kernel.org/msg18447.html This patch increases the usb-linux.c buffer size to 2048 to fix the specific device reported, and adds a check to avoid the overflow in any case. Signed-off-by: Jim Paris <jim@jtan.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-09qdev/usb: make qemu aware of usb busses.Gerd Hoffmann1-6/+6
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() instead. Kill some FIXMEs added by the first qdev/usb patch. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-09qdev/usb: add usb bus support to qdev, convert drivers.Gerd Hoffmann1-16/+37
* 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. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-09-07USB: use opaque parameter passing for monitor handleBlue Swirl1-4/+5
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-07-31Fix Sparse warnings: "Using plain integer as NULL pointer"Blue Swirl1-4/+4
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-07-10Prefer sysfs for USB host devicesMark McLoughlin1-9/+9
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 but not /proc/bus/usb, so although the current code will work just fine, it will generate SELinux AVC warnings. See also: https://bugzilla.redhat.com/508326 Reported-by: Daniel Berrange <berrange@redhat.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-22USB serial device supportJason Wessel1-2/+1
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. This was fully tested with a pl2303 usb serial device. Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
2009-03-05monitor: Rework API (Jan Kiszka)aliguori1-14/+21
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 unused for now. All monitor command callbacks are also extended by a mon parameter so that command handlers are able to pass an appropriate reference to monitor output services. For the case that monitor outputs so far happen without clearly identifiable context, the global variable cur_mon is introduced that shall once provide a pointer either to the current active monitor (while processing commands) or to the default one. On the mid or long term, those use case will be obsoleted so that this variable can be removed again. Due to the broad usage of the monitor interface, this patch mostly deals with converting users of the monitor API. A few of them are already extended to pass 'mon' from the command handler further down to internal functions that invoke monitor_printf. At this chance, monitor-related prototypes are moved from console.h to a new monitor.h. The same is done for the readline API. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6711 c046a42c-6fe2-441c-8c8c-71466251a162
2009-02-05toplevel: remove error handling from qemu_malloc() callers (Avi Kivity)aliguori1-22/+2
Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6531 c046a42c-6fe2-441c-8c8c-71466251a162
2008-12-28Suppress a -Werror=format-security warningblueswir11-7/+11
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6135 c046a42c-6fe2-441c-8c8c-71466251a162
2008-11-22Native BSD host USB support (Juergen Lock, Lonnie Mendez)blueswir11-23/+0
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5780 c046a42c-6fe2-441c-8c8c-71466251a162
2008-11-22Use qemu_isfoobar and qemu_towombat versions, based on patch by Christoph Eggerblueswir11-1/+1
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5774 c046a42c-6fe2-441c-8c8c-71466251a162
2008-10-28Use locally defined structure.pbrook1-1/+1
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5569 c046a42c-6fe2-441c-8c8c-71466251a162
2008-10-25Silence warnings about unused variablesblueswir11-5/+5
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5535 c046a42c-6fe2-441c-8c8c-71466251a162
2008-10-21Keep usb host scanning from leaking file descriptorsaliguori1-5/+11
If the first case does not succeed, then the usb scanning code will leak file descriptors on every scan. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5509 c046a42c-6fe2-441c-8c8c-71466251a162
2008-10-21Fix broken USB support for Linux host (Bjorn Danielsson)aliguori1-1/+2
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 <bdq@dax.nu> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5507 c046a42c-6fe2-441c-8c8c-71466251a162
2008-10-07Add USB sys file-system support (v8) (TJ)aliguori1-10/+218
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: /proc/bus/usb/devices and opened from /proc/bus/usb/*/* Signed-off-by: TJ <linux@tjworld.net> Signed-off-by: Anthony Liguori <aliguori> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5441 c046a42c-6fe2-441c-8c8c-71466251a162
2008-09-22Don't use sprintf() or strcpy()aliguori1-10/+10
They are unsafe. The current code is correct, but to be safer, we should pass an explicit size. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5290 c046a42c-6fe2-441c-8c8c-71466251a162
2008-09-15Define a few structures instead of including a file, add "static"blueswir11-2/+20
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5225 c046a42c-6fe2-441c-8c8c-71466251a162
2008-09-14usb: Support for removing device by host addr, improved auto filter syntax ↵aliguori1-31/+172
(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. In other words you can now do: usb_add host:3.5 ... usb_del host:3.5 Before the patch 'usb_del' did not support 'host:' notation. ---- Syntax for specifying auto connect filters has been improved. Old syntax was host:bus.dev host:pid:vid New syntax is host:auto:bus.dev[:pid:vid] In both the cases any attribute can be set to "*". New syntax is more flexible and lets you do things like host:3.*:5533:* /* grab any device on bus 3 with vendor id 5533 */ It's now possible to remove auto filters. For example: usb_del host:auto:3.*:5533:* Active filters are printed after all host devices in 'info usb' output. Which now looks like this: Device 1.1, speed 480 Mb/s Hub: USB device 1d6b:0002, EHCI Host Controller Device 1.4, speed 480 Mb/s Class 00: USB device 1058:0704, External HDD Auto filters: Device 3.* ID *:* Signed-off-by: Max Krasnyansky <maxk@kernel.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5205 c046a42c-6fe2-441c-8c8c-71466251a162
2008-09-14husb: Make control transactions asynchronous (Max Krasnyansky)aliguori1-93/+371
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 performed only during device initialization (ie when device is connected to the VM). The change is a bit bigger than I wanted due to the fact that generic handle_packet()/handle_control() interface was not designed for async transactions. So I ended up adding custom handle_packet() code to usb-linux. We can make that generic if/when some other component needs it. Signed-off-by: Max Krasnyansky <maxk@kernel.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5204 c046a42c-6fe2-441c-8c8c-71466251a162
2008-08-21husb: Fixup printfs and stuff based on the review comments (Max Krasnyansky)aliguori1-7/+4
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 <maxk@kernel.org> Signed-off-by: AnthonY Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5053 c046a42c-6fe2-441c-8c8c-71466251a162
2008-08-21husb: remove disconnect detection timer (Max Krasnyansky)aliguori1-31/+6
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 <maxk@kernel.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5052 c046a42c-6fe2-441c-8c8c-71466251a162
2008-08-21husb: rewrite Linux host USB layer, fully async operation (Max Krasnyansky)aliguori1-278/+182
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. This patch obviously requires UHCI patch. The combo has been tested with various devices. See the UHCI patch description for list of the devices. Most of the testing was done with the KVM flavor of QEMU. Signed-off-by: Max Krasnyansky <maxk@kernel.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5051 c046a42c-6fe2-441c-8c8c-71466251a162
2008-08-21husb: support for USB host device auto connect (Max Krasnyansky)aliguori1-14/+195
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 usb_add host:5.* QEMU will automatically grab any non-hub device with host address 5.*. Same with the 'host:PID:*', we grab any device that matches PID. Filtering itself is very generic so we can probably add more elaborate syntax like 'host:BUS.ADDR:VID:PID'. So that we can do 'host:5.*:6000:*'. Anyway, it's implemented using a periodic timer that scans host devices and grabs those that match the filter. Timer is started when the first filter is added. We now keep the list of all host devices that we grabbed to make sure that we do not grab the same device twice. btw It's currently possible to grab the same host device more than once. ie You can just do "usb_add host:1.1" more than once, which of course does not work. So this patch fixes that issue too. Along with auto disconnect patch that I send a minute ago the setup is very seamless now. You can just allocate some usb ports to the VMs and plug/unplug devices at any time. Signed-off-by: Max Krasnyansky <maxk@kernel.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5048 c046a42c-6fe2-441c-8c8c-71466251a162
2008-08-21husb: support for USB host device auto disconnect (Max Krasnyansky)aliguori1-9/+47
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 when the actual host device is disconnected. At first I've extended set_fd_handlerX() stuff to support checking for exceptions on fds. But unfortunately usbfs code does not wake up user-space process when device is removed, which means we need a timer to periodically check if device is still there. So I removed fd exception stuff and implemented it with the timer. Signed-off-by: Max Krasnyansky <maxk@kernel.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5047 c046a42c-6fe2-441c-8c8c-71466251a162
2007-11-18Add statics and missing #includes for prototypes.pbrook1-4/+4
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3683 c046a42c-6fe2-441c-8c8c-71466251a162