From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=59982 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P9KBy-0003FN-LZ for qemu-devel@nongnu.org; Fri, 22 Oct 2010 12:10:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P9KBx-0008MF-2Z for qemu-devel@nongnu.org; Fri, 22 Oct 2010 12:10:06 -0400 Received: from mail-ey0-f173.google.com ([209.85.215.173]:42170) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P9KBw-0008M0-UU for qemu-devel@nongnu.org; Fri, 22 Oct 2010 12:10:05 -0400 Received: by eyh5 with SMTP id 5so549742eyh.4 for ; Fri, 22 Oct 2010 09:10:03 -0700 (PDT) From: Grazvydas Ignotas Date: Fri, 22 Oct 2010 19:10:01 +0300 Message-Id: <1287763801-25458-1-git-send-email-notasas@gmail.com> Subject: [Qemu-devel] [PATCH] usb-linux: allow multiple devices with matching IDs List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 --- 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