vmware VMDK conversion

Latest response

it appears that V2V conversion from a vmware source requires that the source is on an ESX server.  What if we are not running an ESX server and only have the VMDK files?  Is it  Possible to convert from the stand-alone VMDK file without an ESX server.  If so what is the best way to do this?

Responses

vmdk files can be converted to raw or qcow2, but virt-v2v does more than format conversion - it also injects the virtio drivers and prepares the VM to run on RHEV.

 

The easiest way to do this would be to just set up an ESXi server and run virt-v2v properly. Alternatively, you could convert the files manually, and set up a libvirt based VM, from which virt-v2v would pull the VMs.

 

Simple file support can be a great RFE, btw

You can also use the Acronis ABR11 software to achieve this. A trial that includes 3 free migrations can be found on the Red Hat Marketplace at:

 

http://marketplace.redhat.com/rhev/5-Acronis-Backup-Recovery-Virtual-Edition-11

It looks like there is already an open RFE for virt-v2v to work on stand-alone VMDK files, however there are a couple blocking issues. Specifically, The qemu-img vmdk block driver can't handle VMware4 compressed images. There is some work being done at Google Summer of Code  to address this, however not complete.

 

From what I can tell you can do the conversions manually by first using virt-convert to convert the VMware images into libvirt images, then use virt-v2v to import them into RHEV. However this will only work under the following conditions.

  1. The VMware exported images are exported as FLAT images, not compressed images.
  2. You have to either have the meta data, xml file, exported form the VMware server, or create you own libvirt.xml file to pass to virt-v2v.

If you have the meta data exported form VMware as either an ovf file or vmx file you can run virt-convert directly on the meta data file. It should convert the image, assuming the vmdk file is is the same dir.

 

# virt-convert -i ovf test.ovf

or

# virt-convert -i vmx test.vmx

 

If you do not have the meta data you can manually convert the disk file, vmdk, using qemu-img, then manually create your own libvirt.xml file:

 

# qemu-img convert test.vmdk -O raw test.img

 

example libvirt.xml:

 

<domain type='kvm'>
  <name>test</name>
  <currentMemory>6291456</currentMemory>
  <memory>6291456</memory>
  <uuid>a85b6649-99a5-391f-856b-53e20ab4c719</uuid>
  <os>
    <type arch='x86_64'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/><apic/><pae/>
  </features>
  <clock offset="utc"/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <vcpu>2</vcpu>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw' cache='none' io='threads'/>
      <source file='/path/to/converted/disk.raw'/>
      <target dev='hda' bus='ide'/>
    </disk>
    <interface type='network'>
      <source network='default'/>
      <mac address='52:54:00:01:33:86'/>
    </interface>
    <input type='mouse' bus='ps2'/>
    <console type='pty'/>
  </devices>
</domain>

 

Once you have the images converted to raw disk images and a libvirt.xml file we can virt-v2v to import them into RHEVM.

 

# virt-v2v -i libvirtxml -o rhev -os hostname:/exportdomain libvirt.xml

 

This is just what I found after a couple hours playing around, and with very little testing. Your mileage may very, any addition input on the subject is appreciated.
 

We are hoping to fix this for RHEL 7 [usually disclaimers about future features, E&OE, YMMV, etc]

 

It needs work which is mostly complete now in qemu, plus further development work in virt-v2v.  I cannot find the RFE right this minute ...

Dear Dave, 

 

Thanks for sharing the details. However can you please help me to understand from where we can get "virt-convert" package as i dont see that package in RHN ?

 

Kindly suggest.

 

 

Thanks,

Ashish

yum install /usr/bin/virt-convert

 

should work in most situations.

Thank you ver much it works and I am able to download virtu-convert.

However when I ran this command, I got the below error:

[root@ipas home]# ll
total 4965188
drwx------. 4 redhat redhat 4096 Mar 19 13:03 redhat
-rwxr-xr-x 1 root root 5079367680 Mar 21 15:43 Red Hat Enterprise Linux 5.vmdk
-rwxr-xr-x 1 root root 1400 Mar 21 15:43 Red Hat Enterprise Linux 5.vmx
[root@ipas home]# virt-convert -i vmx Red\ Hat\ Enterprise\ Linux\ 5.vmx
Generating output in 'virt-image' format to RHEL5_Yum/
Converting disk 'Red Hat Enterprise Linux 5.vmdk' to type raw...

Done.
[root@ipas home]#

[root@ipas home]# ll
total 4965192
drwx------. 4 redhat redhat 4096 Mar 19 13:03 redhat
-rwxr-xr-x 1 root root 5079367680 Mar 21 15:43 Red Hat Enterprise Linux 5.vmdk
-rwxr-xr-x 1 root root 1400 Mar 21 15:43 Red Hat Enterprise Linux 5.vmx
drwxr-xr-x 2 root root 4096 Mar 21 16:05 RHEL5_Yum
[root@ipas home]#

[root@ipas RHEL5_Yum]# virt-v2v -i libvirtxml -o rhev -os 10.10.10.200:/ISO RHEL5_Yum.virt-image.xml
virt-v2v: RHEL5_Yum.virt-image.xml doesn't look like a libvirt domain XML file
[root@ipas RHEL5_Yum]# ll
total 4861124
-rw-r--r-- 1 root root 12884901888 Mar 21 16:05 Red_Hat_Enterprise_Linux_5.raw
-rw-r--r-- 1 root root 495 Mar 21 16:05 RHEL5_Yum.virt-image.xml
[root@ipas RHEL5_Yum]# cd ..
[root@ipas home]# ll

Kindly suggest what is the issue in the same.

It's simply not possible to use virt-v2v (or any of our tools) in the manner you are trying.  This feature is scheduled for RHEL 7.

Dear Richard,

I am able to convert one of my vmware machine to RHEV virtual machine by creating the xml file manually however now when I am trying to convert a vhd vm (which has already been converted by "qemu-img convert manager.vhd -O raw manager.img" into RHEV virtual machine, I am receiving the below mentioned error:

[root@manager home]#
[root@manager home]# virt-v2v -i libvirtxml -o rhev -os 10.10.10.200:/ISO libvirt.xml
manager.img: 100% [===============================================================================================================]D 0h09m33s
inspect_os: umount_all: umount: /sysroot: umount: /sysroot: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1)) at /usr/share/perl5/vendor_perl/Sys/VirtConvert/GuestfsHandle.pm line 187.
at /usr/bin/virt-v2v line 602

Kindly suggest what can be the issue or what is the workaround to convert a windows vhd virtual machines into rhev virtual machine

Thanks,
Ashish