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 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 USB passthrough software, but let’s talk about some "native" methods to access USB from Xen as well.
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.
#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.