summaryrefslogtreecommitdiffstats
path: root/usb-linux.c
Commit message (Collapse)AuthorAgeFilesLines
* usb-linux: Add missing break statementStefan Weil2011-05-091-0/+1
| | | | | | | | | | cppcheck report: usb-linux.c:661: warning: Redundant assignment of "len" in switch Cc: Hans de Goede <hdegoede@redhat.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
* usb: move complete callback to port opsGerd Hoffmann2011-05-041-1/+1
|
* usb-linux: Add support for buffering iso out usb packetsHans de Goede2011-05-041-51/+101
| | | | | | | 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 <hdegoede@redhat.com>
* usb-linux: We only need to keep track of 15 endpointsHans de Goede2011-05-041-3/+3
| | | | | | | | 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 <hdegoede@redhat.com>
* usb-linux: Refuse iso packets when max packet size is 0 (alt setting 0)Hans de Goede2011-05-041-1/+5
| | | | | | 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.
* usb-linux: Refuse packets for endpoints which are not in the usb descriptorHans de Goede2011-05-041-0/+13
| | | | | | | 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 <hdegoede@redhat.com>
* usb-linux: Add support for buffering iso usb packetsHans de Goede2011-05-041-17/+226
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 controller usb frame, we would be generating 1000 hardware interrupts per second on the host 2) We are not fast enough to submit every packet in time for the next host host controller usb frame, causing us to not submit iso urbs in some usb frames which causes devices with an endpoint with an interval of 1 ms (so every frame) to loose data. This causes for example ubs-1.1 webcams to not work properly (usb-2.0 is not supported at all atm). This patch fixes both problems by changing the iso packet pass through handling to buffer packets. This version only does so for iso input packets (webcams, audio in) I'm working on a second patch extending this to iso output packets (audio out). This patch makes use of the linux batching of iso packets in one urb. When an iso in packet gets received from the emulated host controller, it immediately submits 3 urbs with 32 iso in packets each. This causes the host to only get an hw interrupt every 32 packets dropping the interrupt rate to 32 interrupts per second and gives it a queue of urbs to work from once the first 32 iso in packets have been received to make sure no packets are dropped. Besides submitting a whole bunch or urbs as soon as the first urb is received, effectively creating a buffer inside the kernel, this patch also gets rid of the asynchroneous completion for iso in urbs. Instead they are only marked as complete in the fd write callback (which usbfs uses to signal complete urbs). These complete packets then get consumed by returning them synchroneously to the emulated host controller when it submits an iso in packet for the ep in question. When no complete packets are ready (which happens when the stream is starting) a 0 length packet gets returned to the emulated host controller. With this patch I've several usb-1.1 webcams working well with usb pass through, where as without this patch none of them work. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* usb-linux: Get the alt. setting from sysfs rather then asking the devHans de Goede2011-05-041-0/+18
| | | | | | | | | | | | | | | | | | 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 the operating system's usb stack knows which alternate setting it has told the device to get into, and thus this ctrl message does not get tested by device manufacturers. When usb_fs_type == USB_FS_SYS, the active alt. setting can be read directly from sysfs, which allows using this device through qemu's usb redirection. More in general it seems a good idea to not send needless control msg's to devices, esp. as the code in question is called every time a set_interface is done. Which happens multiple times during virtual machine startup, and when device drivers are activating the usb device. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* usb-linux: introduce a usb_linux_alt_setting functionHans de Goede2011-05-041-15/+25
| | | | | | | | | | | | 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 of an error getting the alt setting to be 0 (a sane default) rather then the interface numberwhich makes no sense. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* usb: fix spelling errors in usb-linux.cBrad Hards2011-04-161-2/+2
| | | | | Signed-off-by: Brad Hards <bradh@frogmouth.net> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* usb: initialise data element in Linux USB_DISCONNECT ioctlBrad Hards2011-04-161-0/+1
| | | | | | | This isn't used, but leaving it empty causes valgrind noise. Signed-off-by: Brad Hards <bradh@frogmouth.net> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* change all rt_clock references to use millisecond resolution accessorsPaolo Bonzini2011-03-211-2/+2
| | | | | | | | | | | | | | | 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/' \ $(git grep -l 'new_timer\>.*rt_clock' ) after checking that get_clock and new_timer never occur twice on the same line. There were no missed occurrences; however, even if there had been, they would have been caught by the compiler. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* usb-linux: Get the active configuration from sysfs rather then asking the devHans de Goede2010-11-161-0/+19
| | | | | | | | | | | | | 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 from sysfs, which allows using this device through qemu's usb redirection. More in general it seems a good idea to not send needless control msg's to devices, esp. as the code in question is called every time a set_interface is done. Which happens multiple times during virtual machine startup, and when device drivers are activating the usb device. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* usb-linux: introduce a usb_linux_get_configuration functionHans de Goede2010-11-161-8/+22
| | | | | | | | 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 <aliguori@us.ibm.com>
* usb-linux: Store devpath into USBHostDevice when usb_fs_type == USB_FS_SYSHans de Goede2010-11-161-11/+15
| | | | | | | 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 <aliguori@us.ibm.com>
* Return usb device to host on exitShahar Havivi2010-06-301-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>
* Return usb device to host on usb_del commandShahar Havivi2010-06-301-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>
* Changes to usb-linux to conform to coding styleDavid Ahern2010-05-031-149/+224
| | | | | Signed-off-by: David Ahern <daahern@cisco.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* usb: remove dead assignments, spotted by clang analyzerBlue Swirl2010-04-251-2/+1
| | | | | | Value stored is never read. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Revert "usb-linux: remove unreachable default in switch statement"Anthony Liguori2010-03-191-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>
* usb-linux: remove unreachable default in switch statementPaul Bolle2010-03-171-3/+0
| | | | | Signed-off-by: Paul Bolle <pebolle@tiscali.nl> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* usb: Remove disabled monitor_printf() in usb_read_file()Markus Armbruster2010-03-161-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.
* Do not use dprintfmalc2010-02-071-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>
* usb-linux: increase buffer for USB control requestsChristian Krause2010-02-061-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>
* usb-linux.c: remove write-only variablePaolo Bonzini2010-02-051-2/+0
| | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* usb-linux.c: fix warning with _FORTIFY_SOURCEKirill A. Shutemov2010-01-261-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>
* Fix QEMU_WARN_UNUSED_RESULTKevin Wolf2010-01-191-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>
* usb-host: check mon before using it.Gerd Hoffmann2009-12-181-4/+7
| | | | | Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qdev: Replace device names containing whitespaceMarkus Armbruster2009-12-121-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>
* qdev: Separate USB product description from qdev nameMarkus Armbruster2009-12-121-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>
* qdev: Rename USBDevice member devname to product_descMarkus Armbruster2009-12-121-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>
* Fix recently introduced bugs in -usbdevice hostMarkus Armbruster2009-12-031-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>
* usb-host: use qdev for -usbdevice + rework.Gerd Hoffmann2009-10-301-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>
* usb-linux: return USB_RET_STALL on -EPIPEPaul Bolle2009-10-271-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>
* Check return value of qdev_init()Markus Armbruster2009-10-071-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>
* Unbreak USB autoconnect filtersMarkus Armbruster2009-10-071-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>
* unbreak usb pass-through on linux.Gerd Hoffmann2009-09-251-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>
* Use proper format conversion specifier when printing size_t valuemalc2009-09-121-3/+3
| | | | | | And untabify this while we are at it. Signed-off-by: malc <av1474@comtv.ru>
* usb-linux.c: fix buffer overflowJim Paris2009-09-111-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>
* qdev/usb: make qemu aware of usb busses.Gerd Hoffmann2009-09-091-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>
* qdev/usb: add usb bus support to qdev, convert drivers.Gerd Hoffmann2009-09-091-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>
* USB: use opaque parameter passing for monitor handleBlue Swirl2009-09-071-4/+5
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Fix Sparse warnings: "Using plain integer as NULL pointer"Blue Swirl2009-07-311-4/+4
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Prefer sysfs for USB host devicesMark McLoughlin2009-07-101-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>
* USB serial device supportJason Wessel2009-05-221-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>
* monitor: Rework API (Jan Kiszka)aliguori2009-03-051-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
* toplevel: remove error handling from qemu_malloc() callers (Avi Kivity)aliguori2009-02-051-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
* Suppress a -Werror=format-security warningblueswir12008-12-281-7/+11
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6135 c046a42c-6fe2-441c-8c8c-71466251a162
* Native BSD host USB support (Juergen Lock, Lonnie Mendez)blueswir12008-11-221-23/+0
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5780 c046a42c-6fe2-441c-8c8c-71466251a162
* Use qemu_isfoobar and qemu_towombat versions, based on patch by Christoph Eggerblueswir12008-11-221-1/+1
| | | | git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5774 c046a42c-6fe2-441c-8c8c-71466251a162
OpenPOWER on IntegriCloud