Bug 542639

Summary: Uses wrong (octal) device number for attaching USB devices
Product: [Fedora] Fedora Reporter: Enrico Scholz <rh-bugzilla>
Component: libvirtAssignee: Daniel Veillard <veillard>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 12CC: berrange, clalance, crobinso, itamar, jforbes, veillard, virt-maint
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: All   
OS: Linux   
Fixed In Version: libvirt-0.7.1-16.fc12 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 549840 (view as bug list) Environment:
Last Closed: 2010-05-28 13:56:29 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 514891    

Description Enrico Scholz 2009-11-30 07:47:50 EST
Description of problem:

libvirtd seems to convert the USB device number into octal mode. This creates problems for numbers >=9

# echo "<hostdev mode='subsystem' type='usb'><source><address bus='6' device='18'/></source></hostdev>" | \
  virsh attach-device winxp /dev/stdin
error: Failed to attach device from /dev/stdin
error: cannot set ownership on /dev/bus/usb/006/022: No such file or directory

This device is reported by the kernel as

| usb 6-2: new full speed USB device using uhci_hcd and address 18

and can be found at /dev/bus/usb/006/018 (which can not be addressed by octal numbers).

Btw, it would be nice when the 'device=...' and 'bus=...' attributes would be always interpreted with a radix of 10.  These numbers are exported by kernel hotplug events as zero-padded values (e.g. BUSNUM=006 or DEVNUM=018).  Having a fixed radix of 10 would allow udev rules with an one-liner as above which auto-attach USB devices.

Version-Release number of selected component (if applicable):

Comment 1 Daniel Berrange 2009-11-30 07:56:23 EST
The problem isn't in the XML parser, but rather in src/util/hostusb.c, in its usbGetDevice() function

    snprintf(dev->name, sizeof(dev->name), "%.3o:%.3o",
             dev->bus, dev->dev);
    snprintf(dev->path, sizeof(dev->path),
             USB_DEVFS "%03o/%03o", dev->bus, dev->dev);

Changing those %.3o  to %.3d  ought to make it work correctly.
Comment 2 Daniel Berrange 2010-02-11 09:43:01 EST
Patch available upstream

Comment 3 Fedora Update System 2010-05-18 12:55:40 EDT
libvirt-0.7.1-16.fc12 has been submitted as an update for Fedora 12.
Comment 4 Fedora Update System 2010-05-19 15:13:39 EDT
libvirt-0.7.1-16.fc12 has been pushed to the Fedora 12 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update libvirt'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/libvirt-0.7.1-16.fc12
Comment 5 Fedora Update System 2010-05-28 13:55:53 EDT
libvirt-0.7.1-16.fc12 has been pushed to the Fedora 12 stable repository.  If problems still persist, please make note of it in this bug report.