Ubuntu – Kvm nested Virtualbox windows guest

kvm-switchUbuntuvirtualbox

My setup is:

  • L0: KVM, ubuntu
  • L1: Windows 10
  • L2: Virtualbox (ubuntu) or Bluestacks (Android Emulator)

Symptoms:

  • Bluestacks complains that Hyper-V is enabled and won't start, even though it is not in windows 'additional features'.
  • Virtualbox will reboot the entire Windows guest once I run a new VM. I've tried changing basically every setting I could find.

I do have nested enabled:

$ systool -m kvm_intel -v | grep nested
    nested              = "Y"
$ cat /sys/module/kvm_intel/parameters/nested
Y

Inside my config for my VM ('virsh edit ')

<features>
  <acpi/>
  <apic/>
  <vmport state='off'/>
</features>
<cpu mode='custom' match='exact' check='partial'>
  <model fallback='allow'>Haswell</model>
  <feature policy='require' name='vmx'/>
</cpu>

systeminfo in the L1 guest says:

Hyper-V Requirements: A hypervisor has been detected. Features required for Hyper-V will not be displayed.

Any idea why I can't get nested virtualization working at L2 with a windows host?

Best Answer

To get Hyper-V to work in a KVM virtual machine, you need to both pass through the host CPU model as-is, and disable the hypervisor CPU feature (of the virtual CPU). Your virtual machine XML should appear as follows:

  <cpu mode='host-model' check='partial'>
    <model fallback='allow'/>
    <feature policy='disable' name='hypervisor'/>
  </cpu>

In addition, you should create the VM with Q35 chipset, not i440fx. And ideally the guest should boot with UEFI. If you use BIOS boot you need SeaBIOS 1.10 (I think, it's been a while) or later. For Ubuntu that means Ubuntu 18.04 LTS or later.

Related Question