My professor asked my for a project about Nested virtualization to emulate some process.
First I should say what is Nested virtualization? If you have a Hypervisor for virtualization and you wanted to have another hypervisor on it. this is Wikipedia’s definition for it :
“Nested virtualization refers to the ability of running a virtual machine within another, having this general concept extendable to an arbitrary depth. In other words, nested virtualization refers to running one or more hypervisors inside another hypervisor. Nature of a nested guest virtual machine does not need not be homogeneous with its host virtual machine; for example, application virtualization can be deployed within a virtual machine created by using hardware virtualization.”
If you want to read more about it :
Now in my lab I have ESXi 6 and I want to install an Ubuntu server 16.04 on it and install KVM base machine on Ubuntu server with libvirt. ( I should mention that this is not a good idea but for testing the solution it can help). First I should enable Nested virtualization on ESXi trough :
1- ssh to ESXi host :
1-1 : you should enable SSH service on ESXi by : Configuration -> Security Profile -> Properties -> SSH -> start
then SSH to ESXi host with user “root” and your password , then edit “/etc/vmware/config” with a text editor and add this line to the end of file
vhv.enable = “TRUE”
2- Turn of the virtual machine and edit CPU configuration to “Use Intel VT-X/AMD-V for instruction set virtualization and Intel EPT/AMD RVI for MMU virtualization.” trough : Edit the VM settings and go to VM settings > Options > CPU/MMU Virtualization . Select the Intel EPT option, like :
3- Go to Options->CPUID mask> Advanced-> Level 1, add the following CPU mask level
ECX —- —- —- —- —- —- –H- —-
4- Open the vmx file of the Ubuntu VM and add the following setting
monitor.virtual_exec = “hardware”
hypervisor.cpuid.v0 = “FALSE”
That’s it, Now you can use Nested virtialization.
Once the above configurations are done in ESXi and the VM, hardware virtualization would be supported in the VM. Inorder to confirm that, run the following command in the Ubuntu VM.
egrep -c ‘(vmx|svm)’ /proc/cpuinfo
You should get output as 1, which means hardware virtualization is supported. Also you should see hvm flags in the output when you run the following command
Or else you could also run the following command
The output should be as follows:
INFO: /dev/kvm exists
KVM acceleration can be used