Virtual machines are often created for just one type of hypervisor and are never used anywhere else, but on some...
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
occasions, you'll need to create a virtual machine that can run in multiple hypervisors. The key to creating such as machine is to find the perfect VM file format, but this isn't always a simple task. This article provides some tips to make your VM file as compatible as possible so that it is interchangeable among VMware Workstation, Oracle VirtualBox and Linux KVM.
I recently faced the challenge of creating a Linux VM that had to work on different virtualization platforms and support VMware Workstation, Oracle VirtualBox and the KVM. There are a few things you need to take into consideration when creating such a VM, including virtual disk file compatibility and what type of virtual disk to use within the VM.
Choose SCSI over VirtIO
If you're creating a Linux VM for the KVM hypervisor, the default disk type is set to a VirtIO device. VirtIO was developed for KVM to provide fast and direct access to the virtual disk without the need for I/O emulation before blocks can be written to disk. A VirtIO device creates a specific device type, one that doesn't work on other Linux virtualization platforms, making it impossible to read a VirtIO disk on software such as Workstation or VirtualBox. An emulated Small Computer System Interface (SCSI) driver, however, provides users with a /dev/sda device compatible with all virtualization platforms.
Using the right disk format
The next challenge is selecting the best virtual disk format. There are a number of disk formats to choose from, each with its own unique features that make working with a specific VM type within the virtualization platform as easy as possible. Unfortunately, as a result of their specificity, these different disk types have some degree of incompatibility.
VMware Workstation, for instance, creates a VMDK file by default. This VMDK file can be converted to the required KVM disk file type, but it will be difficult to read in VirtualBox. The best option is to use a type of VM file called the Open Virtualization Format (OVF) file. OVF is an open virtualization standard developed to make virtual disk files interchangeable among different hypervisors. You can easily create an OVF file by selecting the Export as OVF option from VMware Workstation; note that this option isn't available in other VMware products, such as VMware Fusion. While using an OVF file certainly makes things easier, some additional work is required to make it fully compatible across all virtualization platforms.
Making an OVF file fully compatible
In order to use an OVF file in Oracle VirtualBox, you must first open the file with an editor and replace every instance of the phrase ElementName with Caption, and every instance of a vmware.sata.ahci disk type with Advanced Host Controller Interface. Next, you must generate a Secure Hash Algorithm hash sum for the VM files, which can be done by running the sha1sum <FILENAME>.ovf command on each VM file. Without making these adjustments to the OVF file, you'll receive an error message when you attempt to import it in VirtualBox.
Using OVF files on KVM is a different story. Before you can import them, you'll need to ensure that each VM file is converted to the right format. You can do this by using the qemu-img convert command to read the input file, which is either OVF or VMDK, to the QEMU Copy-on-Write (qcow2) output format. Qcow2 file format is the file format of choice for KVM and other open source virtualization platforms, and can easily be integrated in an OpenStack cloud. Use the following command to convert your file to the required qcow2 file format:
qemu-img convert -O qcow2 <FILENAME>.vmdk <FILENAME>.qcow2
Even after converting the KVM file type to qcow2, there's no guarantee that it will work. You'll next need to import it in the KVM environment with a management tool such as the Linux Virtual Machine Manager, using the New > Import Existing Disk Image option. Once this is complete, you must assign the VM to the Linux OS you want to use. Be careful, because if you select anything other than the generic Linux OS type, you risk ending up with a VM configuration file that expects a VirtIO disk to be present, and that's not going to work if you've used the generic SCSI driver to access the virtual disk.
Creating a VM file that is compatible among different virtualization platforms is no walk in the park, but if you make sure the VM isn't using VirtIO disk type and you've written the disk file to an OVF file, it is possible.
Breaking down VM compatibility
QEMU's diminishing role in KVM virtualization
Comparing and contrasting free hypervisors