Migrate Xen to KVM on RHEL/CentOS 6

Red Hat's own documentation can be found here:
http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Virtua...

Set up bridging on server:

  • http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Virtua...
  • Follow suggestion: Instead of turning off NetworkManager, add "NM_CONTROLLED=no" to the ifcfg-* scripts used in the examples.
  • In my experience it was necessary to have the following lines in ifcfg-br0 (replacing .4. as required)
  • BROADCAST=192.168.4.255
    NETMASK=255.255.255.0
    NETWORK=192.168.4.0

  • It is also necessary to disable network manager (using the services tool) or the network will have to be restarted by hand every time the system is booted

Storage Pool

  • An LVM volume group can be set up as a storage pool, e.g. named lvm_cdrive

Convert machine with virt-v2v

  • note that all configuration files are in /etc/libvirt
  • create an xml file on the xen server with: virsh dumpxml vm_name > vm_name.xml
  • Create a disk image file of exactly the same name that the LV will have
  • edit the xml file and in the disk section change the lines
    driver name='phy' to name='file' type='raw'
    source dev='name of old lV' to source dev='new disk image file'
  • optionally change the MAC address (and this will also have to be changed in /etc/sysconfig/network-scripts/ifcfg-eth0
  • Now create the VM: (lvm_cdrive is the LVM pool you have created)
    virt-v2v -i libvirtxml -op lvm_cdrive --bridge br0 www.xml
  • If a logical volume is created with a virt tool, it is important to use the tool to delete it.

Update Data

  • If the MAC address has been changed so that both the new and old machines can be running at the same time, directories in the new machine (that have changed since imaging) can be updated from the old with rsync:
    RSDIR=/etc
    RSREMOTE=www
    RSOPT="--archive -v --delete --compress --sparse --stats --progress --rsh=ssh"
    rsync $RSOPT root@$RSREMOTE:$RSDIR/ $RSDIR

KVM Notes

  • When changes are made to the xml file, you need to reload it
    virsh shutdown vm_name
    service libvirtd restart
    virsh start vm_name

-The highest performing drive uses dev='vdx' bus='virtio' and sets cache='none' on the driver
-KVM will not allocate vdb if vda is not used
-Have to modify the fstab and the boot file for this change to work

See also:
- http://www.techotopia.com/index.php/Creating_a_CentOS_KVM_Networked_Brid...
- http://wiki.centos.org/HowTos/KVM