Xen Workflow – Migrating a VM

One of the great features of a hypervisor management suite like XenServer is the ability to migrate a running VM from one physical host to another without affecting running services on that VM. This allows you to balance VMs appropriately across your hypervisors, as well as evacuate a hypervisor so it’s safe to perform maintenance. Doing this migration through the GUI gives you a step-by-step wizard to help set up appropriate options. For my needs, though, it’s got to be automated via the API.

Migrating a VM vs Migrating Storage + VM
There are two types of “live migration” in XenServer. The first type, XenMotion, migrates only the VM itself (that is, the contents of memory, plus misc other VM metadata about the running system). This feature requires that the disks for the VM are on shared storage (NFS, iSCSI, etc) that is accessible to both hypervisors. The second type, Storage XenMotion, migrates the running VM (memory, metadata), and also migrates any disks attached to the VM. This method takes considerably longer (since there is quite a bit more data to transfer), but means that during normal operation of the VM (ie not during a migration), you get the performance benefit of local storage. For more details, have a look at this document from Citrix comparing these two options. I’m not using shared storage, so Storage XenMotion is what I’ll use.

Storage XenMotion
I have a pool with two XenServer boxes, and a VM (“centos_base”) running on the first box. I want to migrate it to the second host, but there are several steps to this process:

  1. Identify the VM to migrate
  2. Identify the destination host
  3. For each VDI (Virtual DIsk) attached the VM, chose which SR (Storage Repository) on the destination should receive it
  4. Chose which network to transfer the disk over
  5. Prepare the destination to receive the transfer
  6. Transfer the VM

All of the above steps (including wizard-style user interaction) are captured in the following xencap task:

Published by

Patrick Schless

I'm a (mostly) ruby/rails developer, living in Chicago. I work at Braintree, and I have lots of side-projects.

Leave a Reply

Your email address will not be published. Required fields are marked *