qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] usb-linux: allow multiple devices with matching IDs
@ 2010-10-22 16:10 Grazvydas Ignotas
  2010-11-10 16:01 ` Markus Armbruster
  0 siblings, 1 reply; 3+ messages in thread
From: Grazvydas Ignotas @ 2010-10-22 16:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Grazvydas Ignotas

Right now if we pass through multiple USB devices with matching vendor
and product IDs, only first one is passed to guest, as the code thinks
second device is already attached. The only way to get those devices
working is to specify bus.addr which is inconvenient if devices are
frequently replugged on host, because the address changes after replug.

Fix this by checking bus.addr before assuming the device is already
attached. This way -usbdevice host:1234:1234 -usbdevice host:1234:1234
will pass through 2 devices correctly.

Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
---
 usb-linux.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/usb-linux.c b/usb-linux.c
index c3c38ec..b5f1396 100644
--- a/usb-linux.c
+++ b/usb-linux.c
@@ -1464,9 +1464,13 @@ static int usb_host_auto_scan(void *opaque, int bus_num, int addr,
         }
         /* We got a match */
 
-        /* Already attached ? */
         if (s->fd != -1) {
-            return 0;
+            /* Already attached? */
+            if (s->bus_num == bus_num && s->addr == addr)
+                return 0;
+
+            /* Not attached but needs another hostdev */
+            continue;
         }
         DPRINTF("husb: auto open: bus_num %d addr %d\n", bus_num, addr);
 
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] usb-linux: allow multiple devices with matching IDs
  2010-10-22 16:10 [Qemu-devel] [PATCH] usb-linux: allow multiple devices with matching IDs Grazvydas Ignotas
@ 2010-11-10 16:01 ` Markus Armbruster
  2010-11-13 14:32   ` Grazvydas Ignotas
  0 siblings, 1 reply; 3+ messages in thread
From: Markus Armbruster @ 2010-11-10 16:01 UTC (permalink / raw)
  To: Grazvydas Ignotas; +Cc: qemu-devel

Grazvydas Ignotas <notasas@gmail.com> writes:

> Right now if we pass through multiple USB devices with matching vendor
> and product IDs, only first one is passed to guest, as the code thinks
> second device is already attached. The only way to get those devices
> working is to specify bus.addr which is inconvenient if devices are
> frequently replugged on host, because the address changes after replug.
>
> Fix this by checking bus.addr before assuming the device is already
> attached. This way -usbdevice host:1234:1234 -usbdevice host:1234:1234
> will pass through 2 devices correctly.
>
> Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
> ---
>  usb-linux.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/usb-linux.c b/usb-linux.c
> index c3c38ec..b5f1396 100644
> --- a/usb-linux.c
> +++ b/usb-linux.c
> @@ -1464,9 +1464,13 @@ static int usb_host_auto_scan(void *opaque, int bus_num, int addr,
>          }
>          /* We got a match */
>  
> -        /* Already attached ? */
>          if (s->fd != -1) {
> -            return 0;
> +            /* Already attached? */
> +            if (s->bus_num == bus_num && s->addr == addr)
> +                return 0;
> +
> +            /* Not attached but needs another hostdev */
> +            continue;
>          }
>          DPRINTF("husb: auto open: bus_num %d addr %d\n", bus_num, addr);

Did you test that filtering by bus and addr still works?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] usb-linux: allow multiple devices with matching IDs
  2010-11-10 16:01 ` Markus Armbruster
@ 2010-11-13 14:32   ` Grazvydas Ignotas
  0 siblings, 0 replies; 3+ messages in thread
From: Grazvydas Ignotas @ 2010-11-13 14:32 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-devel

On Wed, Nov 10, 2010 at 6:01 PM, Markus Armbruster <armbru@redhat.com> wrote:
> Grazvydas Ignotas <notasas@gmail.com> writes:
>
>> Right now if we pass through multiple USB devices with matching vendor
>> and product IDs, only first one is passed to guest, as the code thinks
>> second device is already attached. The only way to get those devices
>> working is to specify bus.addr which is inconvenient if devices are
>> frequently replugged on host, because the address changes after replug.
>>
>> Fix this by checking bus.addr before assuming the device is already
>> attached. This way -usbdevice host:1234:1234 -usbdevice host:1234:1234
>> will pass through 2 devices correctly.
>>
>> Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
>> ---
>>  usb-linux.c |    8 ++++++--
>>  1 files changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/usb-linux.c b/usb-linux.c
>> index c3c38ec..b5f1396 100644
>> --- a/usb-linux.c
>> +++ b/usb-linux.c
>> @@ -1464,9 +1464,13 @@ static int usb_host_auto_scan(void *opaque, int bus_num, int addr,
>>          }
>>          /* We got a match */
>>
>> -        /* Already attached ? */
>>          if (s->fd != -1) {
>> -            return 0;
>> +            /* Already attached? */
>> +            if (s->bus_num == bus_num && s->addr == addr)
>> +                return 0;
>> +
>> +            /* Not attached but needs another hostdev */
>> +            continue;
>>          }
>>          DPRINTF("husb: auto open: bus_num %d addr %d\n", bus_num, addr);
>
> Did you test that filtering by bus and addr still works?
>

Yes. However it still acts strange when one of those 2 devices is
unplugged, so you can drop this patch for now I guess.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-11-13 14:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-22 16:10 [Qemu-devel] [PATCH] usb-linux: allow multiple devices with matching IDs Grazvydas Ignotas
2010-11-10 16:01 ` Markus Armbruster
2010-11-13 14:32   ` Grazvydas Ignotas

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).