Tuesday, 11 February 2014

Xen USB Passthrough

I've been having some trouble passing through USB controllers to Windows VMs running on my unRAID 6.0beta3 Xen host.

Specifically, passing through the full USB controller using PCI Passthrough, I was seeing errors similar to the following when creating or destroying VMs;

libxl: error: libxl_pci.c:1001:libxl__device_pci_reset: The kernel doesn't support reset from sysfs for PCI device 0000:00:12.2 

USB access in the VM would be hit or miss and I'd often get an error on Dom0 indicating that IRQ #18 had been disabled.

Checking out IRQs with lspci -v, I noted that the USB conrtroller I was attempting to pass through was sharing IRQs with several other devices. In fact, all the USB controllers enumerated were on shared IRQs. This was not good.

I the past, I'd successfully passed through discrete USB devices to KVM (via virt-manager) so searched how this could be done in Xen. I found this wiki page which gave me hope. As I needed to passthrough keyboards and mice only, I went for the 1.1 emulation option as the syntax seemed quite similar to pci passthrough.

To find the device addresses I'd need to use lsusb but this function is not included in unRAID 6.0beta3. (it's going to be in beta4 and beyond, apparently).

To list the USB devices and find my mouse and keyboard, I'd need to first install usbutils. Thanks to SchoolBusDriver over at unRAID forums, I found the package I needed to install;
wget http://ftp.lip6.fr/pub/linux/distributions/slackware/slackware64-14.1/slackware64/a/usbutils-007-x86_64-1.txz
installpkg usbutils-007-x86_64-1.txz
The 'installpkg' command needs to be run after each unRAID restart, (unless it's added to go script).

Having re-enabled the USB pci controllers on my syslinux.cfg file and enabled discrete device passthrough in my VM .cfg file, my Windows 8.1 VM booted with mouse and keyboard support.

However, I had one challenge remaining; whenever I clicked on the windows logon password field, it got auto-filled with a stream of characters. It seemed that there was an issue with the keyboard. After a few restarts where I swapped USB cables and double-checked my device codes, I ended up swapping the keyboard for a different one which worked perfectly.

Now I've got mouse and keyboard passed through to Windows VM and no crashes or errors (so far).

I would note that I did manage to pass through the onboard USB3 controllers to a Windows 7 VM in order to access USB storage and that seemed to work just fine.

No comments: