Adding USB Devices to a Xen HVM domainU Guest

From Virtuatopia
Revision as of 18:52, 29 May 2016 by Admin (Talk | contribs) (Text replacement - "<htmlet>xen<htmlet>" to "<htmlet>xen</htmlet>")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
PreviousTable of ContentsNext
Virtualizing Windows Server 2008 with XenBuilding a Xen Virtual Guest Filesystem on a Disk Image (Cloning Host System)


Purchase and download the full PDF and ePub versions of this Xen eBook for only $8.99 Add to Cart


Xen provides two mechanisms for adding USB devices to an HVM virtualization domainU guest system. The first technique is a long-term solution requiring the addition of the device to the domainU configuration file and a domainU restart. The second solution is better suited to adding a device temporarily to a running Xen HVM guest system and involves the use of the QEMU monitor.




Identifying USB Devices on the Xen Host System

Before a USB device can be added to a Xen HVM domainU guest it must first be connected to the host system, powered on and identified. USB devices on Linux systems are identified using vendor and product ID values in the form vendor:product. A list of connected USB devices on the host can be identified using the lsusb command. For example:

# lsusb
Bus 003 Device 001: ID 0000:0000  
Bus 004 Device 001: ID 0000:0000  
Bus 005 Device 005: ID 4971:cb07  
Bus 005 Device 001: ID 0000:0000  
Bus 001 Device 006: ID 03f0:a004 Hewlett-Packard DeskJet 5850c
Bus 001 Device 001: ID 0000:0000  
Bus 001 Device 004: ID 413c:2003 Dell Computer Corp. 
Bus 002 Device 001: ID 0000:0000  
Bus 002 Device 002: ID 047d:102e Kensington 

USB devices which are connected are shown with a vendor:product value pair. Devices with 0000:0000 represent USB ports where no device is connected or a device is connected but currently powered off. A list of device ID strings is contained in the /usr/share/hwdata/usb.ids file. If no matching ID is found in the file this field is left blank. This file is constantly updated so it may be worth downloading the latest release from http://www.linux-usb.org/usb.ids.

A Trick to Identify the Correct USB Device

If, even with the latest usb.ids file, you are unsure which ID relates to the device you wish to add to your Xen HVM guest another option is to power off or unplug the device in question and run lsusb again. The device which is no longer listed is most likely the device you are looking for.

Adding the New USB Device to the Xen domainU Configuration File

To add the USB device to the Xen domainU guest to address a long term requirement the device should be specified in the domainU configuration file. The first step is to enable USB support which is achieved by adding the following line to the configuration:

usb=1

With USB support enabled, the next step is to specify the device to be added. Devices are referenced using host:vendor:product where vendor and product are the ID values as listed by the lsusb command. For example, to add the HP printer listed in the previous lsusb output the following line needs to be added to the configuration file:

usbdevice=[ 'host:03f0:a004' ]

Once these changes have been made, restart the domainU system. The USB device should now be accessible within the guest operating system.

Temporarily Adding a USB Device to a running Xen HVM Guest

If access to a USB device is needed temporarily the device can be added to the running domainU guest without shutting it down and modifying the configuration file. This feat is achieved using the QEMU monitor. Before the QEMU monitor of a running Xen HVM domainU guest can be accessed, however, a number of configuration changes are necessary. Firstly, the monitor needs to be enabled in the domainU configuration file:

monitor=1

Secondly, the graphical console of the domainU guest must be using SDL rather than VNC:

sdl=1
vnc=0

Once these changes are made, restart the domainU and from now on USB devices may be added and removed dynamically without having to restart the system. To access the QEMU monitor press Crtl+Alt+2. The graphical display will subsequently change to the text based QEMU monitor. The initial display will read:

HVM device model. type 'q' to exit
(HVMXen) 

At the (HVMXen) prompt a USB device may be added using the usb_add command together with the host:vendor:product value pair of the required device, for example:

usb_add host:03f0:a004

The device may be subsequently removed from the domianU guest when no longer required using the usb_del command combined with the appropriate device identification values:

usb_del host:03f0:a004


Purchase and download the full PDF and ePub versions of this Xen eBook for only $8.99 Add to Cart



PreviousTable of ContentsNext
Virtualizing Windows Server 2008 with XenBuilding a Xen Virtual Guest Filesystem on a Disk Image (Cloning Host System)