Enable the emulated USB hub with usb=1 in the config file for guest.
This will enable qemu to emulate the USB controller for guest VM's and hence will relay information passed by guest to USB device in dom0.
*By default qemu will emulate USB controller which will support USB-1.X devices only.
To passthrough USB-1.X devices, add device to the device list(usbdevice) in a manner shown below. usbdevice=['tablet','host:1.6','host:0424:460']
1.6 => BusID.DeviceID (execute lsusb in dom0 and look for Bus and Device numbers of the device to be passthroughed)
0424:460 => VendorID:ProductID (execute lsusb in dom0 and look for ID field)
Passthrough USB-2.X and USB-3.X
The default USB controller created by qemu is USB 1.1. For some devices, this isn't sufficient. For this reason, you can specify the USB controller version as well, with usbversion . However, at the moment this is incompatible with usbdevice. Hence, do the following:
First line => enable USB emulation.
Second line => emulate USB controller 2.0 and 3.0 respectively.
Third line => device with BusID 002 and DeviceID 001 will be attached to controller 0 (i.e., USB-2.0)
and device with BusID 003 and DeviceID 001 will be attached to controller 1 (i.e., USB-3.0)
*When controller is not mentioned, an appropriate controller will be chosen if available.
*Bus and Device ID can be found by executing lsusb.
Hotplug (Adding USB devices while the guest is running)
Devices are added on-the-go with the help of xl/libxl toolstack in dom0.
Before adding devices an appropriate controller needs to be set up.
Add an emulated USB-controller (USB-3.0) to a guest with the following: xl usbctrl-attach vm_name type=devicemodel version=3
Now add a device to be attached to this controller: xl usbdev-attach vm_name hostbus=3 hostaddr=4 controller=0
*hostbus, hostaddr => Bus ID and Device ID respectively (from lsusb)
*controller ID's start from 0
USB-controller can be detached by: xl usbctrl-detach vm_name dev_id This will remove USB controller with the indicated dev_id, and all USB devices under it
A single USB device can be detached by: xl usbdev-detach vm_name 0 1 This will detach USB device under controller 0 port 1.
To list the USB controller and devices attached to a guest, execute the following in dom0: xl usb-list vm_name
Findings and Known Issues
Following tests were carried out on Dell Latitude E6430 ATG laptop
Table below is a comparison between the time taken to write a file to a USB-3.0 stick in Dom0 and Guest:
USB-2.0 Webcam (Logitech C270)
Successfully captured snapshot and recorded video from the HVM Guest machine(Ubuntu-16.04 LTS), but there was no audio in the recorded video. Not sure if the absence of audio is because of USB-passthrough or is entirely a different issue. This needs to be further investigated.