WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / ESXi / How to run Qemu & KVM on ESXi?

How to run Qemu & KVM on ESXi?

09.17.2014 by William Lam // 4 Comments

Last week I was asked whether ESXi could run the KVM hypervisor as a Virtual Machine (often referred to as Nested Virtualization). I personally have not used KVM before or run it on top of ESXi, but I have heard of many folks successfully virtualizing KVM as a Virtual Machine on top of ESXi. I figure since I have already written several articles on Nesting VMware ESXi, Microsoft Hyper-V and Xen on top of ESXi, I might as well also take a look at KVM!

Disclaimer: Nested Virtualization is not supported by VMware, please use at your own risk.

As mentioned already, I have not used KVM before and one thing I wanted to understand before trying to run it as a Virtual Machine is what the difference is between Qemu and KVM as I have heard both these terms used in-conjunction before. I found this post to be quite helpful in helping me understand the differences between Qemu, KQemu and KVM. I recommend a read if you are new to Qemu or KVM like I am.

From the article above, we now see that you can run either Qemu as a standalone system or KVM which is an accelerator that runs on top of Qemu. With this, I will now demonstrate how you can run Qemu as well as KVM as Virtual Machine on top of ESXi. In the example below, I have selected the latest Ubuntu release (14.04.1) to run both Qemu and KVM.

To be able to run either Qemu or KVM on top of ESXi, you just need to create a Virtual Machine running Virtual Hardware 10 and enable the (VHV) Hardware Assisted Virtualization feature which available in the vSphere Web Client as seen in the screenshot below:

qemu-and-kvm-on-esxi-0
To validate that you have properly enable VHV, you run the following command:

egrep '(vmx|svm)' /proc/cpuinfo

You should see some output when running the command, else it was not properly enabled as seen in the screenshot below:

qemu-and-kvm-on-esxi-1
Another command you can also run to check if the VM has been properly configure is the following:

kvm-ok

You should also see a message stating that KVM acceleration is possible:

qemu-and-kvm-on-esxi-2
Installing/Running Qemu on Ubuntu VM

Step 1 - Install Qemu by running the following command:

sudo apt-get -y install qemu

Step 2 - Download and extract a simple Linux Qemu image by running the following two commands :

wget http://wiki.qemu.org/download/linux-0.2.img.bz2
bunzip2 linux-0.2.img.bz2

Note: You can also find other Qemu images here.

Step 3 - Launch the Linux image by running the following command:

qemu-system-x86_64 linux-0.2.img -curses

qemu-and-kvm-on-esxi-3

Installing/Running KVM on Ubuntu VM

Step 1 - Install KVM by running the following command:

sudo apt-get install qemu-kvm libvirt-bin

Step 2 - Install bridge networking components by running the following command:

sudo apt-get install bridge-utils

Step 3 - Add a bridge interface by running the following command:

sudo brctl addbr br0

Step 4 - Append the following configuration to /etc/networking/interfaces:

auto br0
iface br0 inet dhcp
        bridge_ports eth0
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0

Step 5 - Restart the networking service by running the following command:

sudo /etc/init.d/networking restart

Step 6 - Next, we will need to create a VM which is based on an XML file. Here is what my VM definition looks like:

<domain type='kvm'>
  <name>alice</name>
  <uuid>61a813ba-3c4c-11e4-b048-005056a85388</uuid>
  <memory>1048576</memory>
  <currentMemory>1048576</currentMemory>
  <vcpu>1</vcpu>
  <os>
    <type>hvm</type>
    <boot dev='cdrom'/>
  </os>
  <features>
    <acpi/>
  </features>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/bin/kvm</emulator>
    <disk type="file" device="disk">
      <driver name="qemu" type="raw"/>
      <source file="/home/lamw/alice.img"/>
      <target dev="vda" bus="virtio"/>
      <address type="pci" domain="0x0000" bus="0x00" slot="0x04" function="0x0"/>
    </disk>
    <disk type="file" device="cdrom">
      <driver name="qemu" type="raw"/>
      <source file="/home/lamw/ubuntu-14.04.1-desktop-amd64.iso"/>
      <target dev="hdc" bus="ide"/>
      <readonly/>
      <address type="drive" controller="0" bus="1" target="0" unit="0"/>
    </disk>
    <controller type="ide" index="0">
      <address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x1"/>
    </controller>
    <interface type='bridge'>
      <mac address='52:54:aa:00:f0:51'/>
      <source bridge='br0'/>
    </interface>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport="yes" listen='172.30.0.207'/>
  </devices>
</domain>
Step 7 - You will need to make some changes to the XML file such as the location of the Ubuntu ISO (which is required to boot the VM) as well as the lP Address of the VNC service for console access to VM and lastly the UUID identifier of the VM which can be generated by ru

Step 7 - You will need to make some changes to the XML file such as the location of the Ubuntu ISO (which is required to boot the VM) as well as the lP Address of the VNC service for console access to VM and lastly the UUID identifier of the VM which can be generated by running 'uuid' command.

Step 8 - Before we can create our VM, we will need to create the Image file by running the following command:

qemu-img create -f qcow2 /home/lamw/alice.img 5G

Step 9 - We are now ready to initialize and boot up our VM by running the following command:

virsh --connect qemu:///system create alice.xml

Step 10 - We can get information about the VM we just created by running the following command:

virsh --connect qemu:///system dominfo alice

qemu-and-kvm-on-esxi-4
Step 11 - Lastly, we can connect to the VM console using a VNC client and if you modified the XML definition of the VM to listen on the public address of your Ubuntu host VM, then you should be able to see the installer of ISO bootup (in my case, it's Ubuntu Desktop Edition) as seen in the screenshot below:

qemu-and-kvm-on-esxi-5
Note: The instructions have been modified from this site here http://xmodulo.com/2014/02/use-kvm-command-line-debian-ubuntu.html There were a couple of errors that I ran into and hence re-writing

Additional Resources:

  • https://gmplib.org/~tege/qemu.html

More from my site

  • VM serial logging to the rescue for capturing Nested ESXi PSOD
  • vSphere 6.0 Update 2 hints at Nested ESXi support for Paravirtual SCSI (PVSCSI) in the future
  • Deploying Nested ESXi is even easier now with the ESXi Virtual Appliance
  • VMware Tools for Nested ESXi updated to v1.2
  • New VMware Fling to improve Network/CPU performance when using Promiscuous Mode for Nested ESXi

Categories // ESXi, Nested Virtualization, vSphere Tags // ESXi, kqemu, kvm, nested, nested virtualization, qemu

Comments

  1. *protectedAndras says

    09/17/2014 at 6:49 pm

    You can check virt-manager it's a pretty simple (compared to VMware) GUI, but it can be handy. sudo apt-get install virt-manager

    Reply
  2. *protectedMike says

    08/30/2016 at 11:43 am

    Very helpful post! I was looking to get KVM support on my GNS3 VM after moving it to ESXi from VMware Workstation. Your configuration from the vsphere web client was spot on!

    Reply
  3. *protectedAtul says

    12/08/2016 at 3:26 am

    Dear William,
    This blog was very informative one. I came across once thought of running ESXI over any other hypervisor.
    Is it currently support in vmware ?

    Regards,
    Atul

    Reply
  4. *protectedWiley Wiggins (@wileywiggins) says

    05/13/2017 at 3:29 pm

    Do you think it would theoretically be possible to use Qemu to run a Mac OS 9 virtual machine on an Xserve running ESXi6?

    Reply

Leave a Reply to Wiley Wiggins (@wileywiggins)Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025

 

Loading Comments...