From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MPBjq-0002kd-7Z for qemu-devel@nongnu.org; Fri, 10 Jul 2009 04:45:50 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MPBjl-0002gR-CR for qemu-devel@nongnu.org; Fri, 10 Jul 2009 04:45:49 -0400 Received: from [199.232.76.173] (port=34128 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MPBjl-0002gD-1K for qemu-devel@nongnu.org; Fri, 10 Jul 2009 04:45:45 -0400 Received: from mx2.redhat.com ([66.187.237.31]:48116) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MPBjj-0006th-QH for qemu-devel@nongnu.org; Fri, 10 Jul 2009 04:45:44 -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 n6A8jgDG024217 for ; Fri, 10 Jul 2009 04:45:42 -0400 From: Mark McLoughlin Content-Type: text/plain Date: Fri, 10 Jul 2009 09:45:21 +0100 Message-Id: <1247215521.3645.2.camel@blaa> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH] [RESEND] Prefer sysfs for USB host devices Reply-To: Mark McLoughlin List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel Scanning for devices via /sys/bus/usb/devices/ and using them via the /dev/bus/usb// character devices is the prefered method on modern kernels, so try that first. When using SELinux and libvirt, qemu will have access to /sys/bus/usb but not /proc/bus/usb, so although the current code will work just fine, it will generate SELinux AVC warnings. See also: https://bugzilla.redhat.com/508326 Reported-by: Daniel Berrange Signed-off-by: Mark McLoughlin --- usb-linux.c | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-) diff --git a/usb-linux.c b/usb-linux.c index 67e4acd..3c724ba 100644 --- a/usb-linux.c +++ b/usb-linux.c @@ -1265,6 +1265,15 @@ static int usb_host_scan(void *opaque, USBScanFunc *func) /* only check the host once */ if (!usb_fs_type) { + dir = opendir(USBSYSBUS_PATH "/devices"); + if (dir) { + /* devices found in /dev/bus/usb/ (yes - not a mistake!) */ + strcpy(devpath, USBDEVBUS_PATH); + usb_fs_type = USB_FS_SYS; + closedir(dir); + dprintf(USBDBG_DEVOPENED, USBSYSBUS_PATH); + goto found_devices; + } f = fopen(USBPROCBUS_PATH "/devices", "r"); if (f) { /* devices found in /proc/bus/usb/ */ @@ -1284,15 +1293,6 @@ static int usb_host_scan(void *opaque, USBScanFunc *func) dprintf(USBDBG_DEVOPENED, USBDEVBUS_PATH); goto found_devices; } - dir = opendir(USBSYSBUS_PATH "/devices"); - if (dir) { - /* devices found in /dev/bus/usb/ (yes - not a mistake!) */ - strcpy(devpath, USBDEVBUS_PATH); - usb_fs_type = USB_FS_SYS; - closedir(dir); - dprintf(USBDBG_DEVOPENED, USBSYSBUS_PATH); - goto found_devices; - } found_devices: if (!usb_fs_type) { monitor_printf(mon, "husb: unable to access USB devices\n"); -- 1.6.2.5