[CentOS] Install CentOS as KVM guest

Thu Apr 28 20:49:45 UTC 2011
Emmanuel Noobadmin <centos.admin at gmail.com>

On 4/28/11, Gleb Natapov <gleb at redhat.com> wrote:
> of virt stack. You should use libvirt or virt-manager instead. Especially
> if you are concerned about security. I think libvirt can start guest on
> headless server.
> If this still fails for you you need to complain to libvirt developers
> (not in a rant mode, but providing details of what exact version of
> software you have problem with and what are you trying to do). And
> libvirt developers will not be shy to complain to qemu developers if the
> problem turned to be on their side.

I've finally got an installation working, not using virt-install or
virt-manager. After reading through the libvirt site, I started
writing the domain definition manually.

Through trial and error, comparison with what virt-install generated
and the online examples, I got a working xml. Just for the record,
virsh --version reports 0.8.1

For the benefits of other newbies, my discovery so far is that

1. No-activity after the guest VM started
Originally, when I specified the CentOS DVD ISO, the guest will load
and then do nothing but chew up 100% CPU cycle on the allocated 1 vcpu
for quite some time. Subsequently, it appeared that mounting the ISO
as loop back is the solution. This seemed to imply that libvirt or KVM
couldn't boot a guest from ISO... which didn't quite make sense.

I ran into the issue when using my manually generated XML, it turned
out that the reason was the permissions (644) on vmlinuz and
initrd.img on the DVD. By copying the two files to local disk,
changing the permissions and using the <initrd> and <kernel> options,
I was able to boot the guest.

I was curious how virt-install got around this and learnt that I could
dump the config from a running machine. It turns out that virt-install
didn't exactly use the .xml it created, it added stuff to the running
version. Importantly making a temporary copy of initrd.img and
vmlinuz. I think the ISO problem with virt-install may be that it was
unable to mount the ISO to copy these files despite me running it as

2. Anaconda couldn't see the DVD
Which was my rant earlier, since it sounded really stupid that the
installer couldn't see the disc it just booted off. Now, with #1
solved, it seems that anaconda wasn't booting off the disc after all.

However, the interesting thing here is that once I got past #1, My
guest could install from the DVD.

After comparing the xml files, it seems the problem is virt-install
did not save the path to the ISO/mounted DVD. Under the <disk>
element, there wasn't a source. With my manually generated xml,
specifying the ISO as the source worked.

But the virt-installed anaconda was complaining I don't have any hard
disks or cdroms. Not that there was no disk in the drive. Everytime I
picked an option like install media in HDD or CDROM, it prompted me no
device, do I want to install a driver. Since the hard disk definition
appears to be the same, I'm not sure why that happened with
virt-install's xml but not mine.

So right now, I managed to get the OS installed, rebooting it required
removing the initrd and kernel entry as well as the source so that it
would boot from the image disk.

Only problem is... networking still isn't working although brctl show
on the host shows that a vnet0 had been created and attached to the
bridge. Any pointers would be appreciated!