Can Hyper-V run in a virtual machine?
Ok, we all know (or should know) that Microsoft's answer is a plain "NO!".
But we also know that recent hypervisors can support nested/recursive virtualization, provided the underlying CPU offers hardware virtualization; VMware's recent products (ESXi 5, Workstation 8) even support this natively, without the need for ugly hacks.
So, my question is: can Hyper-V run succesfully (i.e. allowing to actually run virtual machines) inside other hypervisors?
If yes, which ones? And how?
This is only intended for testing, of course.
Solution 1:
Yes, it can, if the underlying CPUs support the latest virtualization extensions (Intel VT-X/EPT) and if you're using the latest VMware products (Workstation 8, ESXi 5).
The relevant settings in your VM should be as follows:
monitor.virtual_mmu = "hardware"
monitor.virtual_exec = "hardware"
vhv.enable = "TRUE"
hypervisor.cpuid.v0 = "FALSE"
The first three settings can be enabled via GUI (where exactly varies slightly between Workstation and ESXi), the last one needs to be manually added to the VM's .vmx
file.
Additionally, on ESXi 5, you need to add the following line to /etc/vmware/config
:
vhv.allow = "TRUE"
Solution 2:
There are different answers to this question.
Before WS2016/W10, the correct answer was: Yes, you can enable the Hyper-V role in a Hyper-V VM, but the hypervisor would not start. Therefore, you could create VMs in the vHost, but those VMs could not start.
However, in Windows 10 and WS2016 (TP4 and later) we can use nested Hyper-V. If you're mad enough to try, you can create a host, in a host, in a host, in a host, on a host ...