Nested Virtualization in Xen
Nested virtualization is the ability to run a hypervisor inside of a virtual machine. The hypervisor that runs on the real hardware is called a level 0 or L0; the hypervisor that runs as a guest on L0 is called level 1 or L1; a guest that runs on the L1 hypervisor is called a level 2 or L2.
Nested virtualization is a technology that has several potential applications:
- End-user virtualization for guests. With nested virtualization, users can run Windows 7's XP compatibility mode (VirtualPC), or install Bromium in guests.
- Development. Many developers have found testing and debugging hypervisor and dom0 code much easier when it's run inside a virtual machine.
- Deployment testing. When experimenting with deployment of large clouds, admins can create "virtual clouds", comprising dozens of virtual machines, to test how cloud orchestration software or other coordination and deployment layers will work at scale, without the need to actually have a large number of dedicated machines.
Running PV guests as an L2 has been supported in Xen since the introduction of HVM guests in Xen 3.0. Support for HVM guests as L2 guests is heavily dependent on architecture-specific support. Nested HVM on AMD CPUs is considered "experimental". Nested HVM on Intel CPUs, as of Xen 4.4, is considered "tech preview". For many common cases, it should work reliably and with low overhead. However, there are some important limitations, and we do not recommend that it be used in a production environment at this time.
Only 64-bit hypervisors are supported at this time.
See below for more details on tested hypervisior / guest combinations, and known issues on Intel CPUs.
- Make sure you have the right support
- Xen 4.4 or later
- Intel CPU with EPT support
- Add the following to your config file:
|L1||First level VM which is able to start second level VM|
|L2||The second level VM which boot up by L1|
|XP_mode||L1 WIN7 VirtualPC XP_mode on L0 XEN|
How to use nested
- Nested feature is added to Xen long time ago. But it is really ready to use only from last year. So it’s better to use the latest Xen,
git clone git://xenbits.xen.org/xen.git xen.git
- NB: When I wrote this Wiki, there are still one patch is missing in upstream Xen if you want to boot up VMware and Hyper-v. You can get the patch from:
- No special requirement for Dom0. Just use the stable one is enough.
- Both Qemu-xen and Qemu traditional are OK.
- To use nested virtualization, you need to add the following two lines in your guest configuration file:
- NB: We don’t want to support L1 guest with shadow mode, since the performance is very poor. So I recommend you to enable the EPT(hap = 1) in the L1 guest. Besides, there is a known issue that nested is failing to work with L1 shadow mode.
- To boot L1 VMware-ESX, VMware-Workstation, Win8-hyperv, you needs to mask CPU bit.
cpuid = ['0x1:ecx=0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx']
|L0 XEN||git commit:58f5bcaf05621810f06bf5b3592e2ae87475053d|
|L1 XEN||git commit:e423b5cd60ff95ba3680e2e4a8440d4d19b2b13e|
|L1 VMware Workstation||10.0|
|L1 VMware ESX||5.1|
|L1 Hyperv||Win8 with hyperv feature enabled|
hap=1 nestedhvm=1 cpuid = ['0x1:ecx=0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx']
- V means guest boots well
- V* means it works before, but buggy with latest Xen
- 1. Only L2 EPT/Shadow on L1 EPT is working. L2 EPT/Shadow on L1 Shadow is not supported.
- 2. Virtual Box fails to boot on top of Xen (L1 panic while booting L2)
- 3. Hyper-v screen flush issue:
- Current the screen flush is not correct after booting hyper-v. Two workarouds:
- using remote desktop to connect guest
- or set full update mode in Qemu.
- 4. Using populate-on-demand (memory!=maxmem) or guest paging in an L1 hypervisor for an L2 guest may deadlock the L0 hypervisor.
- 1. L1 stress test, performance test
- 2. L2 stress test performance test
- 3. L1 save restore, live migration
- 4. L2 save restore, live migration
- 1. Nested Virtualization on Xen http://www-archive.xenproject.org/files/xensummit_intel09/xensummit-nested-virt.pdf
- 2. Nested Virtualization Update from Intel http://www.slideshare.net/xen_com_mgr/nested-virtualization-update-from-intel