From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KaTy1-0005Ab-5y for qemu-devel@nongnu.org; Tue, 02 Sep 2008 07:22:37 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KaTxw-00055K-CB for qemu-devel@nongnu.org; Tue, 02 Sep 2008 07:22:36 -0400 Received: from [199.232.76.173] (port=36980 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KaTxw-000557-6d for qemu-devel@nongnu.org; Tue, 02 Sep 2008 07:22:32 -0400 Received: from gecko.sbs.de ([194.138.37.40]:17054) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KaTxv-0006Vr-NZ for qemu-devel@nongnu.org; Tue, 02 Sep 2008 07:22:32 -0400 Received: from mail2.sbs.de (localhost [127.0.0.1]) by gecko.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id m82BMSaY028784 for ; Tue, 2 Sep 2008 13:22:28 +0200 Received: from [139.25.109.167] (mchn012c.ww002.siemens.net [139.25.109.167] (may be forged)) by mail2.sbs.de (8.12.11.20060308/8.12.11) with ESMTP id m82BMSAQ025620 for ; Tue, 2 Sep 2008 13:22:28 +0200 Message-ID: <48BD21F3.1020705@siemens.com> Date: Tue, 02 Sep 2008 13:22:27 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <48AE9AC6.9090909@siemens.com> In-Reply-To: <48AE9AC6.9090909@siemens.com> 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 Jan Kiszka wrote: > 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; It's still throwing a warning at me... Jan -- Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux