Electronic Team uses cookies to personalize your experience on our website. By continuing to use this site, you agree to our cookie policy. Click here to learn more.

Xen USB passthrough guide

Editorial Team Editorial Team Dec 18, 2019

If accessing USB devices from your Xen guest OS becomes a real challenge for you, our Xen USB passthrough guide will help you solve this problem. In this article you’ll find simple descriptions of the most common ways to redirect USB peripherals to Xen virtual machine.

What is Xen Hypervisor

Xen is a cross-platform hypervisor that supports a host of advanced features and is widely used on both consumer grade computers and enterprise data servers.

Xen hypervisor works directly on the system’s hardware. What it does is adds a virtualization layer between the system’s hardware and virtual machines, turning system hardware into a pool of logical computing resources that can be dynamically allocated to any guest operating system by the hypervisor. Operating systems running in virtual machines interact with virtual resources as if they were physical resources.

Redirect USB to Xen Hypervisor
14-day free trial

One of the main features of Xen hypervisor is support for paravirtualization, a special OS kernel mode. In contrast to emulation of a separate isolated environment and hardware set for each machine, such mode allows you to achieve much better performance.

With that, the paravirtualization mode has its limitations: privileged operations are prohibited, inability to switch from 32-bit to 64-bit mode and vice versa ‘on the fly’, hardware virtualization of the processor is not supported. None of these factors, however, can significantly affect the performance and usability of the system.

Most efficient Xen USB passthrough method

It’s not a problem to forward any USB device inserted in a host PC to a virtual machine as long as you use a specialized USB virtualization tool, USB Network Gate.
UNG logo

USB Network Gate

Share USB over Ethernet on Windows
4.9 Rank based on 372+ users, Reviews(372)
Try for Free 14-day trial, You can share only 1 local USB-device
 USB Network Gate

Based on the USB passthrough technology, the app lets redirect USB devices over the network (Ethernet, WAN, the Internet) making them accessible from a guest OS. The software solution is available for Windows, Linux, and Mac operating systems and supports cross-platform connections.

This is how the software works:

  1. You install USB Network Gate on both your host and guest operating systems.

  2. Share the required USB device (physically connected to the host PC) over the network.

  3. Start the app on your virtual machine and connect to the shared peripheral in the software interface.

Once connected, the device will appear in the Device Manager of your guest OS like it was attached to the virtual machine physically.

USB in Xen OS: possible options

Despite its many advantages, Xen solution still has one major drawback. Like any bare metal hypervisor, Xen has troubles redirecting USB ports to a host OS. At the same time, there are some ways to get access to a USB device form a Xen guest domain. The above method describes how to do this with the help of a Xenserver USB passthrough software, but let’s talk about some "native" methods to access USB from Xen as well.

Connecting USB devices

Most commonly, USB devices are specified either by their bus address (bus.device) or their device tag (vendorid:deviceid).

You can list the USB devices on the system by using the command lsusb:

Bus 001 Device 003: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 003 Device 002: ID f617:0905
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 004: ID 0424:2640 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 005: ID 0424:4060 Standard Microsystems Corp. Ultra Fast Media Reader
Bus 001 Device 006: ID 046d:c016 Logitech, Inc. Optical Wheel Mouse

For example, if you need to redirect the Logitech mouse, you can specify either 046d:c016 or 1.6.

Typically, individual host devices are forwarded to a guest OS either via an emulated USB device controller or PVUSB.

1. The first method implies that the device model (qemu) presents an emulated USB controller to the guest. After that, the device model process takes control of the device from domain 0 and transmits the USB commands between the guest operating system and the host USB device.

This method can be used with HVM domains only, and isn't available for domains which run with device model stub domains.

As to Xen 4.6, xl only supports the emulated USB, from the config file.

You can enable the emulated USB hub by using usb=1. Then, you'll need to specify devices in the list of devices in the config file together with other emulated devices by using host:USBID. For instance:


USB 1.1 is the default USB controller created by qemu. For some devices, however, this isn't sufficient. In such a case, starting with 4.6, you can use usbversion to specify the USB controller version as well. However, currently this is not compatible with usbdevice, and so is only efficient in conjunction with spice USB redirection. This option is not available for qemu-traditional.

2. The second method, PVUSB, uses a paravirtualized front-end/back-end interface, similar to the traditional Xen PV network and disk protocols.

To be able to use PVUSB, you require usbfront in your guest OS, and usbback in dom0 or usb backend in qemu (or your USB driver domain).

The support for PVUSB in xl/libxl (for both PVUSB device from config file and PVUSB device hot-plug and un-plug) is available since Xen 4.7. Now, it works with USB 1.1 and USB 2.0.

Here's what you should do to pass through host USB devices to the guest with PVUSB:

  • First, from the config file, specify USB controllers and USB host devices using usbctrl and usbdev. For instance:

    usbctrl=['type=qusb,version=2,ports=4', 'type=qusb,version=1, ports=4', ]
    usbdev=['hostbus=2, hostaddr=1, controller=0,port=1', ]

  • Then, for type you can specify auto (the default: xl tries to select the most suitable type), qusb (paravirtualized qemu based backend, should be specified for pvUSB used by HVM domains), pv (paravirtualized kernel based backend, not supported by current standard linux), or devicemodel (qemu emulated USB controller, not yet supported).

    Also, you can specify usbdev only, for example:

    usbdev=['hostbus=2, hostaddr=1, ]

  • After that, it will create a USB controller (version 2.0) and 8 ports automatically, and connect the USB device to the first port of this new controller.
  • In order to hot-plug and un-plug PVUSB device, you can use commands usbctrl-attach, usbctrl-detach, usb-list, usbdev-attach and usbdev-detach.

    For instance:

    #xl usbctrl-attach test_vm version=1 ports=8

Accessing USB devices over the network

Another popular way to get access to a USB device from a Xen guest domain is a dedicated third-party solution working over the network. In this case you’ll need a USB-server (hardware or software) and a USB-client (software). The latter is actually a special driver for the operating system. Now, let’s take a closer look at this simple and efficient way to get Xen USB passthrough support in your virtual machine.

USB Network Gate
Redirect USB devices over network
14-day Free Trial available
License price starts at $159.95
Available for