Run WSL2 in Windows 10 guest VM running on a Linux host

Viewed 3914

I've got a Windows VM that I am using for testing in lieu of a real WIndows machine. I'd like to enable WSL2 inside that VM.

So far I've:

  • Upgraded Windows to v2004.
  • Enabled nested virtualization in kvm-intel kernel module via options kvm-intel nested=1
  • Made sure that sudo cat /sys/module/kvm_intel/parameters/nested outputs "Y".
  • Set <cpu model='host-passthrough'> in virt-manager's xml config.

Still no dice. As soon as I enable "Virtual Machine Platform" feature, as required for WSL2, my VM starts freezing on boot.

Has anyone managed to do this successfully?

1 Answers

The answer here - to pass through specific flags that make Windows think it is on the metal, but can do nested virt, saved the day for me:

https://superuser.com/a/1589286/916009 - please note this link was posted by @JCallicoat - just saying it should be the answer

cpu definition in your virtual machine emu like so:

<cpu mode="custom" match="exact" check="partial">
    <model fallback="allow">Skylake-Client-noTSX-IBRS</model>
    <feature policy="disable" name="hypervisor"/>
    <feature policy="require" name="vmx"/>
</cpu>
Related