Using CentOS 6 as the Control Domain for the Xen Project Hypervisor
Lots of hosting companies and other service providers settled on combination of the Xen Project Hypervisor and CentOS as a platform for their virtualization needs. Unfortunately, CentOS 6 brings with it the same kernel as RHEL 6 — a kernel which lacks support for the Xen Project Hypervisor.
Established users had a problem: either give up their hypervisor, or give up the distribution which manages it. But one of the beauties of Open Source software is that modification of the software stack is always an option. And this brought about the birth of a new effort to restore the hypervisor to the distribution via a project called Xen4CentOS.
Just What is in Xen4CentOS?
Xen4CentOS is actually a pretty simple concept: replace the upstream kernel with a standard kernel from kernel.org and include a couple libraries needed to facilitate the hypervisor.
Currently, the Xen4CentOS package includes:
- Xen Project Hypervisor 4.2
- Linux kernel 3.10 (a Long Term Support kernel) from kernel.org
- blktap 2.5 driver and utilities
- libvirt 0.10 drivers for both the xl and xm toolkits
 How Do You Install It?
The process is simple and straightforward. First, you need to install standard CentOS with an eye toward using the Xen Project Hypervisor (including the use of LVM to prepare for VM storage). A review of the Beginner’s Guide is a good idea if you are unfamiliar with installing the hypervisor software.
Once you’ve gotten that done — relax. You have actually the hardest part of the process.
The next step is to connect the Xen4CentOS repository to your machine so that the installation can be done easily. To do this, type:
yum install centos-release-xen
Now that the appropriate repository has been added to the yum system, installing the Xen4CentOS software is a piece of cake. Issue the command:
yum install xen
That loads up the hypervisor software. Now, we need to add the new kernel to the grub menu. To do this, execute the script:
/usr/bin/grub-bootxen.sh
This should produce an entry in /boot/grub/grub.conf which looks something like:
title CentOS (3.10.34-11.el6.centos.alt.x86_64) root (hd0,0) kernel /xen.gz dom0_mem=1024M,max:1024M loglvl=all guest_loglvl=all module /vmlinuz-3.10.34-11.el6.centos.alt.x86_64 ro root=/dev/mapper/vg_xen01-lv_root rd_LVM_LV=vg_xen01/lv_swap rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=uk rd_NO_MD LANG=en_GB rd_LVM_LV=vg_xen01/lv_root SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_NO_DM rhgb quiet module /initramfs-3.10.34-11.el6.centos.alt.x86_64.img
Reboot the system. Then run a couple commands to check to make sure all is well:
uname -a
Will tell you the name of the kernel which is running. The word “xen” should be in the output.
xm info
Should show you that Domain0 is up and running.
That’s about it. It really is that simple.
Of course, you will probably want to do standard tasks at this point, like configuring the console, setting up the network, and creating VMs. But all of those tasks are common and not CentOS-specific.
What Limitations Are There?
There are a few things you need to be mindful about, but the list is rather small.
- SELinux is disabled — You might need to disable SELinux on the dom0 for some operations; primarily when using qemu-xen and blktap backed storage.
- 64 bit only — For the time being, Xen4CentOS is only available on CentOS-6/x86_64. This is not a technical issue, but a question of practicality. A 32-bit kernel is limited to 2GB of memory and the Xen4CentOS team didn’t know if anyone would actually use it when the 64-bit version is so readily available. If you actually want the 32-bit version, join in the effort and help make it a reality.
- libvirt with xm and xl — Both xm and xl work from the command line. Curently, however, libvirt is only completely functional with xm (which needs xend running). Native xl support in libvirt is expected in a future release.
- Console for Dom0 — You will need to manually configure the console if you intend to re-route the Dom0 console.
- Ballooning — A bug in Linux’s balloon driver can be worked around with a Xen Project command line option. See the CentOS bug 6893 report for details.
- It is not the same as the RHEL kernel — If you rely on Red Hat-specific modifications to your kernel, you won’t find them here But the focus of this kernel is to run the Control Domain (Dom0) only; the work normally assigned to Dom0 is primarily control of the hypervisor, which should not require any “special sauce†from the original kernel.
Where Do You Go for More Information?
The CentOS Wiki contains a number of useful documents, including:
Plus there is the #centos-virt IRC channel and the centos-virt mailing list.
Finally, there is an excellent presentation from Karanbir Singh at Xen Project User Summit 2013 describing the history and motivations for the Xen4CentOS effort.
What Does the Future Hold?
The Xen4CentOS is not a one-time, cut-and-run hack. It is being transitioned into the newly formed CentOS Virtualization SIG. This CentOS SIG will focus on providing a specialized CentOS variant suitable for various virtualization technologies, including the Xen Project Hypervisor. In a recent press release, it was announced that Xen Project engineers will play a prominent role in development of the new SIG. The current plan is to provide regular security and bug-fix updates as needed and to upgrade the Xen Project Hypervisor with every even major release (4.4, 4.6, etc), providing matching updates for QEMU, libvirt and other dependent packages.
So if you were thinking about trying Xen Project software on CentOS, there is now every reason to give it a try.