Profile photo of Steve White

About Steve White

Software Engineer

Xen Virtual Machine Conversion HVM/PV

VMware to Xen Virtualised Image Conversion

We recently converted a RHEL 6.0 virtual image from VMware to Xen (Xen Cloud Platform 1.6) by using the XenServer Conversion Manager. After installing the XenTools on to the image XenCenter still showed them as “not installed”. We registered the VM with the RHN (via rhn_register) and for RH 6.1 updates and upgraded the kernel from vmlinuz-2.6.32-71.40.1.el6.x86_64 to 2.6.32-131.38.1.el6.x86_64 via the following command:

yum update kernel.x86_64

After this and a reboot the tools the Virtualization state appeared as “Optimized (version 6.1 installed)” and we could set the memory ballooning minimum and maximum in the XenCenter “memory” tab.

Hardware Virtualised Machine By Default

We later found out that it was running as a Hardware Virtualised Machine (HVM) instead of Paravirtualised (PV), which is less efficient. Apparently the actual performance difference varies depending on what hardware it’s running on but we wanted to aim for PV. From what I’ve read on various sites and posts I believe that HVM was used because we had converted the image instead of creating a new one from a Xen template.

To validate this from the XenServer console we got the uuid of our image via a “xe vm-list” and checked the HVM-boot-policy to see if it was set to “BIOS order”, e.g:

xe vm-param-get uuid=<VM uuid> param-name=HVM-boot-policy

If it is set to “BIOS order” (or other non-empty string?) then HVM is enabled.

Converting a Xen Virtual Machine from HVM to PV

We couldn’t find any formal documentation about converting VMs to PV but we came across this posting which pointed us in the right direction.

In order to convert the image to use PV:

1. Go in to your Linux VM and save the output from the “mount” command and /boot/grub/menu.1st contents.

2. Take a snapshot of your image in XenCenter to roll back to just in case!

3. From the XenServer console get the VM ‘uuid’ using the command:

xe vm-list

NB: You can list all VM params with: xe vm-param-list uuid=<VM uuid>

4. Set PV mode by running:

xe vm-param-set uuid=<VM uuid> HVM-boot-policy=""

5. Set the PV boot loader:

xe vm-param-set uuid=<VM uuid> PV-bootloader=pygrub

6. Set the kernel and ramdisk params from the grub menu.1st contents saved earlier:

xe vm-param-set uuid=<VM uuid> PV-bootloader-args="--kernel <kernel location> --ramdisk <initrd location>"

e.g.

xe vm-param-set uuid=c66eb11e-75a3-91a5-2f90-9aa3c03ec61b PV-bootloader-args="--kernel /vmlinuz-2.6.32-131.38.1.el6.x86_64 --ramdisk /initramfs-2.6.32-131.38.1.el6.x86_64.img"

7. List the disks in your VM:

xe vm-disk-list uuid=<VM uuid>

8. Get the VDI disk uuid (e.g. for Disk 0 VDI) and then:

xe vdi-param-get uuid=<VDI uuid> param-name=vbd-uuids

9. Get the vbd-uuids value and then set bootable=true:

xe vbd-param-set uuid=<vbd-uuids> bootable=true

10. Set the root device to point to that from the output of the ‘mount’ command from earlier:

xe vm-param-set uuid=<VM uuid> PV-args="root=<root device>"

e.g.

xe vm-param-set uuid=<VM uuid> PV-args="root=/dev/mapper/vg_vmrhel6-lv_root"

11. Reboot/Start the VM.

12. Unfortunately we could not get the framebuffer (/dev/fb0) device to work and so X wouldn’t start, but this wasn’t really an issue in our environment since we were only concerned with console access.

A few days later we came across a handy script in the following link which performs all of the above commands, which is probably much less error prone. Disclaimer – We have not tested this.

Reverting Back to HVM

To revert back to HVM either drop back to your previous Xen snapshot or run the following from the Xen server console:

xe vm-param-set uuid=<vm uuid> HVM-boot-policy="BIOS order"

By the way, Xen snapshots are great! The ability to branch and revert without losing changes is really handy.

– Steve –

Leave a Reply