Managing full virtual and paravirtual hardware drivers in a Xen environment

Sander van Vugt explains the differences between hardware drivers in full virtual and paravirtual environments.

One of the most daunting tasks facing a virtual machine administrator is hardware management. The topic is confusing, because sometimes you have to deal with real hardware, and sometimes you are talking to virtualized hardware. In some cases, you'll be using full virtualization, and in some cases not. So, according to the virtualization technique that you are using, the hardware will be presented in a different way. In this article,...

you'll learn about the differences between hardware drivers in full virtual and paravirtual environments. I'll be using a Xen environment in this example.

In the Xen architecture, the Dom0 normally is the driver domain. The meaning of this is that only this domain is allowed to use "real" drivers to talk to the hardware devices directly. It is quite common that Domain0 is used as the driver domain, but it is not the only possibility. As you'll learn later, you can give management of certain drivers to certain domain if so required. All domains that are not the driver domain use virtual device drivers that work with the drivers in the driver domain.

In the Xen driver model, there is a back-end driver that runs in the driver domain -- typically dom0 -- and that talks directly to the hardware devices. In the DomU, there is a front-end driver that talks to the back-end driver in the driver domain. To communicate with the back-end driver, Xen creates the Xen bus. This is a virtual bus on which all front-end drivers can talk to the back-end driver in the driver domain. It is the task of this back end driver to handle communications to the hardware device.

The communication between the front-end and back-end drivers can happen in two ways. First, paravirtualization can be used. As an alternative when paravirtualization is not available, emulation can be used.

If you are using a paravirtualized operating system, you automatically will use paravirtualized drivers as well. In this scenario, the driver software knows that it is used in a virtualized environment. As a result, the driver can generate optimized instructions to talk to the hardware directly.

Paravirtualized drivers are not only available in paravirtualization, as also in full virtualization paravirtualized drivers can be used. An example of this is when the Novell Virtual Machine Driver Pack is used. This driver pack, which is available for some operating systems, makes it possible to use paravirtualized drivers for block and network devices. Since these devices cause the highest workload, performance will increase enormously when these drivers are used.

The alternative for the paravirtualized driver is the driver in a full virtualized environment. Since in those environments, the driver is not aware that it is virtualized, all instructions that it generates have to be trapped and emulated. To do this, the Qemu solutions are used, see this Qemu page for more details. Qemu is a processor emulator that offers several solutions to talk to for example emulated disk devices.

To help drivers in the full virtualization, communication has to go through the driver in the driver domain and that negatively impacts performance. Fortunately, there is no extra memory overhead in the driver domain to handle the workload that is caused by these emulated drivers. This is because of a special technique -- which is known as "shadow pages" -- is used in the driver domain.

Driver properties
The properties of drivers in a Xen virtual environment depend on the virtualization technique that you are using. As a result, some operations may be possible in a full virtualized environment and not in a paravirtualized environment, and some problems may exist in one environment and not in another environment. In the following subsections, you'll find essential information about the types of devices and their properties in specific virtualization environments:

  • Block devices: When addressing block devices through paravirtualization, you will see them in the DomU's as the xvd (Xen Virtual Disk) devices. The first paravirtual block device will be xvda, the second one will be xvdb and so on.

    The operating system in the virtual machine will normally perceive these devices as SCSI disk devices. You can have a maximum of 16 of these devices in a virtual machine. The xvd devices in the virtual machines talk to the xenblk module in the Dom0 machine. In the virtual machine itself, the blkbk and blktap kernel modules are used.

    Should you work with a full virtualized DomU machine without using paravirtual drivers, then the machines sees "normal" block devices. That is, if you're virtualizing Linux, you would see hda and hdb, like you are used to on a non-virtualized machine. You should be aware that it's a choice between one or the other. If some of your block devices are full virtualized, all have to be full virtualized.


  • LAN devices: The differences between full virtual or paravirtualized LAN devices are not as obvious as when using block devices. In both cases, you can have a maximum of three virtual network boards. In a paravirtual environment, the netbk and netloop kernel modules are used to talk to the xennet module in the Dom0 environment. The network card itself is presented as the xennet network card. When using Full virtualization, you can choose between a Realtek 8139, an AMD PCnet32 and an NE2000 network board.


  • Video devices: Also for the video board, there is a difference between paravirtual and full virtual. In general, you probably don't even care about this difference as the video board is not important at all for server performance. When using a paravirtual video board, it is presented as a frame buffer device. In the DomU, the frame buffer driver is used to provide its services and in the front end, this driver communicates to the xenfb module. When using an emulated video driver in full virtualization, it is presented as a Cirrus Logic or a generic VESA video card.

Benefits of paravirtualized device drivers
In this article, you've learned about the two ways that virtual drivers are used in a Xen environment. Even if you are working in an environment with full virtualization, it still is possible to use paravirtualized device drivers for some devices. This normally greatly enhances performance of these devices because paravirtual device drivers are aware of the fact that they are used in a virtualized environment.

About the author: Sander van Vugt is an author and independent technical trainer, specializing in Linux since 1994. Vugt is also a technical consultant for high-availability (HA) clustering and performance optimization, as well as an expert on SLED 10 administration.

This was first published in November 2007

Dig deeper on Citrix XenServer



Enjoy the benefits of Pro+ membership, learn more and join.



Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: