Migrate a XenServer VM without a Pool or Shared Storage

Source is now in github, please help me make it better! If you just want a 32-bit binary (to run on Dom0), download it from here instead.

With the help of Ben Booth’s Xen::API (Perl module) 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.

As of today, MigrateVM has been tested and works fine on XenServer 5.6 through 6.5.

Options:

-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)

If any of the options are omitted, you will be prompted for them.

Example output:

[root@cl-ash-h1 ~]# ./migratevm
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.

Download the script like this:

wget http://djlab.com/stuff/migratevm-1.0.2.tar.gz
tar zxf migratevm-1.0.2.tar.gz && cd migratevm-1.0.2
./migratevm

If you get ‘bad ELF’ or something like that on a 64 bit system, try to install 32-bit glibc, for example:

Older XenServers: yum install glibc.i686
XenServer 6.5:  yum install glibc.i686 --enablerepo=base --enablerepo=updates --disablerepo=citrix

Binary and source are both included in the tarball.

Version 1.0.2 has an updated binary build which should now run on XenServer 6.5. We needed to static link expat into the binary because it is no longer installed by default on XS 6.5.

106 Responses to Migrate a XenServer VM without a Pool or Shared Storage

  1. Atoms says:

    tried on both on DOM0 and guest machine both segmentation fault:

    # strace ./migratevm
    execve(“./migratevm”, [“./migratevm”], [/* 23 vars */]) = 0
    [ Process PID=1098 runs in 32 bit mode. ]
    brk(0) = 0x9ab0000
    mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xfffffffff7783000
    access(“/etc/ld.so.preload”, R_OK) = -1 ENOENT (No such file or directory)
    mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xfffffffff7782000
    set_thread_area(0xff857e04) = 0
    — SIGSEGV (Segmentation fault) @ 0 (0) —
    +++ killed by SIGSEGV +++
    Segmentation fault

  2. Randy says:

    Should work now guys. I had uploaded the wrong binary. I just re-tested it on a XenServer 6.1 dom0 and it working.

    
    [root@cl-ash-h1 ~]# ./migratevm
    Enter source host name/IP (blank = localhost): vps1c.ash
    Enter username for vps1c.ash (blank = root):
    Enter password for vps1c.ash: **********
    Enter source vm name or uuid on vps1c.ash: c790vm2
    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
    ...................    4.0%, 4995.63 (KB/sec)
    
  3. ChrisB says:

    I think it still has a problem, I get a “Export task returned status pending:” and it exits to [root@xenserv-2 ~]#

    I am running Citrix XenServer 6.1 with Hotfix up to 22 on Dual Intel Xeon Quad Core Processors.

    [root@xenserv-2 ~]# ./migratevm
    Enter source host name/IP (blank = localhost): 192.168.1.8
    Enter username for 192.168.1.8 (blank = root):
    Enter password for 192.168.1.8: *******
    Enter source vm name or uuid on 192.168.1.8: 6f9ce372-8e24-011e-4230-a19388d4743a
    Enter destination host name/IP (blank = localhost):
    Enter username for localhost (blank = root):
    Enter password for localhost: *******
    Destination SR on localhost (blank for default): 6cc62bb7-5245-5355-3996-19fa1614392e
    Starting transfer
    Export task returned status pending: [root@xenserv-2 ~]#

    1. Randy says:

      Make sure the source VM is shut down or otherwise in the correct state to be exported.

  4. Kyoshiro says:

    Great tool.
    It is possible to preserve MAC-addresses of VM?

    1. Randy says:

      To preserve MAC address(s), you would either need to change the MAC manually after the migration or it could also be possible to add some code to the script to do it for you.

  5. Caleb says:

    I’m getting this message after ‘Starting transfer’:
    Can’t call method “Xen::API::task::get_record” on an undefined value at /tmp/par-root/cache-768103c6bf7f6a2923d1a1ce2bed3f3daff01c76/inc/lib/Xen/API.pm line 674, line 6.

    Any idea what I might be doing wrong? This is being run on the XS6.2 destination Dom0, pointed at a XS6.0 source.

  6. hellmind says:

    Export task returned status pending
    xs62

  7. Jules says:

    Thanks for the great utility which I’ve recently been using.

    There just one problem I’ve found which I hope you can fix.

    The command line parsing doesn’t process the -dsr switch. I checked the source code and on line 43 of migratevm is the errror.

    my $dsr = $opt->{‘dpass’} || Xen::API::input(“Destination SR on “.$dhost.” (blank for default): “);

    Looks like a simply “cut ‘n’ paste” error, where dpass should be dsr

    I would be very grateful if this could be fixed and a new download made available as I’m unfamiliar with converting the source into an executable.

    Many thanks

    J

  8. Randy says:

    The destination SR bug has been fixed with v1.0.1. Please re-try the new version of the script if you were getting errors like “Status Pending” when defining a destination SR.

  9. Jules says:

    Thanks for the quick response, unfortunately the utility now throws the following error (using command line switch or replying to the prompts)

    “simple_request” is not exported by the RPC::XML::Client module
    Can’t continue after import errors at script/migratevm.pl line 37

    Any ideas?

    Thanks

    J

  10. Randy says:

    Sorry… really need to get some version control. Made one more change and it tests OK now. Try again.

  11. Jules says:

    It’s working again but I’ve hit another problem. The transfer kicks off ok if prompted for the dest SR but when specifying a SR with -dsr an error is trown. I’ve tried passing in the uuid and name-label of the target SR but the following message is displayed

    Starting transfer
    Export task returned status pending:

    and the tool exits immediately and I’m left with pending tasks on the source and dest hosts. I have to do a xe-toolstack-restart to tidy up.

    I’d like to use migratevm in a schedule shell script but I’m stumped until it can run without user input.

    Thanks

    J

    J

  12. Randy says:

    Interesting. Could you give me an example of your full command line setup (passwords redacted of course)

  13. Jules says:

    ./migratevm -sh hostA -su root -sp password -sv vm -dh localhost -du root -dp password -dsr “Local storage”

    or

    ./migratevm -sh hostA -su root -sp password -sv vm -dh localhost -du root -dp password -dsr 5d05880e-d464-5b89-ea96-d8348a47a27c

    If I put -dsr junk for example, an appropriate error message is displayed.

    J

  14. Jules says:

    I did a bit more debugging with strace and I think the problem is simply due to a ‘>’ character being appended to the sr_uuid on the PUT command on line 681 of API.pm

    print $dsock “PUT /import/?session_id=$d->{session}&task_id=$dtask”.($sr_uuid?”&sr_uuid=>$sr_uuid”:””).” HTTP/1.1\r\n”;

    Looking at the xensource.log on the dest hosts backs this up with the error message
    [20130730T08:01:58.519Z|debug|xen5|335 inet-RPC||http_critical] Unhandled exception: Db_exn.Read_missing_uuid(“SR”, “”, “>5d05880e-d464-5b89-ea96-d8348a47a27c”

    Hope that helps

    J

  15. Randy says:

    I think you’re right; there was an unnecessary > sign. Try again?

  16. Jules says:

    Thanks, works great now!

    J

  17. Randy says:

    thanks for your help! I never used the dsr option apparently 🙂

  18. Flemming says:

    [root@xenserver-1 migratevm-1.0.1]# ./migratevm
    migratevm 1.0.1 started
    Enter source host name/IP (blank = localhost): 192.168.0.30
    Enter username for 192.168.0.30 (blank = root): root
    Enter password for 192.168.0.30: ************
    Enter source vm name or uuid on 192.168.0.30: Acadre
    Enter destination host name/IP (blank = localhost): 192.168.10.81
    Enter username for 192.168.10.81 (blank = root): root
    Enter password for 192.168.10.81: ****************
    Destination SR on 192.168.10.81 (blank for default): b74b1e8e-306b-418d-6a12-62922b4e88a0
    Connecting to source host
    Connecting to destination host and Starting transfer
    Can’t use an undefined value as an ARRAY reference at /tmp/par-root/cache-2b8a1684f926aafa15f592120acb24c2765dc039/inc/lib/Xen/API.pm line 301.

    Pls Help

    1. Randy says:

      What version of XenServer on each side? Are you sure the source and destination IP and passwords are correct? Make sure you can connect remotely to each machine using xe to verify.

  19. Flemming says:

    pretty sure about ip and password

    i am trying to move from version 6.0 to 6.2

  20. Flemming says:

    Sorry my mistake got wrong default gateway on the suorce xen server

    Sorry

  21. Pandu Poluan says:

    Whoa! This looks exactly what I need!

    I’m tasked with moving a VM from a standalone host into this shiny new pool, and this script looks like my salvation! Gonna test it out real soon and report back with the results.

  22. Okay, I’m now using this tool to do a copy. But due to the size of the VM, it will take a while (more than 24h), while the VM’s application owner wants the VM to be started after 12h.

    So, I plan to take a snapshot of the VM, and copy that instead. Is it possible to run this script against a Snapshot?

    1. Randy says:

      It works for templates (and theoretically but untested, snapshots).

  23. Sven says:

    Great tool, makes my life a lot easier. Thanks!

  24. Eric B says:

    If you get the error : Export task returned status pending. You need to enter he UUID of the storage at the destination Storage field, not the name. it should work after that.

    1. Randy says:

      This could be due to spaces in the name. I might need to URLencode the SR string before sending the PUT request.

  25. Lars Kuhlmann says:

    Great tool.

    Is it possible to modify the script, to take a snapshot of a VM and replicate the snapshot instead.
    I dont have the option to shutdown the VM while replicating.

    Thanks

    1. Randy says:

      You can take a snapshot then migrate the snapshot by name or uuid. It appears on the new server as a template you can use to create a new VM. 🙂

  26. Joof Eloof says:

    Bravo!

    Thank you very much for this.

  27. Joe says:

    Thank you very much! Btw, does this script work for copy a VM from one pool to another?

    1. Randy says:

      It works with or without pools.

  28. Joe says:

    Question, it looks like the script only works on our pool master, for the other servers in the pool , please help!

    [root@p3459987 migratevm]$ ./migratevm
    migratevm 1.0.1 started
    Enter source host name/IP (blank = localhost):
    Enter username for (blank = root): root
    Enter password for : ********
    Enter source vm name or uuid on : WWWServer
    Enter destination host name/IP (blank = localhost):
    Enter username for localhost (blank = root):
    Enter password for localhost: ********
    Destination SR on localhost (blank for default):
    Connecting to source host
    Connecting to destination host and Starting transfer
    Can’t use an undefined value as an ARRAY reference at /tmp/par-jfore/cache-2b8a1684f926aafa15f592120acb24c2765dc039/inc/lib/Xen/API.pm line 301.

    if we use the UUID, it complains its not found:
    Connecting to destination host and Starting transfer
    Could not find VM ‘9b916c1e-736d-4c15-a6e3-3f5a22ccaaf1’ at /tmp/par-root/cache-2b8a1684f926aafa15f592120acb24c2765dc039/inc/lib/Xen/API.pm line 616.

    1. Randy says:

      After an email exchange with Joe it appears the use of local storage for VM’s in a resource pool was the root of the problem. Apparently VM’s using local storage need to be migrated to the master before migration. I’ve verified that at least with the case of a VM on shared storage, it doesn’t matter which node of a pool the VM resides on.

  29. jwoods05 says:

    Hi, this is an awesome tool that hopefully will save me some time! I’m currently exporting from a Xen 6.2 to Xen 6.2 server and the import seems to hang at 8.7% while the export on the source server keeps incrementing based off of xe task-list for the export. Have you seen this before? I have killed the export several times and always hangs at 8.7%.

    Thanks in advance!

    1. Randy says:

      Sometimes it makes it to a point and doesn’t increase and seems to hang, HOWEVER if it doesn’t error out, the task is on-going and will eventually finish. I usually don’t see much higher than 60-70%, less for smaller VM’s.

  30. jwoods05 says:

    Awesome, thanks for your quick response, I was getting nervous there, haha.

    Thanks!

    J

  31. TestUSer says:

    script doesn’t work:

    user@host>./migratevm
    Usage: ./migratevm [ -Alib.par ] [ -Idir ] [ -Mmodule ] [ src.par ] [ program.pl ]
    ./migratevm [ -B|-b ] [-Ooutfile] src.par

  32. Sbleck says:

    Hello,

    Thanks for offering this valuable tool. IÂīve successfully migrated 3 of 4 VMs using this tool, but when I tried the last VM I encountered the following problem:

    [root@xenserver01 migratevm-1.0.1]# ./migratevm
    migratevm 1.0.1 started
    Enter source host name/IP (blank = localhost):
    Enter username for localhost (blank = root):
    Enter password for localhost: ******
    Enter source vm name or uuid on localhost: Orabkp
    Enter destination host name/IP (blank = localhost): 10.4.15.243
    Enter username for 10.4.15.243 (blank = root):
    Enter password for 10.4.15.243: ******
    Destination SR on 10.4.15.243 (blank for default):
    Connecting to source host
    Connecting to destination host and Starting transfer
    …………… 34.0%, 10901.45 (KB/sec)
    Done.
    Export task returned status failure: IMPORT_ERROR_PREMATURE_EOF[root@xenserver01

    Could this be circumvented ? Please give back some advice of comment about how this could be solved, as soon as possible too…

    Thanks in advance !

    1. Randy says:

      The error seems as being generated by the source machine. Check the source machines’s logs for more clues… rule out anything obvious (full disk, out of memory, ect).

      1. Randy says:

        After working with Sven offline, sadly, we determined the issue was a bad sector on the source machine.

  33. Stefan says:

    Great tool. Everything worked with XCP 1.6 and XenServer 6.2.
    Thanks!

  34. Marek says:

    Hello,
    is it possible to transfer only “vhd” storage across two xenservers? I allready transfered multiple servers, but now I need to move one storage which was not attached to specific virtual machine.

    Thank you.
    Great JOB!

    1. Randy says:

      I don’t think there’s a provision for it in XAPI. Just attach it to a dummy VM (make one from ‘other’ template) then migrate it.

  35. david says:

    Export Task returned status pending:

    Tried names and also UUID’s, but same results. Was hoping this was my holy grail of migrating scripts.

    1. Randy says:

      Export Task returned status pending usually means a connection issue with the destination or source server – network/user/pass ect…

  36. Davison says:

    I’m getting the same types of errors as Joe:
    Can’t use an undefined value as an ARRAY reference at /tmp/par-726f6f74/cache-e3f497f802b9bfd14103597e404c8e9260e4169f/inc/lib/Xen/API.pm line 108 (using vm name)

    Could not find VM ‘696f0eba-94fa-a118-dbf6-85c3b59e4c73’ at /tmp/par-726f6f74/cache-e3f497f802b9bfd14103597e404c8e9260e4169f/inc/lib/Xen/API.pm line 268 (using UUID)

    However, I don’t have a resource pool at all so there is no “master” to migrate to before running this migration. Isn’t that the whole point of this script? That is, “Migrate a XenServer VM without a Pool or Shared Storage”. I thought it could be a problem with spaces in the VM name, but even the UUID option fails as well. I was really hoping this would work as it would save so much time…

  37. Davison says:

    I did end up getting it to work.

    The problem was that I was using a different IP address on the source server other than the one set as the “management” interface. Even though it was a perfectly valid IP (could SSH into the server fine) apparently Xenserver only allows API connections to the management interface. Once I used that specific IP address it worked properly.

    It took quite a while to get it working (largely due to having to create a new VM just to get the right architecture and glibc version for the compiled perl binary to run) but it’s great now. Thanks!

    1. Randy says:

      In the original post, it mentions that you need to install 32-bit glibc on 64-bit systems. Did you have to do more than that? FYI, the reason it’s compiled in 32-bit is so it can run on XenServer Dom0, however 32-bit glibc should be all that’s needed on a 64-bit system.

  38. Davison says:

    The problem was I didn’t have any 32-bit systems around. Except for my XenServer system all I had were 64-bit systems, and compiling it on them wouldn’t allow it to run on a 32-bit system. Then I created a 32-bit CentOS 6 VM to compile the script and the XenServer complained about not having glibc 2.11 (XenServer 6.0 has glibc 2.5). So I looked and found that CentOS 5.8 uses glibc 2.5, and once I created a VM using that version of CentOS it finally worked. Maybe I’m overlooking something else, but my research about compiling on a 64-bit platform for a 32-bit system led to all sorts of arcane and overly complex issues.

    1. Randy says:

      You do realize there’s a pre-compiled binary in the tarball on the original post that works on Dom0? Having been through your pain, I included it for that reason.

  39. Davison says:

    Doh. I downloaded the source from Github and started from there. Oh well, at least I have everything set up to build if I wanted to tweak anything in the source…

    1. Randy says:

      Ah, well, github frowns on putting binaries in repos, so I didn’t… but I’ll add big note to the repo mentioning this.

  40. Boy says:

    Thanks, this script saved me a lot of time. Just one remark, while transferring a large VM (3 virtual disks with a total capacity of 275 GB) i’m getting an out of memory error arround 28% progress. Maybe this can be fixed easily? Thanks in advance!

  41. Ryan says:

    Just wnated to post that this script is really cool and useful. Appreciate the work you put in to this.

  42. M. Mirzayev says:

    Dear Randy,

    at first i would like to thank you for this masterpiece. It saved me a lot of time while moving several machines from one host to another.
    I know that it is a lot of work to program this stuff but is there a possibility to implement a flag to preserve mac-addresses of the vms? My programming skills aren’t very well and that’s why i can’t do it on my own.

    Would be really nice if you could think about it.

  43. M. Mirzayev says:

    Had a problem while trying to run migratevm on Ubuntu Server 12.04 32bit.

    Upgraded to XenServer 6.5 and had the problem with bad ELF which was resolved by installing the glibc32. But then the RPC::XML-Problem occured.
    So i tried to install a dedicated VM (Ubuntu 12.04 32bit) which had the same RPC::XML-Problem.

    migratevm 1.0.1 started
    Connecting to source host
    Can’t locate object method “simple_request” via package “RPC::XML::Client::new: 8a1684f926aafa15f592120acb24c2765dc039/inc/lib/Xen/API.pm line 144.

    So i decided to try the XenServer 6.2 DDK and it works fine. Imported the OVA entered a Password in the console in XenCenter and started to migrate the VMs.

  44. Pedro says:

    Any idea how to fix this?

    Can’t locate object method “simple_request” via package “RPC::XML::Client::new: Unable to get RPC::XML::Parser object” (perhaps you forgot to load “RPC::XML::Client::new: Unable to get RPC::XML::Parser object”?) at /tmp/par-root/cache-2b8a1684f926aafa15f592120acb24c2765dc039/inc/lib/Xen/API.pm line 144.

    I manually installed RPC::XML and even added it to API.pm and I still get that error. I tried on CentOS, FreeBSD, and Debian.

  45. Muhammad Farooq says:

    Dear Randy,

    My intention is not to migrate VM from one Xenserver to another but do change its SR location to another SR. I am currently running Xenserver 5.6 . That provides feature to migrate VMs within pool, but no ‘destination-sr-uuid’ argument to change VM SR. My questions regarding your script are following.
    Does this script works on Xenserver 5.6?
    if i provide same source and destination arguments except destination SR-UUID, should it work or not?

    Thanks in advance.

    1. Randy says:

      Yes, it should work!

  46. Scott says:

    I’m with Pedro. (same error)

    Using Xenserver 6.5.0.

    I used yum --enablerepo=base --disablerepo=citrix install glibc.i686 to install glib.c

    And tried yum --enablerepo=base --disablerepo=citrix install perl to reinstall perl

  47. Muhammad Farooq says:

    @Randy,

    It really worked out but i found the same VM on both source and destination host.It seems that it just copied it, and kept original its source Server.

  48. Jimmy says:

    Hi Randy!

    I have the same problems with simple_request mentioned above:

    Can’t locate object method “simple_request” via package “RPC::XML::Client::new: Unable to get RPC::XML::Parser object” (perhaps you forgot to load “RPC::XML::Client::new: Unable to get RPC::XML::Parser object”?) at lib/Xen/API.pm line 144.

    This happen on a xenserver 6.5

    Any idea?

  49. Randy says:

    Please download latest version 1.0.2. As of today, MigrateVM 1.0.2 has been tested and works fine on XenServer 5.6 through 6.5.

  50. Sven B. says:

    Thanks for the great script.
    Just a note that should be added to the documentation: The transfer is unencrypted and if port 80 is blocked (f.e. with system-config-securitylevel-tui) the script doesn’t work.

    1. Randy says:

      Good idea. I will also look into adding SSL capability, as I originally designed it for local transfers and realize others might be transferring over public networks.

  51. Pab says:

    Tanks Randy!!! Great script!

  52. Ben says:

    Thanks for this awesome script, unfortunately I am getting the following error. Management IP’s are being used and the script starts but fails on this error when run from either machine. Any ideas?

    Destination SR on vp*****03.e***.com (blank for default):
    Connecting to source host
    Connecting to destination host and Starting transfer
    Can’t use an undefined value as an ARRAY reference at /tmp/par-root/cache-1ef67fd02ac4e48d37c75f30223c07ddbb73f4d2/inc/lib/Xen/API.pm line 108.

    1. Randy says:

      That error is almost always an authentication problem (password wrong, ect) or connectivity problem. Please double check your root passwords and make sure you can run commands using the same password via XE as a sure-fire test. Also make sure port 80 is not being blocked since the connection goes over http not https.

    2. Randy says:

      Also make sure you have a default SR defined on the target machine. Otherwise provide the specific SR UUID.

  53. Ed says:

    Very useful script, turned into a real win dealing with a pair of servers in another city, with insufficient local disk space to use the snapshot/export method. Most appreciated.

    Query: despite being connected together via 100mbs ether, speeds seemed to top out about 10mbs (so moving a 500gig host took a pretty fair chunk of down time). Any ideas why it used so little of the avail bandwidth? CPU loads also didn’t look too distressed, so my hunch was just limitations of either the script or the APIs its using.

    1. Randy says:

      The issue is most likely either XenServer itself (in the case of busy storage) or high RTT / Packet loss on your link. With only a 100Mbps connection the burstiness of the transfer will induce light packet loss, and the TCP window and thus transfer speed will shrink to compensate. You might try tuning the TCP windows via sysctl, but ideally you should be on a minimum of 1Gbps between servers for best speeds. Even on a 1Gbps link on a local network, about 250-300mbps is what I’m used to seeing.

  54. Barry says:

    Hi Randy,

    Thanks for the great script. Any idea why I’m getting the following message after starting transfer.

    Can’t call method “Xen::API::task::get_record” on an undefined value at /tmp/par-root/cache-768103c6bf7f6a2923d1a1ce2bed3f3daff01c76/inc/lib/Xen/API.pm

    The script has worked fine previously

    Cheers

  55. Michael says:

    Barry that is because you need to shutdown the source vm before migrating.

    Thanks for this great script, itÂīs a real lifesaver 🙂

    Michael

  56. Michael says:

    I have seen some heavy performance issues, transfer speed is somewhat between 5 MBit/s and does not go above 48 MBit/s, both machines are on a 1GBit LAN and transferring something else with scp goes to 500-600MBit/s .
    Seems that there is a bottleneck somewhere.

    1. Michael says:

      I reply to myself because I found a very easy solution for migrating VMs to another server that is not in the pool.

      make sure you are on the SOURCE Xenserver (made me mad after a few hours recognizing that I was on the destination host…) and that the VM is running.

      issue the following command:

      xe vm-migrate remote-master= remote-username= remote-password= vm= –live –force

      instead of vm parameter you can specify the uuid of the VM with the uuid= parameter. However, the vm parameter is CaSe SenSitive. names with space need to be set like this ‘name with space ‘

      I was able to migrate a VM from 6.2 to 6.5 Host.

      1. Michael says:

        ok, square brackets donÂīt work here in comments… so the command again :

        xe vm-migrate remote-master=DESTINATIONIPADDRESS remote-username=xxxx remote-password=xxxxx vm=xxxxx –live –force

      2. Randy says:

        I think this would only be possible on 6.2 or higher am I right?

    2. Randy says:

      You sure you’re not mixing bytes and bits? The tool reports Kbytes per sec so I’m guessing you’re actually seeing 40-400mbit/sec which is what I’m used to seeing over gbit lan (depending on host/destination load). On a busy source or destination server it can get slower. I also think there’s gzip compression internally on the hosts so that also affects network throughput.

  57. Michael says:

    No I did not mixing, and yes it is probably only >=6.2 (canÂīt test as i have no older one) Gzip could be a reason, yeah.
    I really believed that this would work only inside a pool, but… never learned enough.

  58. Michael says:

    Thanks for the tool, it looks really useful! Similar to jwoods05 I’ve had an export seem to stall at 23.9%, but I can’t see it in xe task-list on either the source or the destination. Is there another way of checking progress? It’s been running for 3 days over a slow link and I’m starting to get concerned!

  59. Syed says:

    I’m unable to pass parameters. I’ve tried
    ./migratevm -sh 10.11.12.13 -su root -sp password -sv af9c1e1a-347f-23b1-af9e-ff7ses182ba3 -dh 10.11.12.14 -du root -dp password -ds fa352121-dda7-0d0b-5dc5-7be71234ba0c

    but it always returns error. Am I doing something wrong? I need to run the script with parameters instead of interacting from the shell.

    Thanks,

    Syed

  60. […] āļ–āđ‰āļēāđ€āļāļīāļ” error  ‘bad ELF’ āļšāļ™āļĢāļ°āļšāļšāđāļšāļšÂ 64 āļšāļīāļ•Â Â āđƒāļŦāđ‰āļ•āļīāļ”āļ•āļąāđ‰āļ‡Â Â glibc āđāļšāļš 32 āļšāļīāļ• āļ•āļąāļ§āļ­āļĒāđˆāļēāļ‡ :http://djlab.com/2013/01/migrate-a-xenserver-vm-without-a-pool-or-shared-storage/ […]

  61. Ian Ward says:

    Thank you Randy,

    I have been trying to replace a Xenserver and copying a 1.2 Terabyte Host using export / import with the current network was not possible due to a small maintenance window , your script will get this done in about 10 hours.

    Regards, Ian

  62. Anand Gupta says:

    Hi,

    Thanks for the wonderful script.

    Until now I was using the below command to migrate vms

    xe vm-migrate remote-master=DESTINATIONIP remote-username=ROOT remote-password=PASSWORD vm=xxxxx –live –force

    However lately the above has started to fail, with VDI failure command. Having tried everything I used your script, and the VM migrated without issues. It did get stuck in between were the transfer was doing nothing for few seconds, but it did recover. Thanks again.

    Now is there a way to do live migration using this script ?

    Thanks

  63. xavier says:

    Hi Randy,
    just to say Thank you for this script that saved my week 🙂

    regards

    Xavier

  64. Robert says:

    Question for Randy or anyone else who might see this.

    I have successfully moved one VM using your script here. I love it. Unfortunately that 1 is of the 3 I have attempted to move. I’m using the same inputs I used with the successful transfer other than the VM name (and I’ve attempted UUID) but I keep getting a failure with no error:
    >>…
    >>Destination SR on localhost (blank for default):
    >>Connecting to source host
    >>Connecting to destination host and Starting transfer
    >>[root@HC-XEN11 migratevm-1.0.2]#
    It takes 1o to 15 seconds to drop me back at the prompt.
    If I go and look at xensource.log and follow the process, it seems like it stops at:
    R:767fc6a496aa|import] Caught exception during import: SR_BACKEND_FAILURE: [ non-zero exit;
    Unfortunately the traceback maxes the character count on the line.
    After this ,it starts cleanup/rollback process: R:767fc6a496aa|import] Cleaning up after import failure: SR_BACKEND_FAILURE: [ non-zero exit;

    Can you point me in the direction of a solution, or maybe somewhere where I can find more specific information about why the process is failing?

  65. Alessandro W Baule says:

    Is possible turn on the exported vm in your new host?For example, the principal host is down, then is only turn on the bkp in the vm exported in the new host?

  66. Dan Mueller says:

    This is a great tool, I love it on XenServer 6.2 and 6.5 – Does anyone have this working on XenServer 7.0 yet?

  67. Mirjavid Mirzayev says:

    To get migratevm to run on XenServer 7.0 id did the following:

    Download:
    ftp://195.220.108.108/linux/centos/7.2.1511/os/x86_64/Packages/nss-softokn-freebl-3.16.2.3-13.el7_1.i686.rpm
    ftp://rpmfind.net/linux/centos/7.2.1511/updates/x86_64/Packages/glibc-2.17-106.el7_2.4.i686.rpm

    Commands:
    rpm -ihv nss-softokn-freebl-3.16.2.3-13.el7_1.i686.rpm
    rpm -ihv glibc-2.17-106.el7_2.4.i686.rpm –nodeps

    Use at your own risk.
    I tested this on a clean XenServer 7.0 without any updates or supplemental packs.

    1. Dan Mueller says:

      I tried to install these RPMs on a clean system without success.

      rpm -ihv nss-softokn-freebl-3.16.2.3-13.el7_1.i686.rpm
      error: Failed dependencies:
      libc.so.6 is needed by nss-softokn-freebl-3.16.2.3-13.el7_1.i686
      libc.so.6(GLIBC_2.0) is needed by nss-softokn-freebl-3.16.2.3-13.el7_1.i 686
      libc.so.6(GLIBC_2.1) is needed by nss-softokn-freebl-3.16.2.3-13.el7_1.i 686
      libc.so.6(GLIBC_2.1.3) is needed by nss-softokn-freebl-3.16.2.3-13.el7_1 .i686
      libc.so.6(GLIBC_2.3) is needed by nss-softokn-freebl-3.16.2.3-13.el7_1.i 686
      libc.so.6(GLIBC_2.3.4) is needed by nss-softokn-freebl-3.16.2.3-13.el7_1 .i686
      libc.so.6(GLIBC_2.4) is needed by nss-softokn-freebl-3.16.2.3-13.el7_1.i 686
      libdl.so.2 is needed by nss-softokn-freebl-3.16.2.3-13.el7_1.i686
      libdl.so.2(GLIBC_2.0) is needed by nss-softokn-freebl-3.16.2.3-13.el7_1. i686
      libdl.so.2(GLIBC_2.1) is needed by nss-softokn-freebl-3.16.2.3-13.el7_1. i686
      [root@HQ1XS036 ~]# rpm -ihv glibc-2.17-106.el7_2.4.i686.rpm –nodeps
      error: open of –nodeps failed: No such file or directory
      [root@HQ1XS036 ~]# rpm -ihv glibc-2.17-106.el7_2.4.i686.rpm
      error: Failed dependencies:
      libfreebl3.so is needed by glibc-2.17-106.el7_2.4.i686
      libfreebl3.so(NSSRAWHASH_3.12.3) is needed by glibc-2.17-106.el7_2.4.i68 6

      rpm -ihv nss-softokn-freebl-3.16.2.3-13.el7_1.i686.rpm
      warning: nss-softokn-freebl-3.16.2.3-13.el7_1.i686.rpm: Header V3 RSA/SHA256 Sig nature, key ID f4a80eb5: NOKEY
      error: Failed dependencies:
      libc.so.6 is needed by nss-softokn-freebl-3.16.2.3-13.el7_1.i686
      libc.so.6(GLIBC_2.0) is needed by nss-softokn-freebl-3.16.2.3-13.el7_1.i 686
      libc.so.6(GLIBC_2.1) is needed by nss-softokn-freebl-3.16.2.3-13.el7_1.i 686
      libc.so.6(GLIBC_2.1.3) is needed by nss-softokn-freebl-3.16.2.3-13.el7_1 .i686
      libc.so.6(GLIBC_2.3) is needed by nss-softokn-freebl-3.16.2.3-13.el7_1.i 686
      libc.so.6(GLIBC_2.3.4) is needed by nss-softokn-freebl-3.16.2.3-13.el7_1 .i686
      libc.so.6(GLIBC_2.4) is needed by nss-softokn-freebl-3.16.2.3-13.el7_1.i 686
      libdl.so.2 is needed by nss-softokn-freebl-3.16.2.3-13.el7_1.i686
      libdl.so.2(GLIBC_2.0) is needed by nss-softokn-freebl-3.16.2.3-13.el7_1. i686
      libdl.so.2(GLIBC_2.1) is needed by nss-softokn-freebl-3.16.2.3-13.el7_1. i686

      1. Mirjavid Mirzayev says:

        Can you please try to install the packages in this order:

        rpm -ihv glibc-2.17-106.el7_2.4.i686.rpm –nodeps
        rpm -ihv nss-softokn-freebl-3.16.2.3-13.el7_1.i686.rpm

        I think i posted the commands in wrong order.

        1. Chris says:

          I have installed the RPMs in the corrected order (glibc first, then nss-softokn-freebl) with no problem. Note that the nodeps option is prefixed by two hyphen. This website appears to have converted the two hypens in Mirjavid’s post to an en-dash.

          After the RPM installs, I can run migratevm-1.0.2 on XenServer 7.0 without any problems.

  68. Tim Bourne says:

    This worked great for us and saved an amazing amount of time. Thanks!

  69. Mark McDonald says:

    Hi Randy, do you happen to have a 64-bit compiled version of your script for Xenserver 7? I can’t install anything else on the production servers here.

  70. JÞrgen says:

    The link for the additional rpms on XS7.1 is broken. Is there an offical download site for getting the right rpms?

  71. Corey Orman says:

    I get a connection refused error when I try to download the script. What am I doing wrong?

  72. husain says:

    hello

    it look like centos 5 which xenserver built on is ended so or links are dead, any one have a repository so we can download the packages

    kind regards

  73. Walde says:

    I get an Error on XenServer 6.5:
    yum install glibc.i686 (with repo Vault Centos 5)

    yum install glibc.i686
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
    Setting up Install Process
    Resolving Dependencies
    –> Running transaction check
    —> Package glibc.i686 0:2.5-107.el5_9.5 set to be updated
    –> Processing Dependency: glibc-common = 2.5-107.el5_9.5 for package: glibc
    –> Finished Dependency Resolution
    glibc-2.5-107.el5_9.5.i686 from C5.9-updates has depsolving problems
    –> Missing Dependency: glibc-common = 2.5-107.el5_9.5 is needed by package glibc-2.5-107.el5_9.5.i686 (C5.9-updates)
    Error: Missing Dependency: glibc-common = 2.5-107.el5_9.5 is needed by package glibc-2.5-107.el5_9.5.i686 (C5.9-updates)
    You could try using –skip-broken to work around the problem
    You could try running: package-cleanup –problems
    package-cleanup –dupes
    rpm -Va –nofiles –nodigest

    Please Help !!! Thanks Dirk

  74. Walde says:

    I have found a Workaround:
    yum -y downgrade glibc glibc-common
    yum -y install glibc.i686

    Now all ok …. I Hope

  75. Steve says:

    Hey Randy
    Have been using your script for a while now, works great with Xen, but it doesnt connect with XCP, any chance you’re still looking into this wonderful script? Would be great to migrate all our old Xen VMs over to XCP
    Cheers!

  76. NicolasS says:

    Hy Randy

    On a fresh install of Xen 7.5 I’v got this. Do you have any idea please. Thanks

    Can’t locate RPC/XML.pm in @INC (@INC contains: ./lib /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at lib/Xen/API.pm line 2.
    BEGIN failed–compilation aborted at lib/Xen/API.pm line 2.
    Compilation failed in require at ./migratevm.pl line 4.
    BEGIN failed–compilation aborted at ./migratevm.pl line 4.