Historically, we systems administrators have not been able to run a virtual machine (VM) inside of a virtual machine. However, the release of VMware Workstation 9 finally gives us the ability to perform nested virtualization.
Our goal here is to install and run the Hyper-V server role in an already virtualized instance of Windows Server 2012. We’ll then demonstrate that nested virtualization works by deploying a virtual machine (VMs) inside the “outer” VM.
Set up VMware Workstation
- Open VMware Workstation and create a new VM by using the Windows Server 2012 template. We will need to make two tweaks to the VM configuration in order to (fully) support Hyper-V Server:
- In the Virtual Machine Settings dialog box, enable the Virtualization engine options as shown in the following figure.
- Open the VM’s .VDX configuration file from the VM’s working directory. You can find the working directory by navigating to the Options page in the Virtual Machine Settings dialog box and checking the Working directory field.
Add the following three new entries to the .VDX configuration file to match the following screenshot. VMware configuration files can be opened with any text editor. I’ve given you a picture of my configuration file in the following figure.
- hypervisor.cpuid.v0 = “FALSE”: This option tricks the Windows Server 2012 into “thinking” it is not running in a virtualized instance
- mce.enable = “TRUE”: This option enables Machine Check Exception (MCE), which enable the Windows Server 2012 VM to report CPU hardware issues
- vhv.enable = “TRUE”: This option enables nested virtualization
You should check the Virtually Ghetto blog for a neat post that outlines a whole bunch of undocumented .VDX configuration parameters.
Tweaking the VM configuration file
Your .VDX file may already have an entry for vhv.enable. If so, then please ensure that you don’t have duplicate entries in the configuration file or your VM will fail to boot and produce the “Dictionary Problem” error. I’ve shown that error in the following screenshot.
Dictionary problem - A duplicate entry in your VDX file produces this error.
If you try to install the Hyper-V role in virtualized Windows Server 2012 without enabling nested virtualization, then Windows presents the “hypervisor is already running” error message shown in the following screen capture:
Hyper-V cannot be installed: A hypervisor is already running.
Installing the Hyper-V Server Role
Boot up the Windows Server 2012 VM and install the Hyper-V server role. We can do this either graphically via the Server Manager, or by using Windows PowerShell. For instance, we can open an elevated PowerShell prompt and submit the following command to install Hyper-V with its associated management tools.
PS:> Install-WindowsFeature –Name Hyper-V –Restart –IncludeAllSubFeature –IncludeManagementTools
After the “outer” VM restarts, we can fire up the Hyper-V Manager tool and test out the nested virtualization.
Testing Nested Virtualization
Open Hyper-V Manager from your Windows Server 2012 VM and click New > Virtual Machine.
Creating a new VM in a Windows Server 2012 Hyper-V VM
The rest of the process should be familiar to any Windows administrator who has used Hyper-V. The following screenshot should serve as proof that we can perform nested virtualization with VMware Workstation 9.
In the screenshot I’m installing a Windows 8 Hyper-V VM inside of a Windows Server 2012 VMware VM, which in turn runs on my Windows 7 hardware host.
Nested virtualization with VMware Workstation: A virtual machine running inside of a virtual machine inside of a hardware host.
Because VMware Workstation is a desktop application and not an enterprise server product, we certainly aren’t looking to deploy production-quality Hyper-V server boxes from this platform.
However, the ability to perform nested virtualization makes it much easier for administrators and developers to build, test, and rebuild configurations with the least amount of administrative effort.