Pass an USB hub from a KVM host to a guest with libvirt

kvm-virtualizationlibvirtusb

I have the following USB devices on a Linux server:

# lsusb -t
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/6p, 480M
        |__ Port 2: Dev 3, If 0, Class=HID, Driver=usbfs, 1.5M
        |__ Port 3: Dev 4, If 0, Class=hub, Driver=hub/4p, 480M
            |__ Port 1: Dev 8, If 0, Class=print, Driver=usbfs, 12M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/6p, 480M

I would like to pass the entire USB hub (Dev 4) to a Windows XP guest.
In this a device attached and removed to the hub should be automatically handled by the guest (right?).

I tried the following code with virsh attach-device:

<hostdev mode='subsystem' type='usb' managed='yes'>
 <source>
  <address type='usb' bus='0x002' port='1.3' />
 </source>
</hostdev>

but it didn't work:

error: Failed to attach device from attach_hub.xml
error: internal error usb address needs device id

What am I doing wrong?

Best Answer

xml for hub: https://libvirt.org/formatdomain.html#elementsHub

An example:

  <hub type='usb'>
     <address type='usb' bus='0' port='1'/>
  </hub>

https://www.redhat.com/archives/libvir-list/2011-August/msg00816.html