Xenmigrate.py export and import example

    Table of contents
    No headers

    NOTICE: Xenmigrate does not currently support NFS stored VMs.  This example is for Logical Volume stored VMs.

    If you've used the migrate program to export to a raw file (don't confuse an "export" using the xenmigrate program with an "export" from Xen Center), you'll then need to use the import function of the program to turn that raw file into a logical volume that open source xen can then use as its disk.  Here's a run through of an export and import on my system...

    First we export from the source machine.  Adjust the export and virtual name location accordingly.  In my case, I mounted an NFS share under /mnt and have a virtual with a name-label of "nessus01":

    [root@xen01 xentool]# python xenmigrate.py -x /mnt/nessus01 nessus01
    xenmigrate 0.6.2 -- 2009.01.05

    vm name-label     : nessus01
    vm uuid           : 75177e74-92de-1efc-be47-d7047ad62b69
    vm disk uuid      : e236d60f-ad35-4887-ad0a-c187d8093a07
    vm disk partid    : xvda
    vm disk uuid      : dae12c56-6702-4e56-bb15-530aa43d1019
    vm disk partid    : xvdd
    export dev       : /dev/VG_XenStorage-8aa40725-3429-83d5-a560-e5c18dd19efe/LV-e236d60f-ad35-4887-ad0a-c187d8093a07
    to raw file      : /root/mnt/nessus01_xvda_8.00

    Activating Volume:
        Using logical volume(s) on command line
        Activating logical volume "LV-e236d60f-ad35-4887-ad0a-c187d8093a07"
        Found volume group "VG_XenStorage-8aa40725-3429-83d5-a560-e5c18dd19efe"
        Creating VG_XenStorage--8aa40725--3429--83d5--a560--e5c18dd19efe-LV--e236d60f--ad35--4887--ad0a--c187d8093a07
        Loading VG_XenStorage--8aa40725--3429--83d5--a560--e5c18dd19efe-LV--e236d60f--ad35--4887--ad0a--c187d8093a07 table
        Resuming VG_XenStorage--8aa40725--3429--83d5--a560--e5c18dd19efe-LV--e236d60f--ad35--4887--ad0a--c187d8093a07 (252:18)

    RW notification every: 1.0GB
    Exporting: 1.0GBrw 2.0GBrw 3.0GBrw 4.0GBrw 5.0GBrw 6.0GBrw 7.0GBrw 8.0GBrw
    Successful export

    Deactivating Volume:
        Using logical volume(s) on command line
        Deactivating logical volume "LV-e236d60f-ad35-4887-ad0a-c187d8093a07"
        Found volume group "VG_XenStorage-8aa40725-3429-83d5-a560-e5c18dd19efe"
        Removing VG_XenStorage--8aa40725--3429--83d5--a560--e5c18dd19efe-LV--e236d60f--ad35--4887--ad0a--c187d8093a07 (252:18)
        Found volume group "VG_XenStorage-8aa40725-3429-83d5-a560-e5c18dd19efe"
    You many need to restart your VM:
    xe vm-startup -u root uuid=75177e74-92de-1efc-be47-d7047ad62b69

    Then we import on the destination open source xen machine.  Change the mnt locaiton and the Volume Group accordingly.  In my case I had a ./mnt mounted to my NFS share and a Volume Group named VolGroup00.  You need to be using LVM storage on open source Xen (the recommended way) for this to work:

    [root@xen04 xentool]# python xenmigrate.py -i mnt/nessus01_xvda_8.00 VolGroup00
    xenmigrate 0.6.2 -- 2009.01.05

    import raw file   : mnt/nessus01_xvda_8.00
    to lv             : nessus01
    in vg             : VolGroup00
    lv size           : 8.00GB
    xen config partid : xvda

    Creating Logical Volume:
        Setting logging type to disk
        Finding volume group "VolGroup00"
        Archiving volume group "VolGroup00" metadata (seqno 1511).
        Creating logical volume nessus01
        Creating volume group backup "/etc/lvm/backup/VolGroup00" (seqno 1512).
        Found volume group "VolGroup00"
        Creating VolGroup00-nessus01
        Loading VolGroup00-nessus01 table
        Resuming VolGroup00-nessus01 (253:18)
        Clearing start of logical volume "nessus01"
        Creating volume group backup "/etc/lvm/backup/VolGroup00" (seqno 1512).

    RW notification every: 1.0GB
    Importing: 1.0GBrw 2.0GBrw 3.0GBrw 4.0GBrw 5.0GBrw 6.0GBrw 7.0GBrw 8.0GBrw
    Successful import

    Then you need to add the appropriate information to your virtual's configuration file:

    disk       = ['phy:/dev/VolGroup00/nessus01,xvda,w']
    root = '/dev/xvda1 ro'

     

    Tag page (Edit tags)
    • No tags
    Viewing 15 of 16 comments: view all
    ERROR: unknown convert format is currently its way of saying "directory not found". I'm off to try to fix that.
    Posted 03:04, 25 Apr 2009
    And the actual problem was caused by not having a trailing / at the end of the ref dir name. I've fixed that (for linux at least, if you run this in windows it will probably choke) in the latest version. There are some serious flaws in the ref2raw function that need to be fixed, but it should hobble through it right now.
    Posted 03:36, 25 Apr 2009
    Hi pace,

    I installed Citrix Xen to create one virtual debian linux just for sandbox purposes. Now I'd like to move this virtual debian linux to Amazon E2C, so I think I should use your xenmigrate.py. I'm not so technical in linux and I don't know what to do after xenmigrate.py -x
    I have the file but I cannot mount with "mount -o loop -t ext3 exportfile /newext3vm"

    Could you help me?

    Thanks

    David edited 13:54, 28 Apr 2009
    Posted 10:07, 28 Apr 2009
    Any possibility not using LVM while importing ? I have setup XEN with raw devices and getting error :

    Traceback (most recent call last):
    File "xenmigrate.py", line 453, in ?
    lvpartid=importname.split('_')[-2]
    Posted 11:14, 19 Jun 2009
    I'm not quite following, bambid. You're trying to export a VM from Citrix and then not import it into an LVM, but just use the raw file? If this is the case, the export you've created is a raw file. If not, please explain more.


    pace
    Posted 19:43, 20 Jun 2009
    atolf19 -- sorry for the months later answer here. I've configured notifications so I should actually know when people have posted from now on.

    You should use the Amazon EC2 tools to create your bundle. The actual program is ec2-bundle-vol. You can find the docs for that specifically here: http://docs.amazonwebservices.com/AmazonEC2/dg/2006-10-01/CLTRG-ami-bundle-vol.html


    pace
    Posted 19:49, 20 Jun 2009
    I have a xva created by citrix'x hardware to vritual system converter.
    The format of the directory is ova.xm and hda/
    hda/ contains chunk-000000##.gz.
    each chunk is 1GB(1000000000) in size(pre gzip)

    I had to hack xenmigrate to strip the chunk- and to use the filenames from the directory not a generated one.

    I will soon find out how well this has all worked
    Posted 18:26, 20 Nov 2009
    We'll need to add the ungzip to the program -- that is easy enough, I just need to get my hands on one of the system converter images to test with. Can you send me one if I give you some FTP details?
    Posted 18:47, 23 Nov 2009
    I have successfully converted a microsoft virtual hard disk (vhd) format virtual machine to open source xen using citrix xenconvert and this tool.
    I first used citrix xenconvert to convert the vhd file to xen virtual appliance format. This created an ova.xml and hda/ directory with chunk-000000##.gz files.
    I then renamed all the chunk- files to not have chunk in front of them, and added an extra 0 at the beginning and then gunzipped them all.
    Next I ran
    python ./Xenmigrate.py -c ./hda/ new-server.img
    which created a file called new-server.img
    Finally i added this into a xen configuration file as
    disk = [ 'file:/usr/xen/tfs_2010/tfs.img,ioemu:hda,w']
    and started the virtual machine

    I guess all the renaming and gunzipping of files could be done within the python script, but my python scripting abilities arent up to much so i did it a manual way
    Posted 20:11, 13 Jan 2010
    When I tried this method, the script completed properly but none of my VMs would boot.

    After scratching my head for some time (and almost going back to Citrix) I figured I'd just do it the old skool way:

    Boot into Clonezilla on the VM in XenServer, grab the drive image, create a new VM on Xen with the right size drive, boot into Clonezilla and restore the drive.

    Worked a charm for me, so it may be useful for others having trouble here (or others too thick to figure it out like me!).
    Posted 12:45, 20 Aug 2010
    Hello there, I am trying to convert a XVA file into an img file. I run:
    python xenmigrate.py -convert=Ref\:7/ server.img

    and all I get is:
    "xenmigrate 0.7.2 -- 2010.01.01
    (c)2010 Jolokia Networks and Mark Pace -- jolokianetworks.com

    ERROR: convert source directory or file does not exist"

    Any tips on what I should try?
    Posted 19:12, 30 Aug 2011
    I've been able to convert the XVA but I can't do nothing with it ! I can't mount It and I can't convert to LVM ... I'm trying to port Vyatta XVA image to Xen 4.1
    Posted 19:52, 13 Sep 2011
    kenjiro: There is a diff in the comments on the xenmigrate.py page that may help you.

    scramatte: Assuming you end up with an image file you will then need to use that as a file source for either an LVM partition or as just a file source for your vm. You can use the xenmigrate script to load an image into an lvm (--import) or you and just use the file you created with xen 4.1. If you need more help, email me directly. My email address is my last name pace @ our domain name. edited 20:08, 13 Sep 2011
    Posted 20:06, 13 Sep 2011
    There is an error in the script. The following line:

    line 296
    numfiles=len([dirobj for dirobj in os.listdir(refdir) if os.path.isfile(dirobj)])

    only works if the workingdirectory is the ref directory itself. It should read:

    numfiles=len([dirobj for dirobj in os.listdir(refdir) if os.path.isfile(os.path.normpath(refdir) + '/' + dirobj))])

    That way it does not matter in what directory the script is started and should work in all environments
    Posted 17:36, 12 Nov 2011
    Sorry, I misplaced the braces.

    numfiles=len([dirobj for dirobj in os.listdir(refdir) if os.path.isfile(os.path.normpath(refdir + '/' + dirobj))])
    Posted 17:37, 12 Nov 2011
    Viewing 15 of 16 comments: view all
    You must login to post a comment.