User Tools

Site Tools


cn:ccr:virtualizzazione:documentazione:xen_to_kvm

Migrating from XEN to KVM

This small guide describes how to migrate existing and running machines from xen (para and hvm) to kvm, and NOT VICE VERSA. KVM is taking over XEN and is getting rather popular, so we think that this is the time for such a guide.

Before you start

We assume you already have an idea on how XEN and KVM work, and how to convert a machine from one hypervisor to the other. Needless to say that to make the migration, you need to shutdown your machine, the migration can't be done live. This guide has been prepared using the Tier1 environment and installation system, so it's possibile that something different could be required on other sites/installations. We assume that the dom0 is running on a SL 5.x machine and that the VMs are SL 4.x. This does not mean that if you start from a different setup things won't work, but additional effort may be required.

This procedure works both for disk-on-a-file and disk on partition approaches. In our environment generally disk partitions are LABELLED, so there is no need to change anything inside /etc/fstab. If you are using direct disk device specifications you may need to change the devices to something suitable to KVM. Generally the problem can occur with para-virtualized xen machines that use /dev/xvd instead of /dev/{hd,sd}. Pay attention to this before beginning the further steps.

XEN-para to KVM

Log on the node and perform some modifications:

  • If the machine does not have already one, install a standard kernel (that is to say, not a xenU)
  • Set the default kernel to the one you just installed
  • Remove any reference to the virtual console on the kernel line console=xvc0
  • modify /etc/inittab this way
    • comment in tty section of inittab the line beginning with co: that enables the serial console
    • uncomment all the 6 standard consoles
  • if you don't need ldap or if you want to speed up the first boot process, add this line to /etc/ldap.conf
    • bind_policy soft, remember to add it again after you reconfigured the network

After all these operations, you can reboot the node using kvm instead of xen. As an example, a command line to launch a node could be something like:

qemu-kvm -hda disk.img -net nic,model=e1000,macaddr=00:16:3e:00:00:00 -net tap -m 2048 -vnc :0

When the machine starts, kudzu will detect several hardware changes; it is quite safe to answer yes to all the questions and after some seconds, the node should be ready again, this time running on KVM.

XEN-hvm to KVM

With XEN-hvm the process is simpler. Log on the node and perform some operations;

  • if you are using para-virtualized drivers, erase the corresponding line in /etc/modprobe.conf
  • if you plan to use e1000 network driver, add alias eth0 e1000 in /etc/modprobe.conf
  • if you don't need ldap or if you want to speed up the first boot process, add this line to /etc/ldap.conf
    • bind_policy soft, remember to add it again after you reconfigured the network

After all these operations, you can reboot the node using kvm instead of xen. As an example, a command line to launch a node could be something like:

qemu-kvm -hda disk.img -net nic,model=e1000,macaddr=00:16:3e:00:00:00 -net tap -m 2048 -vnc :0

When the machine starts, kudzu will detect several hardware changes; it is quite safe to answer yes to all the questions and after some seconds, the node should be ready again, this time running on KVM.

Appendix: Mounting a disk image file to edit configurations

If your VM is already turned off, you can avoid turning it on again to perform the modifications described in this page. You can follow this small guide.

At first place create a device mapper for the disk image:

kpartx -a node1.img

You can check which is the device by ‘kpartx -l node1.img’.

# kpartx -l node1.img''<br>
loop0p1 : 0 8177022 /dev/loop0 63''

Then mount the filesystem:

mount /dev/mapper/loop0p1 /media/xenvm

Chroot to the the Xen VM filesystem:

chroot /media/xenvm

Perform an update on the existing package to avoid any package conflicts during kernel installation and then installed the normal Linux kernel:

yum update
yum install kernel

Exit the chroot environment:

exit

Umount the disk image and remove the mapper:

umount /media/xenvm
kpartx -d node1.img

The disk could then be used with KVM with no problems at all, both via libVirt and direct KVM/Qemu environment.

cn/ccr/virtualizzazione/documentazione/xen_to_kvm.txt · Last modified: 2010/04/19 13:09 by andrea.chierici@cnaf.infn.it

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki