Migrating KVM hosts with virsh

I played around with KVM live migration over the weekend, and it worked flawlessly. When I was first getting the environment (i.e., /etc/libvirt/libvirtd.conf, /etc/sysconfig/libvirt, SASL credentials, etc.) set up to allow migrations to work, I was greeted with the following error:

virsh # migrate –live kvmnode1 qemu+tcp://thecrue/system
error: invalid argument in only tcp URIs are supported for KVM migrations

This message wasn’t the most descriptive error I’ve ever read, so I turned to the libvirt source to see what was going on. I saw the following comment:

/* Prepare is the first step, and it runs on the destination host. */

And immediately fired up virsh to double check the migrate syntax I was using:

$ virsh
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virsh # help migrate
    .....
    migrate [--live] <domain> <desturi> [<migrateuri>] [<dname>]



I had accidently run the migrate command from the destination host instead of the source host. Once I knew what was going on, I fired off the migrate from the source host and everything worked flawlessly:

virsh # migrate –live kvmnode1 qemu+tcp://thecrue/system

virsh #

I really dig KVM, and have recently become somewhat smitten with openvz. Both technologies rock, and I hope to talk about my experiences with each virtualization technology sometime in the future.

Fixing Slow Fedora PXE installations under KVM

I have been doing a lot of work with KVM, and bumped into an odd issue when PXE booting a Fedora 10 KVM guest. The installer (anaconda) would progress to the point where it would try to locate and configure the network interface, but would spit out the following error and wait for operator input:

                      +--------+ Network Error +---------+
                      |                                  |
                      | There was an error configuring   |
                      | your network interface.          |                      
                      |                                  |                      
                      |            +-------+             |                      
                      |            | Retry |             |                      
                      |            +-------+             |                      
                      |                                  |
                      |                                  |
                      +----------------------------------+



After doing a bit of profiling, I noticed that the guest was having issues initializing the Realtek interface (this is the default interface type presented to KVM guests by QEMU). To see if a different interface type cured my problems, I changed the NIC model to an e1000 by adding the “model” tag to the KVM guest XML file:

<interface type='bridge'>
   <mac address='54:52:00:53:20:02'/>
   <source bridge='br0'/>
      <target dev='vnet2'/>
      <model type='e1000'/>
</interface>



Once I made this simple change, the PXE install worked flawlessly. This was a fun problem to debug, and I learned a TON about QEMU, Anaconda, libvirt and several Linux profiling tools in the process. Viva la problem resolution!

The Fedora 10 qemu-kvm binary doesn’t support the -curses option

I have been playing with the serial console capabilities that are part of qemu, and noticed the following error when I ran qemu-kvm with the “-curses” option on a Fedora 10 host:

$ qemu-kvm -curses
qemu-kvm: invalid option — ‘-curses’

The manual page indicates this should be a valid option:

-curses
     Normally, QEMU uses SDL to display the VGA output.  With this option, QEMU can
     display the VGA output when in text mode using a curses/ncurses interface.
     Nothing is displayed in graphical mode.



But closer inspection of the qemu-kvm binary proves otherwise:

$ qemu-kvm -help | grep curses

$ ldd /usr/bin/qemu-kvm | grep curses

I filed Fedora bug 504226 to get this option added.

Too many option ROMS bug

I created a new KVM host last night, and was greeted with the error “Too many option ROMS” during initialization:

$ /usr/bin/qemu-kvm -S -M pc -m 512 -smp 1 -name kvmnode1 -boot n -drive file=/bits/vms/kvmnode1,if=ide,index=0,boot=on -net nic,macaddr=54:52:00:53:20:00 -net tap,script=/bits/bin/qemu-ifup -serial pty -monitor pty
Setting the tunnel interface to up
Adding the tunnel interface to br0
char device redirected to /dev/pts/1
Too many option ROMS

It turns out this is Redhat bug 473137, which is fixed in the latest etherboot package. If you are running Fedora, you can install this from the testing repository.