Oct 162008
 

Xen is nowadays a widespread approach to run virtual hosts. Thanks to its flexible configuration it’s not only possible to run virtual Linux hosts but nearly any operating system that is compatible to the Xen hypervisor machine architecture will possibly run as guest host. The Xen paravirtualization feature, which provides a tighter association between the hypervisor and the guest kernel makes it especially interesting for running performance critical Linux guests.

For using Xen virtualization a separate patchset always had to be applied to the hypervisor and also the paravirtualized Linux kernel. Because of this it wasn’t always easy to migrate physical servers into virtual one’s, especially when requiring a special kernel version or another profound Linux patchset.

What is paravirt_ops?
Paravirt_ops is a generic kernel structure that represents an interface to a virtualization hypervisor. It allows the kernel to run natively on the hardware but also virtual on a hypervisor. Since kernel 2.6.23 paravirt_ops support for Xen is integrated into the vanilla kernel and since then also support for VMI (VMware) and KVM was added. It is a first step to integrate full Xen compatibility into the mainline kernel tree. Today, with kernel 2.6.27, Xen paravirt_ops support exists at least for the x86 and x86_64 architecture.

How can I use the vanilla kernel as Xen domU?
If you build the kernel by yourself, like every real man does, you have to activate the following features. Build the support directly into the kernel that you don’t have to fiddle around with an initramfs.

Processor type and features  --->
[*] Paravirtualized guest support  --->
--- Paravirtualized guest support
[*]   Xen guest support
...
[*] PAE (Physical Address Extension) Support
Device Drivers  --->
[*] Block devices  --->
<*>   Xen virtual block device support
...
[*] Network device support  --->
<*>   Xen network device frontend driver
...
Character devices  --->
[*] Xen Hypervisor Console support

Now we’re nearly done with it. After compiling the kernel we need to do some small changes concerning the console redirection in the baselayout of the Linux guest. In the future the distributions will likely prepare this for us.

Add hvc0 device node:

root # cd /dev
root # mknod hvc0 c 229 0
root # chown root:tty hvc0
root # chmod 600 hvc0

To change default console to hvc0 you have to edit the /etc/inittab. If not done already, disable all the other virtual consoles:

co:12345:respawn:/sbin/agetty 38400 hvc0 vt100-nav
#2:23:respawn:/sbin/agetty 38400 tty2
#3:23:respawn:/sbin/agetty 38400 tty3
...

Finally permit login on the hvc0 console by adding it to /etc/securetty.

Now we should be able to boot our paravirt_ops system on real hardware the same as on a Xen hypervisor. However compared with a Xen-patched paravirtualized kernel, the paravirt_ops kernel doesn’t support special features like framebuffer support or live migration.

Links:

  • lwn.net – Connecting Linux to hypervisors
  • linuxmonk.ch/trac – Building paravirt_ops domU kernel from vanilla sources
  • Sorry, the comment form is closed at this time.