Migrating Xen domainU Guests Between Host Systems

From Virtuatopia
Revision as of 19:10, 11 June 2008 by Neil (Talk | contribs) (Preparing the Xen Migration Environment)

Jump to: navigation, search

One of the most compelling features of Xen virtualization is the ability to migrate a domainU guest from one host system to another. Of particular significance, however, is Xen's ability to perform live migrations whereby a running guest domainU system is moved from one system to another such that there is only an imperceptible interruption in service. In this chapter we will discuss the requirements for performing live Xen domainU migrations before walking through an example live migration.

Requirements for Xen domainU Migration

Before a Xen guest system can be migrated from one host to another a number of requirements must be met:

  • Both the source and destination hosts must have access to the root filesystem (and swap is specified) via the same path name. For example if the root filesystem is contained in a disk image with a path of /xen/xenguest.img then that image file must also be accessible at the same location on the target host. This is most commonly achieved by placing the image files on a file server such that it can be mounted via NFS.
  • Both systems must be running compatible processors.
  • The target host must have sufficient memory to accommodate the migrated guest domain.
  • The source and destination machines must reside on the same subnet.
  • The two systems need to be running compatible versions of Xen.
  • Firewalls (and SELinux if enabled) must be configured to permit communication between the source and destination hosts.
  • Both systems must be configured to allow migration of virtual machines (see below).

As long as the above requirements are met then you are ready to perform a Xen guest migration.

Enabling Xen Guest Migration

By default guest domain migration is disabled in the Xen configuration. A number of changes are necessary, therefore, prior to performing migrations. The required settings are located in the /etc/xen/xend-config.sxp configuration file and need to be implemented on both the source and target host systems. The first modification involves setting the xend_relocation_server value to yes:

(xend-relocation-server yes)

Secondly, the xend-relocation-hosts-allow value must be changed to define the hosts from which relocation requests will be accepted. This can be a list of hostnames or IP addresses including wildcards. An empty value may also be specified to accept connections from any host:

(xend-relocation-hosts-allow '')

Finally, the xend-relocation-address and xend-relocation-port settings on the source and destination systems must match. Leaving these values commented out with '#' characters so that the default value is used is also a viable option as shown below:

#(xend-port            8000)
#(xend-relocation-port 8002)

A Xen Migration Tutorial

In the remainder of this chapter we will work through an example migration of a Xen domainU guest from one host to another.

Preparing the Xen Migration Environment

The first requirement for performing live migrations involves the creation of a Xen domainU guest to migrate. For the purposes of this tutorial, we will need a disk image based domainU guest environment installed in the /xen directory of a server. The steps required to create such a guest are outlined in detail in the chapter entitled Building a Xen Virtual Guest Filesystem on a Disk Image (Cloning Host System), which will instruct you on how to create and configure the following files:


Throughout this tutorial we will also work on the assumption that the source host has an IP address of and the target host has an IP address of

Once the domainU guest has been created, the server needs to be configured to allow the /xen sub-directory on the source host to be mounted via NFS on the target host. On Linux systems this typically involves adding an entry to the /etc/exports file. As an example, the following entry enables the target host (IP address to mount the /xen file directory located on the source host ( via NFS:


Of particular importance in the above configuration is the no_root_squash which allows the target host to write to the /xen directory via NFS as super-user, a key requirement for performing the live migration. Once the /etc/exports file has been modified the change needs to be exported using the exportfs -a command:

exportfs -a

With the exports configured, /xen can be mounted on the target system as follows:

mkdir /xen
mount /xen

Running the DomainU Guest

Before attempting to perform a live migration of the Xen guest it is worth first checking that the guest will run successfully on both the source and target hosts. This will verify, for example, that both systems are configured with enough memory to execute the guest. Beginning on the source host change directory to /xen and run the guest domain as follows:

cd /xen
xm create XenGuest1.cfg -c

Assuming the guest boots successfully execute the appropriate shutdown command and wait for the guest to exit. Once you are certain the guest has exited repeat the above steps on the target system. If any problem occur on witehr system rectify the issues before attempting the migration. Be sure to shutdown the guest on the target system before proceeding.

Performing the Migration

The first step in performing the migration is to start up the guest on the source host:

xm create XenGuest1.cfg -c 

Once the system has booted exit from the console by pressing Ctrl+]. We can now view the list of guests running on the host:

# xm list
Name                                      ID Mem(MiB) VCPUs State   Time(s)
Domain-0                                   0      864     2 r-----   3995.3
centos.5-1                                 1      127     1 -b----     82.6

As shown above our guest domain has been assigned an ID of 1. To perform the live migration we need to use the xm command, the syntax for which is as follows:

xm migrate domain id target host -l

In order to migrate our guest (domain ID 1) to our target host (IP address we therefore need to execute the following command:

xm migrate 1 -l