/ Cloud

Virtual Machine migration from Vmware to Openstack/KVM

This is a quick and easy guide to migrate VMWare VM's to OpenStack (KVM) using Redhat Enterprise 6.5

Install virt-v2v

The virt-v2v command converts virtual machines from a foreign hypervisor to run on KVM, managed by libvirt.

# yum install virt-v2v

Next step is create an xml file for the pool and indicate the storage path, I created a very simple xml file, like this one:


<pool type="dir">
        <name>virtimages</name>
        <target>
          <path>/home/images</path>
        </target>
</pool>

Create an storage pool based on the xml file with virsh command and refeer the xml file

# virsh pool-create --file pool.xml

List the storage pool, "virtimages" pool is refering to the path given on the xml file which is /home/images

# virsh pool-list
Name                 State  	 Autostart
---------------------------------------------------------------------------------
virtimages           active 	  no

Create a .netrc file with ESX credentials, where the machine that you want to convert is hosted.

machine ESXi login root password s3cretitos

Convert the VMware VM to KVM, the virtual machine has to be stopped before to proceed with this, go to Virtual center and turn the VM off.

# virt-v2v -ic esx://(ESX IP address or name) -o libvirt -os (Storagepool) (VMname)
# virt-v2v -ic esx://ESXi/?no_verify=1 -o libvirt -os virtimages Trusty_test_CLON
Trusty_test_Trusty_test: 100% [===============================]D 0h04m25s
virt-v2v: Trusty_test_CLON configured without virtio drivers.

On my example I worked on a diferent server with libvirt, do not recommend to do this on a Openstack computer node running libvirt, so I performed this steps on a different node.

Convert the recent generated RAW image to qcow2 using qemu.

qemu-img convert -f raw -O qcow2 images/Trusty_test_Trusty_test  images/Trusty_exported.qcow2

Let's play with Glance, adding/importing the new image into image repository, the .qcow2 image generated by qemu is the one that we need to point to be imported in glance.

glance image-create --name Ubuntu_exported --is-public False --container-format bare --disk-format qcow2 < Trusty_exported.qcow2

Go to Openstack dashboard and create a new instance based on the new imported image from ESX, which in this case is “Trusty_exported.qcow2”, make sure you match the flavor with the sizing used on ESX, I tried a couple of flavors and then voila the OS was able to boot.
So you will be able to test the Exported/Imported VM from VMWare to Openstack/KVM.

References

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Virtualization/3.0/html-single/V2V_Guide/#chap-V2V_Guide-Installing_virt_v2v