I have a CentOS 5.3 (actually a CentOS 5.2 build upgraded in yum, but that’s not terribly important) x86_64 machine that is in fact a Xen hypervisor kernel with said CentOS 5.3 running as the dom0 (service VM), and currently four guest VMs also running CentOS 5.2 x86_64, upgraded to CentOS 5.3 with yum. This was a kind of interesting project in itself, in that I used the Gitco repos in order to get Xen 3.3.1 on the CentOS build, and I had to do some hackery of the Xen and stock CentOS networking scripts to make things work. The box doesn’t use Xen network scripts and xenbr0, because they broke pretty badly with bonded dual NICs. It has a fairly standard Ethernet bond setup going, then a patched RH network script so bridges don’t init before the bond, a standard Linux bridge br0, which all my Xen vifs attach to, and a virbr0 which doesn’t have any physical NICs attached, but does have an IP address and dhcpd running against it, so I have a place to quickly fire up new VM guests without having to assign network addresses.
This complexity lead to a few problems, partly during installation, when I ended up temporarily having to go wiht a non-Xen kernel in order to update bits and ipeces and set up repos so I could go back to a Xen kernel, and when yum wanted to update to kernel-xen-2.6.18-128.1.10.el5 and like a trusting fool I let it, and promptly had no running VMs on the next reboot. Hacking grub back to 2.6.18-128.1.6.el5xen seemed to sort it, and it never got changed from there.
Actually, to tell the trust, I also have another machine built a similar way, sans CentOS 5.3 upgrade. This one was meant to potentially be a home to a windows machine, or most likely a Linux MCE installation running in a non-PV guest. That one didn’t get installed yet, and has been sitting under my desk for many a month, waiting for cabling. Oops.
My guest DomUs are living in Xen virtual disks which are inside LVM logical volumes as far as the dom0 is concerned. If I’d been smarter, I might have set up three LVs for each domU – one for /boot, one swap and one for /, so that I cold more easily manage them from not only the guest domU, but also the dom0 if the domU was offline for any reason.
The increased exposure KVM is getting in RHEL 5.4 is making me wonder if all this Xen tinkering is worth it. My machine only runs Linux guests, and then only really for a bit of process separation security. Given that the dom0 has to do a bit of service work for guest domUs anyway, and it seems that this involves a bit of context switching overhead, I don’t see that doing the hypervisor function in the kernel is going to be a problem for me, especially on that currently unused box, which is going to be a home all-in-one media, file/print, NATting, caching and bandwidth arbitrating machine. As I was going to just accept doing all the networking for that (including the firewall/NAT/bandwidth and some VPN stuff) in the dom0 instead of making the Xen networking even more complicated with dual virtual NICs and a virtual firewall box, I guess just making all that work in plain old Linux and then loading up a kernel module when I want a media centre guest VM (yes, I know I could just be less lazy and make all the bits of Linux MCE work under CentOS natively, but starting a VM and installing an OS-up image for LMCE seems like a good thing) installing makes a bit of sense.
The currently unused machine isn’t so bad – as it currently has no VMs and didn’t get the 5.2/5.3/Gitco hybrid horror treatment, I could just strip Gitco repo, group uninstall Virtualisation (sorry Virtualization), and boot it as a regular Linux kernel, do the networkingy bits (and make better use of my rather rubbish 1.5Mb/s of patchy ADSL) and then worry about that media server when the time is right. The dual-NIC networkign will be far easier – one outside one inside, attach a separate bridge to each and I could then attach VMs to the “public” or “private” bridges and the host OS will iptables them like any other hosts. Great!
It’s that first server that is going to be ‘interesting’. Fedora’s virt-v2v is a ways off yet, so I’ve got to think of smart ways of moving painlessly from Xen to KVM without losing services for long. The current outline plan goes something like:
- Install a plain old Linux kernel into each VM guest
- Install a plain old Linux kernel into the current dom0
- Make new LVM logical volumes for guest VMs – possibly three each for /boot, swap and /
- Modify guest VM grub config to default the plain old Linux kernel
- Shutdown guest VMs
- Reboot dom0 as a plain old Linux kernel, albeit with KVM support loaded
- Make any networking changes required
- Create new KVM virtual machine images in the logival volumes
- Stop the new KVM guests
- Mount guests Xen virtual ‘disks’ (actually just some partitions I think, not full bootable disk images) on loopback in the dom0
- dd the contents of the Xen partitions into the new LVM logical volumes, overwriting the guest images created at step 7
- Start the KVM guests
- Panic when it goes wrong (had to be step 13, didn’t it?)
I’m hoping that the fact I already do the networking outside of Xen, and just use standard Linux bridging on and the libvirt virbr0, will mean a slightly easier migration – all I have to do is get my instances booting off a standard kernel instead of a Xenified one, and inside a different virtual disk format.
I’ll still need my standard-breaking networking patch to enable bonds before bridges though. Hopefully RH fix that one in RHEL 5.4 so CentOS picks it up in the next release.




Since writing this, I’ve realised that because I installed my Xen guests with virtual disks in LVM logical volumes, they’ve been installed the same way as they would if they were physical drives instead of an image file – they have a /boot partition, a swap partition and a / partition, and dd says the first block looks the same to the dom0 as it does to the domU.
Perhaps I’ll be able to just stick a plain kernel on, make that default before shutdown and then fire them up under KVM straight from the logical volume with no messing about.
Fingers crossed!
Hi Chris, why did you say “5.2/5.3/Gitco hybrid horror treatment”? Since month I work with the GITCO repo and had never problems with it. Dom0 is CentOS5.3 (x86_64) and the DomUs are Windows2003-2008 (GPLPV), Debian Lenny, CentOS5, Opensolaris. I work with HVM and PVM machines without an errror. The performance is very good. I had never such a performance with KVM! Thanks Jeff
Hi Jeff!
I’m casting no doubts on the Gitco repos at all – they’ve served me well and tge box is still unmigrated and running Xen!
I had a bit of a nasty experience when I did my first yum update with Gitco repo enabled – no VM guests could start after reboot! At the time I just hacked grub back to an earlier kernel and put it down to inexperience.
Fairly recently I discovered that I’d got repo priorities a bit wrong, fixed that and did a manual rpm cleanup of the mess I’d made for myself.
Currently, after a paranoid triple-check of repo priorities, installed kernels and Xen versions, I felt confident enough to let yum do it’s trick, and I have an updated and running dom0!
I noticed an oddity with grub not always being updated correctly, so I always scan it now before rebooting after an update – I’ll post on that when I understand it better…
When I get my other host up, I’ll hope to do some Xen/KVM comparisons & see what comes out.
Either way, Red Hat are likely to push KVM harder in future. Could be an interesting competition!
Cheers,
Chris