Nathan Stratton’s Homepage

Converting Citrix .xva to Xen.org .img

by on Jun.06, 2009, under Software

Xen is one of the coolest virtualization technologies out there. It comes in may flavors, the two largest being the bleeding edge xen.org open source project and the commercial (Citrix) version. There are things I love about the commercial version, but they lost me only supporting windows in their XenCenter administration interface.

The file formats of the commercial and open source Xenare totall different. The open source is a standard image file, you can mount it, fdisk it, whatever you would like. The Citrix Xen Virtual Appliance .XVA file is quite different. It is actually a tar file with ova.xml meta data and directories starting with Ref full of 1M files that make up the drive volumes of the virtual image.

To convert .xva to an xen .img file you first untar the image:

tar -xvf {image}.xva

Then grab this handy utility and run it on your untared data, as an example:

python xenmigrate.py –convert=Ref:3 {image}.img

This will paste all of those files back together, starting at 00000000. Note I have had problems running this script on Centos 5.x.

Be Sociable, Share!
:

11 Comments for this entry

  • JBill

    How can one convert a img file to xva format ?

  • nathan

    Why would anyone want to do that! My guess is that if Citrix wanted to charge for Xen that they would provide some sort of utility for that.

    -Nathan

  • dr

    Hi nathan,

    i get the following error while running the script

    when i run python xenmigrate.py –convert=Ref:3 myimage.img

    it cannot find the source directory and when i fire

    python xenmigrate.py -c xvda image.img
    i get the following error

    convert ref dir : xvda
    to raw file : image.img
    Traceback (most recent call last):
    File “xenmigrate.py”, line 478, in
    reftoraw(opts.convert,args[0],opts.gz)
    File “xenmigrate.py”, line 295, in reftoraw
    numfiles=int(refdirlist[-2])
    ValueError: invalid literal for int() with base 10: ‘chunk-000000002.gz’

    Please help…

  • admin

    Make sure you are root, and add the trailing / after Ref:3, I have tested on Fedora 10 and 11.

    -Nathan

  • Mark Pace

    There is a newer version of the xenmigrate program that handles XenServer 5.5 xva files properly. You can get it (and any newer releases that may happen) from its source: http://jolokianetworks.com/Virtualization/Converting_from_Citrix_XenServer_to_Xen_open_source.

    Cheers,
    pace

  • Steven

    After I run xenmigrate it says it completed successfully…

    xenmigrate 0.7.4 — 2011.09.13
    (c)2011 Jolokia Networks and Mark Pace — jolokianetworks.com

    convert ref dir : /mnt/vm_images/xenserver02-vm-2011-09-09/Ref:78/
    to raw file : testconvert.img
    last file : 1
    disk image size : 0 GB

    RW notification every: 1.0GB
    Converting:
    Successful convert

    But the raw file it produces is only about 1M…. It should be around 20G. Has anyone every seen this behavior before?

    Thanks!

  • zinkuz

    Hi admin,

    I get the same message like “dr” and / after Ref:3 didn, helped. It works with imeges less than 1G. When I took newer version of XenMigrate.py message disapeared but
    it stops after 1st chunk. Any suggestions?

  • Bret Miller

    I really needed a working version of this last week, so I created my own. This one works on Windows with .xva snapshots created by XenServer 5.6 SP2.

    http://pastebin.com/MK5Da8CB

  • charles81

    Just taking a wild guess here but are the 1mb files to allow snapshots?

    I know that if you have thin-provisioned virtual disks then they pretty much do this by simply skipping any 1mb blocks/files that have no data in them. So you’ll have something like 000000, 000001, 000002, 000005, 000006 and presumably the 3-4 files are simply empty so not included. Doesn’t save as much space as simply using compression but likely takes some pressure off the CPU and slows down some of the write speed if it needs to create the file first.

    It wouldn’t surprise me that if you looked into snapshots that you’d pretty much find a heap of 1mb files that match up with the ones changed.

    *meh* I could be way off the mark as the virtual disk in XenServer is likely far different from the XVA format.

  • T

    Handy dandy script I cooked up to handle everything from snapshotting a live VM on xenserver to mounting the partitions as /dev/mapper/loopXpY It uses a newer version of xenmigrate.py from Jolokia Networks, edited by bret.miller (dl link to pastebin on the Jolokia page, patch in my note is 0.7.4->editedversion). This lets you quickly run against a Citrix VM, then do something like dd if=/dev/mapper/loopXpY bs=4096k | ssh some.other.xen ‘dd of=/dev/mapper/NewXenLVM’

    http://bit.ly/NJOkLw

    Sharing back since I got this far from this blog post. Kudos to Mark for the py!

  • zinkuz

    Hi, Bret Miller

    The script you’ve made works fine with Windows .xva files
    but when I convert Linux VM it does not boots. Any ideas.

Leave a Reply

ERROR: si-captcha.php plugin says GD image support not detected in PHP!

Contact your web host and ask them why GD image support is not enabled for PHP.

ERROR: si-captcha.php plugin says imagepng function not detected in PHP!

Contact your web host and ask them why imagepng function is not enabled for PHP.

Looking for something?

Use the form below to search the site:

Cool Links!

A few highly recommended links...