When adopting a new virtualization solution, like Oracle Linux KVM with Oracle Linux Virtualization Manager, importing virtual machines from existing solutions is a common need. This allows you to preserve existing work and be productive from the very beginning of the new deployment. If you’re considering adopting Oracle Linux Virtualization Manager, this blog will be a helpful guide. It will take you through the steps to import a virtual machine from VMware vCenter. Let’s get started!
Importing a virtual machine (VM) from VMware to Oracle Linux Virtualization Manager can be performed using native tools, such as the virt-v2v command line tool or the administration web portal’s import option from virtual machines.
When importing a VM using the Oracle Linux Virtualization Manager administration web interface, the import process will use libvirt through an VPX connection to vCenter and one ESXi server available in the VMware cluster to read and transfer the VM's disks and files.
This blog focuses on importing VMs from the command line using VMware's Virtual Disk Development Kit (VDDK) library.
The import process is performed by a KVM host member of the Oracle Linux Virtualization Manager deployment or a stand-alone KVM host.
The KVM host will either connect to both the vCenter and ESXi server or just go directly to the ESXi server. It will read the VM definition and create a temporary configuration file suitable for Oracle Linux Virtualization Manager. The KVM host will download and convert the virtual disks from vmdk to qcow format, storing them locally. It will create the VM on Oracle Linux Virtualization Manager and upload the converted virtual disks to the specified storage domain.
The overall performance will depend on network speed, source storage speed, and destination storage speed.
For Linux VMs:
For Windows VMs:
NOTE: Windows VMs might not power down gracefully when using the power down option from vCenter, leaving some pending records.
An SSL certificate thumbprint, or SSL certificate fingerprint, is a hash of a certificate calculated using all the certificate's data and signature. Thumbprints are usually implemented with cryptographic hash functions.
Since you can import a VM connecting to vCenter or directly from an ESXi server, you can collect the thumbprint from both.
Connect to the KVM host that will import the VMs.
Gather the thumbprint from an ESXi host:
openssl s_client -connect esx1.example.com:443 </dev/null | \
openssl x509 -in /dev/stdin -fingerprint -sha1 -noout | \
grep -i "fingerprint"
Sample output:
SHA1 Fingerprint=9F:A6:79:DF:C1:70:EC:8C:48:FC:1C:D0:30:F4:53:BF:24:39:E6:78
Gather the thumbprint from a vCenter:
openssl s_client -connect vcenter.example.com:443 </dev/null | \
openssl x509 -in /dev/stdin -fingerprint -sha1 -noout | \
grep -i "fingerprint"
Sample output:
SHA1 Fingerprint=C9:69:8C:65:92:3D:19:D4:80:B7:69:1A:A9:43:47:9B:26:53:FB:88
You will need the credentials to access the VMware and Oracle Linux Virtualization Manager environments. For Oracle Linux Virtualization Manager, only the admin@internal user is allowed, and its password must be stored on a file locally in the KVM host. To connect to VMware, you can choose which user to use and save the password in a file.
For Oracle Linux Virtualization Manager, you can use your file name of choice. In this example, the Oracle Linux Virtualization Manager admin@internal user password is stored on the $HOME/olvm-admin-pass file:
echo "Welcome1" > $HOME/olvm-admin-pass
It is recommended that you make this file readable by root only:
chmod 0600 $HOME/olvm-admin-pass
For the VMware user password, choose the file name you want to use. In this example, the VMware user password is stored on the $HOME/vmw-user-pass file:
echo "P@ssw0rd" > $HOME/vmw-user-pass
It is recommended that you make this file readable by root only:
chmod 0600 $HOME/vmw-user-pass
Download the engine server CA public key and give it an understandable name in order to avoid conflicts, configure the Engine server hostname in a variable:
ENGINE="engine.example.com"
Download the CA public key using the following command:
curl -kL 'https://'$ENGINE'/ovirt-engine/services/pki-resource?resource=ca-certificate&format=X509-PEM-CA' -o /etc/pki/tls/certs/ca-$ENGINE.pem
Expand the VDDK tarball on your KVM host local disk. Choose a location like /usr/local, for example. Avoid using your home directory or temp directories like /tmp or /var/tmp since they have special SELinux security contexts and may block the virt-v2v command from accessing the needed files.
tar xf VMware-vix-disklib-... -C /usr/local
Confirm it has been expanded correctly by listing the /usr/local directory content and looking for the vmware-vix-disklib-distrib directory:
ls /usr/local
Ensure that you can connect to the VMware environment by listing VMs that are available in the ESXi host:
virsh -c 'esx://root@esx1.example.com?no_verify=1' list --all
Sample output:
# virsh -c 'esx://root@esx1.example.com?no_verify=1' list --all
Enter root's password for esx1.example.com:
Id Name State-----------------------
- ol94 shut off
You will need to set some variables to make the import command easier to understand.
Create a file called v2v-vars.sh with the following options and adjust the content to reflect your environment:
# VMware user to connect to vCenter, use the %5c characters to separate
# the Domain name and the username
export VMWUSER="VSPHERE.LOCAL%5cUSERNAME"
# An ESXi username that can ssh into the server
export ESXUSER="USERNAME"
# VMware vCenter FQDN or IP address
export VMWVCENTER="vcenter.example.com"
# VMware Datacenter
export VMWDC="APPS"
# VMware Cluster
export VMWCL="APP1CL"
# VMware ESXi host FQDN or IP address
export VMWESX="10.4.34.101"
# Engine server FQDN. Only the Engine hostname is allowed here.
# Add the Engine IP and hostname to the local /etc/hosts file if necessary.
export ENGINE="engine.example.com"
# OLVM Storage Domain name
export OLVMDS="Data"
# Engine server CA public key
export ENGINECACERT="/etc/pki/tls/certs/ca-engine.example.com.pem"
# ESXi host thumb print
export ESXTHUMBPRINT="9F:A6:79:DF:C1:70:EC:8C:48:FC:1C:D0:30:F4:53:BF:24:39:E6:78"
# vCenter thumb print
export VCENTERTHUMBPRINT="C9:69:8C:65:92:3D:19:D4:80:B7:69:1A:A9:43:47:9B:26:53:FB:88"
# Required by the rhv-upload option
export LIBGUESTFS_BACKEND="direct"
# Allow virt-v2v to enable VirtIO options while importing the VM
export VIRTIO_WIN=$HOME/oracle-winvirtio21-qemuagent-SCoter-20240417.iso
Load the v2v-vars.sh content into memory:
source v2v-vars.sh
Configure the IMPORT_VM variable:
export IMPORTING_VM="PUT_THE_VM_NAME_TO_IMPORT_HERE"
Configure the OLVM cluster name to store the imported VM:
export OLVM_CLUSTER="OLVM_CLUSTER_NAME_TO_IMPORT_THE_VM"
It is recommended that you redirect the output to a file so you can inspect it later, if necessary. The following example uses the tee command to show the command output on the screen and saves it to a file.
Run the following virt-v2v command to import the VM.
virt-v2v \
-ic vpx://${VMWUSER}@${VMWVCENTER}/${VMWDC}/${VMWCL}/${VMWESX}?no_verify=1 \
-ip $HOME/vmw-user-pass \
${IMPORTING_VM} \
-io vddk-libdir=/usr/local/vmware-vix-disklib-distrib \
-it vddk \
-io vddk-thumbprint=${VCENTERTHUMBPRINT} \
-o rhv-upload \
-oc https://${ENGINE}/ovirt-engine/api \
-op $HOME/olvm-admin-pass \
-os ${OLVMDS} \
-of qcow2 \
-oo rhv-cafile=${ENGINECACERT} \
-oo rhv-direct \
-oo rhv-cluster=${OLVM_CLUSTER} \
--verbose \
--network ovirtmgmt 2>&1 | tee -a /var/log/virt-v2v-${IMPORTING_VM}.log
Previous command options explained:
Load the v2v-vars.sh content into memory:
source v2v-vars.sh
Configure the IMPORT_VM variable:
export IMPORTING_VM="PUT_THE_VM_NAME_TO_IMPORT_HERE"
Configure the OLVM cluster name to store the imported VM:
export OLVM_CLUSTER="OLVM_CLUSTER_NAME_TO_IMPORT_THE_VM"
It is recommended that you redirect the output to a file so you can inspect it later, if necessary. The following example uses the tee command to show the command output on the screen and saves it to a file.
Run the following virt-v2v command to import the VM.
virt-v2v \
-ic esx://${ESXUSER}@${VMWESX}?no_verify=1 \
-ip $HOME/vmw-user-pass \
${IMPORTING_VM} \
-io vddk-libdir=/usr/local/vmware-vix-disklib-distrib \
-it vddk \
-io vddk-thumbprint=${ESXTHUMBPRINT} \
-o rhv-upload \
-oc https://${ENGINE}/ovirt-engine/api \
-op $HOME/olvm-admin-pass \
-os ${OLVMDS} \
-of qcow2 \
-oo rhv-cafile=${ENGINECACERT} \
-oo rhv-direct \
-oo rhv-cluster=${OLVM_CLUSTER} \
--verbose \
--network ovirtmgmt 2>&1 | tee -a /var/log/virt-v2v-${IMPORTING_VM}.log
You can run the virt-v2v command with the verbose mode (-v) and the trace mode (-x). To help you debug, enable the LIBGUESTFS_DEBUG variable as follows:
export LIBGUESTFS_TRACE=1
export LIBGUESTFS_DEBUG=1
virt-v2v -x -v -ic vpx://...
You can find additional variables that can be set in the following man pages:
After following the above steps, you'll be able to import VMs from VMware into Oracle Linux Virtualization Manager reliably and efficiently. Below are several additional resources to help with your migration to Oracle Linux Virtualization Manager.