Converting a Xen Linux virtual machine to KVM

Updated -

The virt-v2v tool converts virtual machines, including their disk images and metadata, from foreign hypervisors for use with Red Hat Enterprise Linux with KVM managed by libvirt, Red Hat Virtualization, and Red Hat OpenStack Platform.

This article provides instructions for converting and importing a Red Hat Enterprise Linux virtual machine from a Xen hypervisor to run on Red Hat Enterprise Linux 7 KVM, Red Hat Enterprise Linux 8 KVM, and Red Hat Enterprise Linux 9 KVM.

For an overview of the virt-v2v tool, supported conversions, and links to other types of virtual machine conversions, see Converting Virtual Machines from Other Hypervisors to KVM with virt-v2v in RHEL 7, RHEL 8, and RHEL 9.

On successful completion of the conversion process, virt-v2v creates a new libvirt domain XML file for the converted VM with the same name as the original VM. The VM can be started using libvirt tools, such as virt-manager or virsh.

Prerequisites

  • Ensure that the virtual machine is stopped prior to running the conversion process.

  • The following minimum system resources must be available:

    • Minimum network speed 1Gbps
    • Disk space: sufficient space to store the VM's disk image, plus 1 GB
    • Sufficient free space in the VM's file system according to the following table:
File system Minimum free space
Root file system 100 MB
/boot 50 MB
Every other mountable file system 10 MB
  • The source VM must have 100 or more free index nodes (inodes). If the VM does not have a sufficient number of free inodes, for example if it uses an XFS file system and contains very many files, the conversion will be very slow or it will fail.

Procedure

Step 1

Install the virt-v2v packages and their dependencies:

# yum install virt-v2v

Step 2

If the virt-v2v conversion server is RHEL 9, you need to enable modern ssh implementations with RHEL 5:

2a. Add the following "Host" stanza to your ~/.ssh/config:

Host xen.example.com
   KexAlgorithms                +diffie-hellman-group14-sha1
   MACs                         +hmac-sha1
   HostKeyAlgorithms            +ssh-rsa
   PubkeyAcceptedKeyTypes           +ssh-rsa
   PubkeyAcceptedAlgorithms         +ssh-rsa

2b. Create a file called $HOME/openssl-sha1.cnf with the following content:

   .include /etc/ssl/openssl.cnf
   [openssl_init]
   alg_section = evp_properties
   [evp_properties]
   rh-allow-sha1-signatures = yes

2c. Export the following variable into the environment of the virt-v2v process:

OPENSSL_CONF=$HOME/openssl-sha1.cn

Step 3

Configure password-less SSH access to the remote Xen host from the virt-v2v conversion server.

# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa): 
# ssh-agent 
SSH_AUTH_SOCK=/tmp/ssh-36jmUA3rn2JS/agent.24318; export SSH_AUTH_SOCK;
SSH_AGENT_PID=24319; export SSH_AGENT_PID;
echo Agent pid 24319;
# SSH_AUTH_SOCK=/tmp/ssh-36jmUA3rn2JS/agent.24318; export SSH_AUTH_SOCK;
# SSH_AGENT_PID=24319; export SSH_AGENT_PID;
# echo Agent pid 24319;
Agent pid 24319
# ssh-add 
Identity added: /root/.ssh/id_rsa (/root/.ssh/id_rsa)

Step 4

Add your SSH public key to the /root/.ssh/authorized_keys file on the Xen host.

# ssh-copy-id root@xen-example-host.com
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@xen-example-host.com's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'root@xen-example-host.com'"
and check to make sure that only the key(s) you wanted were added.

Step 5

Test the SSH configuration:

# ssh root@xen-example-host.com
Last login: Tue Nov  1 14:39:21 2016 from ovpn-123-45.brq.redhat.com

If SSH has been configured successfully, the conversion server logs you in to the Xen host and does not request any password.

Step 6

To convert a Xen Linux virtual machine, use the following command, and replace:
- testguest with the intended name for the converted VM
- $pool with the storage pool that the converted VM should use
- $format with the disk format the converted VM should use, such as qcow2 or raw

# virt-v2v -ic 'xen+ssh://root@xen.example.com' testguest -os $pool -of $format

For a list of virt-v2v parameters, see the virt-v2v man page.

Step 7

Observe the conversion progress. The following example shows the progress of virt-v2v converting a Red Hat Enterprise Linux 5 virtual machine running on a Xen host:

# virt-v2v -ic "xen+ssh://root@xen-sample-host.com" -os default rhel5-para -of raw
[   0.0] Opening the source -i libvirt -ic xen+ssh://root@xen-sample-host. com rhel5-para
[   0.0] Creating an overlay to protect the source from being modified
[   0.0] Opening the overlay
[  69.0] Initializing the target -o libvirt -os default
[  69.0] Inspecting the overlay
[  80.0] Checking for sufficient free disk space in the guest
[  80.0] Estimating space required on target for each disk
[  80.0] Converting Red Hat Enterprise Linux Server release 5.11 to run on KVM
virt-v2v: This guest has virtio drivers installed.
[ 136.0] Mapping filesystem data to avoid copying unused and blank areas
[ 137.0] Closing the overlay
[ 137.0] Checking if the guest needs BIOS or UEFI to boot
[ 137.0] Copying disk 1/1 to /var/lib/libvirt/images/rhel5-para-sda (raw)
    (100.00/100%)
[ 599.0] Creating output metadata
Pool default refreshed

Domain rhel5-para defined from /tmp/v2vlibvirt8e77ed.xml

[ 599.0] Finishing off

Step 8

Confirm that the VM has been imported correctly:

# virsh list --all

If this command lists the new Linux virtual machine, you have successfully converted and imported the VM. Boot the VM and confirm its full functionality before deleting the original VM or migrating active services.

Further resources

For more information on managing virtual machines with libvirt in RHEL 7, see the Red Hat Enterprise Linux 7 Virtualization Deployment and Administration Guide.

For more information on managing virtual machines with libvirt in RHEL 8, see RHEL 8 Configuring and Managing Virtualization.

For more information on managing virtual machines with libvirt in RHEL 9, see RHEL 9 Configuring and Managing Virtualization.

For more information on using virt-v2v to convert virtual machines, you can see the following articles:

In addition, you can refer to the virt-v2v man page and the virt-v2v upstream documentation.

Comments