[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Re: [5048] husb: support for USB host device auto connect (
From: |
Jan Kiszka |
Subject: |
[Qemu-devel] Re: [5048] husb: support for USB host device auto connect (Max Krasnyansky) |
Date: |
Fri, 22 Aug 2008 12:53:58 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 |
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 <address@hidden>
> Signed-off-by: Anthony Liguori <address@hidden>
>
...
>
> 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 <address@hidden>
---
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;