Xen USB passthrough guide
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.
- About Xen Hypervisor
- USB in Xen OS: possible options
- Most efficient method
- Simple step-by-step instruction
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.
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.
USB in Xen OS: possible options
Despite its many advantages, Xen solution still has one major drawback. Like any bare metal hypervisor, Xen is not able to redirect 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. Below you’ll find a super easy way to do this with the help of a USB passthrough application, but first let’s talk about some "native" methods to access USB from Xen.
1. Connecting USB devices using QEMU monitor (for HVM domains)
If you have USB=1 set in your configuration, it’s possible to add or remove USB peripherals with the help of the QEMU monitor. To add a new USB device, use:
In case several devices in your system have the same vendor_id and device_id, you can use device identifiers:
You can also use the command info usbhost:
(qemu) info usbhost (qemu) Device 3.13, speed 12 Mb/s Class 00: USB device 054c:01fb, Network Walkman
To identify devices over the host system, use the lsusb command. For example, for devices:
Bus 004 Device 001: ID 0000:0000
Bus 004 Device 002: ID 0644:0000 TEAC Corp. Floppy
Bus 001 Device 001: ID 0000:0000
Bus 003 Device 003: ID 0529:0001 Aladdin Knowledge Systems HASP v0.06
Bus 003 Device 002: ID 0529:0001 Aladdin Knowledge Systems HASP v0.06
Bus 003 Device 001: ID 0000:0000
Bus 005 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
The host: 3.3 and host: 3.2 identifiers will be used.
To connect a USB Xen device to a working system with a QEMU monitor, you need to follow these steps:
- Switch to the QEMU management console by pressing Ctrl-Alt-2.
- View information about USB devices in the host system.
- Create a connection.
- Work with the device.
- Disable it.
Please remember that once a USB device is connected to the guest system using the QEMU monitor, the operation of the system slows down considerably.
2. Accessing USB peripherals as block devices from a Xen guest domain.
If you only need to see a USB device in the guest domain as a regular block device, you can connect it as a block device. Here’s how you can do it:
% # xm block-attach < domU > < real_dev > < virt_dev > < mode >
- < domU > - the number of a virtual domain or its name (get it using ‘xm list’);
- < real_dev > - block device in the host system;
- < virt_dev > - block device in the guest system (make sure that it does not conflict with devices already existing in the guest system);
- < mode > - the operation mode.
3. 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.
Most efficient 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. 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:
- You install USB Network Gate on both your host and guest operating systems.
- Share the required USB device (physically connected to the host PC) over the network.
- 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 Network Gate
Also available on macOS, Linux OS and Android , 5.62MB size
Version 8.0.1859 (6th Nov, 2017) Release notes