NOTE: If you need a 32-bit binary of the script (and want to avoid compiling yourself), please see my blog post: http://djlab.com/2013/01/migrate-a-xenserver-vm-without-a-pool-or-shared-storage/
With the help of Ben Booth's Xen::API (Perl module I hacked up), I put together a VM migration script to export a VM directly to another host with no intermediary file. The transfer occurs over XAPI with no temp files or local disk interaction. This script can run directly on the source or destination host, or any server in between. Bear in mind, you will have the best speeds and least network overhead running this directly on the destination host.
Hint: You're best off compiling a static binary (see below). It would be nearly impossible to meet the dependencies on a live XenServer otherwise.
-sh : source host
-su : source user (usually root)
-sp : source pass
-sv : source VM label or UUID
-dh : destination host
-du : destination user
-dp : destination pass
-ds : destination SR (optional, but the destination server must have a default SR)
-ssl : flag to use SSL for the data transfer of VM
If any of the options are omitted, you will be prompted for them. Using SSL for data transfer appears to reduce the throughput significantly. I would recommend not using SSL transfer if you have a secure network connection between the hosts. SSL will always be used in the XAPI calls regardless of this setting.
###Example output:
[root@cl-ash-h1 ~]# ./migratevm.pl
Enter source host name/IP (blank = localhost): 1.2.3.4
Enter username for 1.2.3.4 (blank = root):
Enter password for 1.2.3.4: ************
Enter source vm name or uuid on 1.2.3.4: my_vm
Enter destination host name/IP (blank = localhost):
Enter username for localhost (blank = root):
Enter password for localhost: ******
Destination SR on localhost (blank for default):
Starting transfer
................... 12.0%, 30618.43 (KB/sec)
Done.
A Dockerfile is available to help build a static binary that can be deployed to XenServer 7 hosts.
Running ./docker_build.sh
will create the container, run the build inside it, and copy the resulting binary out to
your local filesystem, then clean up the container.
The image is based on CentOS 7 for compatibility with XenServer 7.