From patchwork Fri Oct 22 16:10:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Gra=C5=BEvydas_Ignotas?= X-Patchwork-Id: 68890 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 07F68B70A8 for ; Sat, 23 Oct 2010 03:51:25 +1100 (EST) Received: from localhost ([127.0.0.1]:52670 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P9KJ4-0006Me-GI for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2010 12:17:26 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=NkX/UWkfJ1GqAJaMg9RHzJd60SvjOMJ+lyqFrxhDYIM=; b=XbC2HBvR8PnF7SzAoDqeqa0gPkJxYSHfkfXX4kD9W9S7scDsjv8MownRaNKSCXhRkE aWAFF34rimWdI0zgWvbYvufwttzQHJyl1f+guPwUY+FeCKqLFFpL5xJF3SicgI/LSt6G Sn1S6YfJU7VH8l0l4LVb0R+/NvPCeYH4ZbFDw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=oHlSb90Tdz1l4mmBo9jskZtwD3NFKWkydPRGNRz9e3FVd9zTFAoaXGEh+nvpqe0OWV TIRWrKuCeQJ5TwSHXdU8FE2aDbxwTNpQsj3UamXbS/TeUOIdeDphfFdSDI+7N5vqujMY P2tWxtd1yODgVlBIkbvivkCsOjYGoFv6UlC28= Received: by 10.213.4.15 with SMTP id 15mr3403231ebp.49.1287763803578; Fri, 22 Oct 2010 09:10:03 -0700 (PDT) Received: from localhost.localdomain (ip-88-119-226-136.static.b4net.lt [88.119.226.136]) by mx.google.com with ESMTPS id q58sm3456308eeh.21.2010.10.22.09.10.02 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 22 Oct 2010 09:10:02 -0700 (PDT) From: Grazvydas Ignotas To: qemu-devel@nongnu.org Date: Fri, 22 Oct 2010 19:10:01 +0300 Message-Id: <1287763801-25458-1-git-send-email-notasas@gmail.com> X-Mailer: git-send-email 1.6.3.3 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: Grazvydas Ignotas Subject: [Qemu-devel] [PATCH] usb-linux: allow multiple devices with matching IDs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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);