Home VM Migration How to Easily Migrate VM from Xen to KVM in 3 Ways?

How to Easily Migrate VM from Xen to KVM in 3 Ways?

2022-11-16 | Nick Zhao

Table of contents
  • Xen VS KVM
  • Migrate VM from Xen to KVM with virt-v2v
  • Convert Xen Image for KVM environment
  • Easily move Xen to KVM in heterogeneous environment
  • Sum Up

Virtualization solution varies and companies can change solutions for better performance or have multiple virtualization solutions to utilize all of their advantages.

When changing or adding new hardware in IT environment, you need to test the compatibility and this is also needed in VM migration. Technically, virtual machine is the folder on the host but when it is moved to new environment, the content in the folder might be recognized by the new host.

This folder contains data like VM configuration, applications, etc. Most of data are saved in virtual disk, which is like the hard disk of physical machine. When migating VM, IT administrator could attach the virtual disk to an existing VM , create a new VM with the virtual disk or move the entire VM but because of different technologies used in different environments, virtual disks often needs to be converted. This is not only needed in heterogeneous virtual environment, but also in homogeneous environment. For example, different versions of ESXi host could be incompatible for an ESXi VM.

Xen VS KVM

Both Xen and KVM are open-source, type-1 hypervisors but they are very different from each other.

Xen hypervisor was born in a research project at the University of Cambridge. Later, the company is acquired by Citrix and the hypervisor is renamed Citrix Hypervisor. XCP-ng, Xen Cloud Platform -next generation also uses Xen hypervisor in its solution.

KVM, Kernel-based Virtual Machine, is developed by Qumranet and acquired by Red Hat later. There are virtualization solutions which use KVM hypervisor like Red Hat Virtualization, oVirt, OpenStack, etc.

As is mentioned above, virtual disk is important during VM migration and is a file in the folder, representing the hard drive. The common virtuak disk formats in Xen environment are vhd and xva, while it is raw and qcow2 that are often used as the virtual disk format in KVM envrionment so virtual disk conversion is needed during migration.

Migrate VM from Xen to KVM with virt-v2v

Virt-v2v command can help convert the entire VM from foreign hypervisor to KVM but you should subscribe to the virt-v2v channel on the Red Hat Customer Portal.

Then you can install virt-v2v with the command:

yum install virt-v2v

Copy the xml file (VM configuration) and virtual disk to local machine:

# virt-v2v-copy-to-local -ic source_server vm_name

Convert the image:

# virt-v2v -i libvirtxml vm_name.xml -o local -os vms/ -of qcow2

-of: convert virtual disk to qcow2 format

-os: directory

vm_name.xml: the exported xml file in the last step

Then you can import the Xen VM to KVM environment.

Convert Xen Image for KVM environment

Except for moving the entire VM, you can also convert just the virtual disk for the new environment. If you are using vhd virtual disk, you can use qemu-img to convert it.

qemu-img convert -p -f vhd -O qcow2 ./virtual_disk.vhd ./virtual_disk.qcow2

-p: presenting the conversion progress

-f: format of the source image

-O: format of the target image

Easily move Xen to KVM in heterogeneous environment

Genreraly speaking, virtualization vendors often provide the solutions to help users move VM from foreign hypervisor to their platforms but the process might be complicated and not good for later management.

Vinchin Backup & Recovery can help you easily protect and manage heterogeneous virtual environment. You can add virtualization platforms like XenServer, XCP-ng, Red Hat Virtualization, oVirt, OpenStack, Oracle Linux KVM, etc. (Native KVM is not supported for now), to the system to make backup and perform V2V migration

Vinchin Backup & Recovery

Vinchin Backup & Recovery supports agentless backup so you just need to add hosts to the system to make backup for any VMs on the hosts.

With the VM backup, you can easily move VM between different hypervisors. For example, if you would like to move VM from XenServer to Red Hat Virtualization. You just need to add both hosts to the system, select a XenServer VM backup, and recover it on the target host. The whole process will be very easy with a user-friendly web console.

Vinchin Backup & Recovery has helped thousands of companies protect and manage virtual environment. You can also start to use this powerful system with a 60-day full-featured free trial. Just click the button to get the installation package.

Sum Up

There are a lot of virtualization solutions in the world and companies can select one or more solutions for IT environment. No matter you would like to abandon old hosts or manage heterogeneous virtual environment, the technique of VM migration is worth learning.

In this post, you can learn the differences of virtual disks between Xen VM and KVM VM and the way to move VM from Xen to KVM with virt-v2v command and qemu-img command.

You can also use Vinchin Backup & recovery to perform V2V migration via an easier way. Don’t miss the free trial.

Share on:

Categories: VM Migration