From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KWUHL-0008G9-4X for qemu-devel@nongnu.org; Fri, 22 Aug 2008 06:54:03 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KWUHK-0008FZ-C3 for qemu-devel@nongnu.org; Fri, 22 Aug 2008 06:54:02 -0400 Received: from [199.232.76.173] (port=35552 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KWUHJ-0008FG-P1 for qemu-devel@nongnu.org; Fri, 22 Aug 2008 06:54:02 -0400 Received: from gecko.sbs.de ([194.138.37.40]:15794) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KWUHJ-0004l4-Je for qemu-devel@nongnu.org; Fri, 22 Aug 2008 06:54:01 -0400 Received: from mail1.sbs.de (localhost [127.0.0.1]) by gecko.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id m7MArxus025388 for ; Fri, 22 Aug 2008 12:53:59 +0200 Received: from [139.25.109.167] (mchn012c.mchp.siemens.de [139.25.109.167] (may be forged)) by mail1.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id m7MArwBA032501 for ; Fri, 22 Aug 2008 12:53:59 +0200 Message-ID: <48AE9AC6.9090909@siemens.com> Date: Fri, 22 Aug 2008 12:53:58 +0200 From: Jan Kiszka MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [5048] husb: support for USB host device auto connect (Max Krasnyansky) Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Anthony Liguori wrote: > Revision: 5048 > http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5048 > Author: aliguori > Date: 2008-08-21 19:28:55 +0000 (Thu, 21 Aug 2008) > > Log Message: > ----------- > 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 > 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 > Signed-off-by: Anthony Liguori > ... > > Modified: trunk/vl.c > =================================================================== > --- trunk/vl.c 2008-08-21 19:27:48 UTC (rev 5047) > +++ trunk/vl.c 2008-08-21 19:28:55 UTC (rev 5048) > @@ -5747,6 +5747,32 @@ > free_usb_ports = port; > } > > +int usb_device_add_dev(USBDevice *dev) > +{ > + USBPort *port; > + > + /* Find a USB port to add the device to. */ > + port = free_usb_ports; > + if (!port->next) { > + USBDevice *hub; > + > + /* Create a new hub and chain it on. */ > + free_usb_ports = NULL; > + port->next = used_usb_ports; > + used_usb_ports = port; > + > + hub = usb_hub_init(VM_USB_HUB_SIZE); > + usb_attach(port, hub); > + port = free_usb_ports; > + } > + > + free_usb_ports = port->next; > + port->next = used_usb_ports; > + used_usb_ports = port; > + usb_attach(port, dev); > + return 0; > +} > + > static int usb_device_add(const char *devname) > { > const char *p; > @@ -5787,26 +5813,7 @@ > if (!dev) > return -1; > > - /* Find a USB port to add the device to. */ > - port = free_usb_ports; > - if (!port->next) { > - USBDevice *hub; > - > - /* Create a new hub and chain it on. */ > - free_usb_ports = NULL; > - port->next = used_usb_ports; > - used_usb_ports = port; > - > - hub = usb_hub_init(VM_USB_HUB_SIZE); > - usb_attach(port, hub); > - port = free_usb_ports; > - } > - > - free_usb_ports = port->next; > - port->next = used_usb_ports; > - used_usb_ports = port; > - usb_attach(port, dev); > - return 0; > + return usb_device_add_dev(dev); > } > > int usb_device_del_addr(int bus_num, int addr) Same complaint here: Please avoid adding new warnings, it makes tracking my own regressions only harder. ;) Jan ------- Signed-off-by: Jan Kiszka --- vl.c | 1 - 1 file changed, 1 deletion(-) Index: b/vl.c =================================================================== --- a/vl.c +++ b/vl.c @@ -5779,7 +5779,6 @@ static int usb_device_add(const char *de { const char *p; USBDevice *dev; - USBPort *port; if (!free_usb_ports) return -1;