Skip to contentSkip to conversation

usb: Support for removing device by host addr, improved auto filter syntax

PATCH Applied Max Krasnyansky 3 participants 4 messages Sep 13, 2008 – Sep 17, 2008 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: Support for removing device by host addr, improved auto filter syntax

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 *:*
---
 hw/usb.h    |    1 +
 usb-linux.c |  203 ++++++++++++++++++++++++++++++++++++++++++++++++++---------
 vl.c        |    3 +
 3 files changed, 176 insertions(+), 31 deletions(-)
hw/usb.h +1 -0
index 997e69f..1a353bb 100644
@@ -240,6 +240,7 @@ USBDevice *usb_hub_init(int nb_ports);
 
 /* usb-linux.c */
 USBDevice *usb_host_device_open(const char *devname);
+int usb_host_device_close(const char *devname);
 void usb_host_info(void);
 
 /* usb-hid.c */
usb-linux.c +172 -31

281 lines not on this page · raw message

vl.c +3 -0
index 18bcc1f..0619f1c 100644
@@ -5866,6 +5866,9 @@ static int usb_device_del(const char *devname)
     int bus_num, addr;
     const char *p;
 
+    if (strstart(devname, "host:", &p))
+        return usb_host_device_close(p);
+
     if (!used_usb_ports)
         return -1;
 
Signature · 1 line
1.5.5.1
#1 lore raw
Quoted 9 lines · 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.

Applied. Thanks.

BTW, I was able to program my harmony remote with QEMU after your last patch series. This brought me great joy as I do not currently have access to a physical Windows system :-)

Regards,

Anthony Liguori

#2 lore raw
Quoted 11 lines · Anthony Liguori
Quoted 9 lines · 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.

Quoted 5 lines

Applied. Thanks.

BTW, I was able to program my harmony remote with QEMU after your last patch series. This brought me great joy as I do not currently have access to a physical Windows system :-)

Yeah most of the devices I have did not work before. Now it's exactly the opposite, I cannot seem to find a device that does not work :). Even those that require firmware download (they reset and remunerate after fw is loaded), with the right set of auto filters QEMU just grabs them after reset and things work just fine.
And once we get EHCI going it'll be even better (BW wise that is).

Thanx for commiting the patches.
Max

#3 lore raw
Quoted 6 lines · Max Krasnyansky <maxk <at> kernel.org> writes:

Yeah most of the devices I have did not work before. Now it's exactly the opposite, I cannot seem to find a device that does not work :). Even those that require firmware download (they reset and remunerate after fw is loaded), with the right set of auto filters QEMU just grabs them after reset and things work just fine.
And once we get EHCI going it'll be even better (BW wise that is).

Hi,

thanks for your USB patches, Max. Also for me things have improved a lot with these patches.

what devices are working for me now (with windows xp+sp3):
* my nokia mobile
* a usb2rs232 converter
* a crazy usb2lpt converter
* a huawei e169 hsdpa usb stick (mobile broadband, yes :-) )
* a old logitech quickcam express for notebooks webcam is workish

devices that do not work:
* my TI calculator (TI 89 Titanium)
* my ipod nano (v3)

the ipod gives me the following output on the console:
husb: open device 1.6
husb: config #1 need -1
husb: 1 interfaces claimed for configuration 1
husb: grabbed usb device 1.6 usb_linux_update_endp_table: No such file or directory

the calculator does this:
husb: open device 4.5
husb: config #1 need -1
husb: 1 interfaces claimed for configuration -1
husb: grabbed usb device 4.5
husb: config #1 need 1
husb: 1 interfaces claimed for configuration 1
husb: config #1 need 1
husb: 1 interfaces claimed for configuration 1
...
husb: config #1 need 1
husb: 1 interfaces claimed for configuration 1
husb: device 4.5 disconnected

it seems to be switching configurations and re-enumerating periodically until i disconnected it.

any hints how to track these problems down? has anybody tried to use an ipod with qemu?

I'd be very thankful for any suggestions!

bye,
Andi