From: Jan Kiszka <jan.kiszka@siemens.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [5048] husb: support for USB host device auto connect (Max Krasnyansky)
Date: Tue, 02 Sep 2008 13:22:27 +0200 [thread overview]
Message-ID: <48BD21F3.1020705@siemens.com> (raw)
In-Reply-To: <48AE9AC6.9090909@siemens.com>
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 <maxk@kernel.org>
>> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
>>
>
> ...
>
>> 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 <jan.kiszka@siemens.com>
> ---
> 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
prev parent reply other threads:[~2008-09-02 11:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-21 19:28 [Qemu-devel] [5048] husb: support for USB host device auto connect (Max Krasnyansky) Anthony Liguori
2008-08-22 10:53 ` [Qemu-devel] " Jan Kiszka
2008-09-02 11:22 ` Jan Kiszka [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48BD21F3.1020705@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).