Wednesday, July 27, 2011

Migrating running VMs using virsh

Prerequisites:


  1. All VM images are mounted on a shared location,  for example: /vmimages. If any images are qcow2 images with a backing file, those files also need to be present on shared locations.
  2. kvm-pxe needs to be installed. If not, the migration occurs, but the VM is suspended at the destination.
  3. Optional: If you want to be able to do this from scripts, setup ssh keys so you don't need to enter passwords


Migrate with the following command as root on the source host:


virsh migrate --live vmname qemu+ssh://destination.host/system

or if you are not on source, you can first connect to the source host


virsh --connect qemu://source.host/system migrate --live vmname \
      qemu+ssh://destination.host/system



No comments: