From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MLGGH-0006eR-PA for qemu-devel@nongnu.org; Mon, 29 Jun 2009 08:47:05 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MLGGC-0006Zm-NT for qemu-devel@nongnu.org; Mon, 29 Jun 2009 08:47:05 -0400 Received: from [199.232.76.173] (port=41139 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MLGGC-0006Zd-2e for qemu-devel@nongnu.org; Mon, 29 Jun 2009 08:47:00 -0400 Received: from mx2.redhat.com ([66.187.237.31]:36476) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MLGGB-0003vZ-24 for qemu-devel@nongnu.org; Mon, 29 Jun 2009 08:46:59 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n5TCkvjj007355 for ; Mon, 29 Jun 2009 08:46:57 -0400 From: Gerd Hoffmann Date: Mon, 29 Jun 2009 14:46:21 +0200 Message-Id: <1246279581-15749-21-git-send-email-kraxel@redhat.com> In-Reply-To: <1246279581-15749-1-git-send-email-kraxel@redhat.com> References: <1246279581-15749-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 20/20] debug/test patch: allow specify busnr for -usbdevice List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann i.e. -usbdevice tablet,busnr=1 Signed-off-by: Gerd Hoffmann --- vl.c | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-) diff --git a/vl.c b/vl.c index 0462892..cfcf437 100644 --- a/vl.c +++ b/vl.c @@ -2649,16 +2649,31 @@ static struct { } }; -static int usb_device_add(const char *devname, int is_hotplug) +static int usb_device_add(const char *config, int is_hotplug) { const char *p; - USBBus *bus = usb_bus_find(-1 /* any */); + char devname[32], buf[32], *params; + int busnr = -1; /* any */ + USBBus *bus; USBDevice *dev = NULL; int i; if (!usb_enabled) return -1; + pstrcpy(devname, sizeof(devname), config); + if ((params = strchr(devname,',')) != NULL) { + *params = 0; + params++; + if (get_param_value(buf, sizeof(buf), "busnr", params)) + busnr = atoi(buf); + } + + bus = usb_bus_find(busnr); + if (!bus) + return -1; + fprintf(stderr, "%s: busnr=%d, bus=%s\n", __FUNCTION__, busnr, bus->qbus.name); + /* simple devices which don't need extra care */ for (i = 0; i < ARRAY_SIZE(usbdevs); i++) { if (strcmp(devname, usbdevs[i].name) != 0) -- 1.6.2.5