Adjective: Comparative form of nerdy: more nerdy.

XenServer to KVM migration.

I had to migrate a Windows VDS from an extremely old node running XenServer 5.5 to a brand new node running KVM on CentOS 6.4. This worked for me, but your mileage may vary..

Run a list to find out the uuid for the VDS

xe vm-list

It will be something like this;

uuid ( RO)           : 24ebdacc-bd8e-637a-7be1-88c08f39059e
name-label ( RW): example
power-state ( RO): running

To create a snapshot of the running VM run;

xe vm-snapshot uuid=24ebdacc-bd8e-637a-7be1-88c08f39059e new-name-label=snapshotname

This will return the uuid of the snapshot, we now need to transform the snapshot into a VM so we can save it as a file;

xe template-param-set is-a-template=false ha-always-run=false uuid=522e2553-8262-bbce-7199-fd178691d9d8

If you don’t have enough space on the mounted file system, you might need to do what I did and create a new logical volume (slightly bigger than the current image size) and mount it.

lvcreate -L30G -n example vg

Where vg is the name of your volume group.

Then make the filesystem type and mount it;

mkfs -t ext3 /dev/vg/example

mkdir /mnt/example

mount /dev/vg/example /mnt/example

Now we will save the snapshot to a file.

xe vm-export vm=522e2553-8262-bbce-7199-fd178691d9d8 filename=/mnt/example/example.xva

Then you just need to copy the image to the KVM node, via your method of choice. I would recommend creating a lv on the node with at least 3 times the size of the current disk image size (for working space).

Once you have got it onto the new node, you need to convert the xva file to a image file.

To do this you can use a super awesome python script.

You need to untar the xva file before you can convert it.

tar -xvf example.xva

cd into the created directory, you will then see a folder that looks like;


Get the python script (Requires Python 2.4);


Then run the following to convert the extracted .xva to a .img

python -c Ref\:39/ example.img

Create a loopback device for the image;

losetup /dev/loop0 /path/to/example.img

Create the lv for the VDS

lvcreate -L21G -n example vg

dd the image to the lv

dd if=/dev/loop0 of=/dev/vg/example

Run virt-install

virt-install --name=example --cpuset=auto --ram=1024 --network bridge=br123 --disk=/dev/vg/example --vnc --vnclisten= --noautoconsole --cdrom=/win2k8.iso

Check which port VNC is running on

netstat -an | grep 59

Then connect to the server IP/Port with your VNC client to configure the network on the VDS.

Once that’s done, shutdown the VDS so you can disable VNC by doing;

virsh edit example

Remove the following lines and then save/exit.

<graphics type='vnc' port='-1' autoport='yes' listen=''>
     <listen type='address' address=''/>

Start the VDS

virsh start example

Once it’s all up and running, you just need to remove the working space you made with lvremove (after unmounting it).



Leave a Reply

Your email address will not be published. Required fields are marked *