What is paravirtualization?

Paravirtualization is a virtualization technique where the guest OSis modified to be aware of the fact it is virtualized. This has a number of benefits, principally a less complex virtualization layer and more opportunity for optimization since OS is aware of it’s envifronment. This generally increases performance of the VM.

The downside is that in the mainstream virtualization world, Linux is the only supported guest OS for paravirtualization, although some BSD flavors can be paravirtualized too. Anything with an open-source kernel is prone to being paravirtualized, actually. XenSource (now owned by Citrix), was the first big software solution to provide paravirtualization for Linux and NetBSD.

Paravirtualization in VMware ESX and ESXi

Since version 3.5 ESX also supports paravirtualization for Linux guest-OS’ses though the Virtual Machine Interface (VMI). This means that certain Linux VM’s will benefit from performance gains when this option is enabled. As explained in VMware KB-article 1003644, both the ESX-host and the Linux-guest need to be modified to fully enable VMI.

Some Linux distributions have standard kernels with VMI enabled (like Novell SUSE, Ubuntu and Fedora), so you do not need no make a custom kernel for VMI to work. For every other Linux distribution (like Debian, my favourite), you’ll need to enable VMI in the kernel manually. For both these ways of using VMI, you’ll make sure that the chosen distribution has a Linux kernel version 2.6.22 or later. Check with your software distributor if your favorite distribution has a pre-made kernel with VMI enabled available.

Paravirtualization – the easy way

As an example for a distribution with built-in support: here’s how it works:

  1. Create a new VM, select ‘Ubuntu’ or any other distribution with built-in support.
  2. Configure the VM as you like.
  3. Enable paravirtualization in the Virtual Machine Settings:
  4. Install your guest OS as usual.
  5. After installation, check the bootlog to confirm correct functioning of the VMI, using a command like ‘dmesg | grep VMI’.

Note: When trying to paravirtualize the current 64-bits Ubuntu 8.10 (Intrepid Ibex) beta on VMware Workstation 6.5, I recieved an error that a VM requiring both VMI and hardware-assisted virtualization was unable to power on. When trying the 32-bits edition, everything was working as expected. After further investigation, I discovered that VMware only supports 32-bits paravirtualized Linux guests.

Paravirtualization – the hard way

When you favorite distribution does not include a VMI-aware kernel, you’ll need to make a custom kernel. In short, this means recompiling the kernel with two extra parameters (CONFIG_PARAVIRT=y and CONFIG_VMI=y).

  1. Start with creating a VM similar to the above method. Make sure to enable paravirtualization in the Virtual Machine Settings.
  2. Install your guest OS as usual.
  3. Install the needed tools to recompile the kernel (for debian: gcc, make, linux-source-2.6.26 and libncurses5-dev)
  4. Unpack the kernel source (for debian: placed in /usr/src. Unpack with tar xfj filename.tar
  5. Load the configuration with ‘make menuconfig’. Make sure to load the correct configurationfile from /boot/config-2.6.26-1-686.
  6. Enable the ‘VMI-Guest support’ and ‘paravirtualization code’ features under ‘Processor type and features’ – ‘Paravirtualized guest support’.
  7. Compile the kernel using ‘make-kpkg clean' and ‘make-kpkg --revision 1.0.vmi kernel_image' commands.
  8. Install the new kernel package with ‘dpkg -i /usr/src/filename.deb'
  9. Finally, run ‘update-grub' to update the bootloader.
  10. Again, check the bootlog to confirm correct functioning of the VMI, using a command like ‘dmesg | grep VMI’.

Note: Even with the standard kernel in Debian Lenny, the kernel was already VMI-equipped. Rule of thumb: make sure to run a kernel newer than 2.6.25, and you’ll be fine.

Concluding

Paravirtualization support for VMware (VMI) in Linux is very good, as long as you’re running a newer version of the kernel. Enabling VMI will be very easy in most cases (just check the tickbox in your VM’s configuration), and could increase the VM’s performance. As always, remember to install your VMware Tools.

Sources:

http://www.virtualization.info/2008/02/long-vmware-road-to-cpu-para.html

Click to access VMware_VMI_performance.pdf

http://blogs.vmware.com/performance/2008/02/vmi-performance.html
http://www.vmworld.com/vmworld/static/sessions/2008/europe/AP06.html
http://www.electricrelaxation.com/2007/05/27/building-a-vmi-enabled-kernel-for-debian-lenny-testing