[libvirt] [PATCH v4 0/3] usb devices with same vendorID, productID hotplug support

Guannan Ren gren at redhat.com
Fri May 4 08:25:52 UTC 2012

v4 updates:
   make each patch not break build
   make usbDeviceSearch flags filtering code simpler


The set of patch tries to fix the issue when multiple usb devices with
same idVendor, idProduct are availible on host,  the usb device with
lowest bus:device will be attached to guest if usb xml file is given like

<hostdev mode='subsystem' type='usb' managed='yes'>
    <vendor id='0x15e1'/>
    <product id='0x2007'/>

The reason is that the usb hotplug function searchs usb device in system files
to match vendor and product id, the file with lowest number is always found

After fix, in this case, libvirt will report an error like:
# virsh attach-device rhel6u1 /tmp/usb.xml
error: Failed to attach device from /tmp/usb.xml
error: operation failed: multiple USB devices for 15e1:2007, use <address> to specify one

At the same time, the usb part of domain initilization is also updated in patch 2/3

These patches also fix the problem when using the following xml, the usb device
could be hotplugged in two domains without raising errors

<hostdev mode='subsystem' type='usb' managed='yes'>
    <address bus='6' device='7'/>

# virsh attach-device rhel6u12nd /tmp/usb_by_bus.xml
error: Failed to attach device from /tmp/usb_by_bus.xml
error: Requested operation is not valid: USB device 006:007 is in use by domain rhel6u1

More information about the libvir-list mailing list