When working in an environment where you have both a VMWare hypervisor and an oVirt or RHEV hypservisor or you want to migrate away from VMWare ESX to oVirt or RHEV, you will need a way to move or copy your current virtual machines from one to another. Unfortunately this can’t be done without downtime but at least it can be done. In this post I’ll try to explain how to successfully move a VM running on ESX or vCenter to an oVirt or Red Hat Enterprise Virtualization host.
Unfortunately, moving a guest from VMWare to oVirt can’t be done without downtime. The guest needs to be shut down before we can start copying it away from the VMWare environment. An option is to first take a clone of the currently running machine in VMWare and to move the clone to oVirt. After the clone is successfully moved, you can shut down the original VM and boot the new one. Using this practice, you can minimize the downtime but you need to be aware that changes in the VM since the moment you took the clone are lost.
Preparation of the oVirt host
Create an export storage domain:
When copying a VM from VMWare to oVirt, the data of the VM will first be copied on an export domain. After the copy, we can import the VM in oVirt from this export domain. So before we can copy something, we’ll need an export domain available on our oVirt host.
Start by creating an NFS-share with sufficient space:
[root@ovirt ~]# mkdir /var/lib/exports/export [root@ovirt ~]# chown vdsm:kvm /var/lib/exports/export [root@ovirt ~]# mount /dev/mapper/vgnonssd-lvnonssd /var/lib/exports/export [root@ovirt ~]# df -h /var/lib/exports/export/ Filesystem Size Used Avail Use% Mounted on /dev/mapper/vgnonssd-lvnonssd 439G 71M 417G 1% /var/lib/exports/export [root@ovirt ~]# echo "/var/lib/exports/export ovirt(rw)">>/etc/exports [root@ovirt ~]# exportfs -a [root@ovirt ~]# showmount -e Export list for ovirt: /var/lib/exports/export ovirt /var/lib/exports/ssd ovirt /tmp/iso ovirt
As you can see in the above output, I created a directory for my mountpoint, made vdsm owner and mounted an LVM on the mountpoint. After mounting, I exported the mount by adding a line in /etc/exports.
Now that we have our NFS-share, we can add the storage domain, as type export to the oVirt-host. Navigate to System -> Data Centers -> Default (or your data center name) -> Storage -> New Domain and enter the details valid for your environment:
After adding the domain, it needs to be activated. Navigate to System -> Data Centers and select your data center name from the list. Select the new export domain and click on “Activate”:
Now, the export domain is ready to be used.
To convert the VM from the format that is used by VMWare and the format used by oVirt, we need to install the package virt-v2v:
[root@ovirt ~]# yum -y install virt-v2v ... Complete !
Configure a ~/.netrc:
The last thing to do before we can start the migration, is to create a ~/.netrc file. This file will contain the credentials needed to authenticate at the VMWare ESX or vCenter server. Al tough not very common anymore, .netrc is a standard file to contain login information.
[root@ovirt ~]# echo "machine 192.168.0.5 login root password secret">>~/.netrc [root@ovirt ~]# chmod 600 ~/.netrc
Make sure that the ~/.netrc file has mode 600 for permissions.
Preparation of the virtual machine
For a Linux VM, there is no real need to prepare the VM. After conversion and importing the VM you should remove the vmware guest tools and install the ovirt-agent but the virtio drivers should be present in any fairly recent kernel.
For a Windows VM, there could be issues with missing virtio drivers so it’s a good idea to install them before doing the migration to oVirt. You can find the drivers here: http://alt.fedoraproject.org/pub/alt/virtio-win/latest/. The same applies as for the Linux guest: after the migration: remove the vmware-tools.
Copy the virtual machine to oVirt
Now that all preparations are done, we can start the actual copy and convert our VMWare VM to a working VM in oVirt:
[root@ovirt ~]# virt-v2v -ic esx://192.168.0.5/?no_verify=1 -o rhev -os ovirt:/var/lib/exports/export --network ovirtmgt testvm2 testvm2_testvm2: 100% [===================================================================]D 0h07m40s
When executing this command, the credentials specified in the ~/.netrc file will be used to authenticate at the VMWare ESX host or vCenter. The option -o rhev makes clear that the target format will be RHEV or oVirt and the network parameter should match to the same network that the VM has in VMWare.
During the copy you should see a simple progress-indicator. Performance is comparable to a copy over NFS.
After copying and converting the VM from the VMWare environment to the oVirt export domain, we need to import the VM in oVirt. Navigate to System -> Data Centers -> Default (or your data center name) -> Storage and select the export domain from the list. In the bottom pane, choose the “VM import” tab, select the VM which we just exported and click on “Import”:
After the import, we can boot the VM without issues. We only need to check the network settings and we’re ready to go.
In case you get the following message:
libvirt error code: 1, message: internal error Invalid or not yet handled value '/vmfs/volumes/7530bad7-8e331d66' for VMX entry 'ide1:0.fileName'
Make sure to remove the IDE cdrom drive or any other virtual IDE device in the VMWare virtual machine configuration.
In case you get the following message:
virt-v2v: Failed to launch guestfs appliance. Try running again with LIBGUESTFS_DEBUG=1 for more information
This seems to be a compatibility problem between changes in packages that aren’t applied everywhere. A workaround for me was to set the LIBVUESTFS_ATTACH_METHOD to appliance:
[root@ovirt ~]# export LIBGUESTFS_ATTACH_METHOD=appliance
Unfortunately it’s not possible to live migrate VM’s so this message should be clear:
[root@ovirt ~]# virt-v2v -ic esx://192.168.0.5/?no_verify=1 -o rhev -os ovirt:/var/lib/exports/export --network ovirtmgt testvm1 virt-v2v: Guest testvm1 is currently running. It must be shut down first.
Thank you so much for useful tutorial, can you suggest please how to manage the issue with ssh on a VM that does not work from on the vmware?
Do I understand correct that you want to connect to a VM running on ESX from the ESX cli over SSH?
No, I am running an ovirt and ovirt host with VM on the vmware workstation, and I could connect via ssh to the ovirt host, but not to ovirt host VM that I have deployed, it does not work is a bug of vmware ?
I’m afraid that’s a problem from a complete different nature. You probably have some issues with NAT or your bridge setup in your oVirt host. It’s also possible that your physical network connection doesn’t allow all those different MAC-addresses and bridging.
Part of the problem is probably that you’re running nested hypervisors (VMware WS + oVirt). It’s always tricky in regards to networking…
or I should install an ovirt host/node into exsi?
Theer’s nothing like the relief of finding what you’re looking for.
great tutorial, thanks!
how to move guest from Ovirt-3 to Ovirt-4
Is it in 2018 possible to import from a esxi free host to an ovirt setup with glusterfs directly (ssh?)
I don’t have vcenter and in the Virtual Machines> Import screen it’s asking for vcenter host/IP + esxi host/IP + Data Center and Cluster.
Fidddling about I think my data center is [datastore1] but in the log it says
Expecting ‘xxx.xxx.xxx.xxx’ to be a vCenter/VPX host but found a ESX(i) host
Yet it won’t let me leave the vcenter ip box empty :(
Nearly perfect tutorial, appreciated!
How to migrate VMware VMs to oVirt platform?