6

I'm not sure this is the right place to ask this question.

I know that:

  • WSL2 uses Hyper-V architecture
  • Android Studio fails to install Intel HAXM if Hyper-V is enabled

So, if I disable Hyper-V completely, then install HAXM (Android Studio), then install WSL2 (this will enable Hyper-V), what happens? HAXM fails to work properly?

Omid Shojaee
  • 353
  • 1
  • 4
  • 13
  • Why don't you install Android Studio for Windows instead? AS for Linux can't be installed in a distro running under WSL2 for the exact reason you identified. Alternatively install a proper dual-boot or even only the Linux of your choice. – ChanganAuto Oct 11 '21 at 19:16
  • @ChanganAuto: I'm not sure I see where OP mentioned installing a Linux version? HAXM is primarily a Windows thing. – u1686_grawity Oct 11 '21 at 19:18
  • 2
    @ChanganAuto Please read my question again. Thanks. – Omid Shojaee Oct 11 '21 at 19:20
  • WSL2 **DOES NOT** require Hyper-V to be enabled. It's not clear what your question is, Android Studio and WSL2 should be able to coexist, since WSL2 does not require Hyper-V – Ramhound Oct 11 '21 at 20:06
  • 1
    @Ramhound Are you sure about that? While I know that technically WSL2 doesn't require the full Hyper-V feature, the "Virtual Machine Platform" that enables WSL2 is really a subset of Hyper-V. My understanding (and experience) has always been that, because of this, enabling WSL2 / Virtual Machine Platform will cause issues with other VM technologies, unless they support nested virtualization. – NotTheDr01ds Oct 12 '21 at 00:56
  • @NotTheDr01ds - I am 1,000,000% sure, WSL2 absolutely does NOT require Hyper-V to be enabled. The author indicated they had installed Hyper-V – Ramhound Oct 12 '21 at 01:01
  • 2
    @Ramhound Perhaps we're getting hung up on wording. I agree that the Windows feature named "Hyper-V" does not have to be enabled in order to run WSL2. However, turning on the Virtual Machine Platform for WSL2 does enable a subset of Hyper-V which will cause issues with other virtualization tools. See ["The newest version of WSL uses Hyper-V architecture to enable its virtualization. This architecture will be available in the 'Virtual Machine Platform' optional component."](https://docs.microsoft.com/en-us/windows/wsl/faq#does-wsl-2-use-hyper-v--will-it-be-available-on-windows-10-home-). – NotTheDr01ds Oct 12 '21 at 06:02
  • 1
    @Ramhound Also see ["Some 3rd party applications cannot work when Hyper-V is in use, which means they will not be able to run when WSL 2 is enabled"](https://docs.microsoft.com/en-us/windows/wsl/faq#will-i-be-able-to-run-wsl-2-and-other-3rd-party-virtualization-tools-such-as-vmware--or-virtualbox-). – NotTheDr01ds Oct 12 '21 at 06:02
  • @NotTheDr01ds - I am an engineer by trade. If you say something requires Hyper-V when it doesn’t I will correct that fact. I knew HAXM didn’t support Hyper-V which is why I suggested it be disabled. Wasn’t aware it was incompatible with Virtual Machine Platform. – Ramhound Oct 12 '21 at 12:26

1 Answers1

5

So, if I disable Hyper-V completely, then install HAXM (Android Studio), then install WSL2 (this will enable Hyper-V), what happens? HAXM fails to work properly?

That is my understanding, yes.

The "Virtual Machine Platform" and the WSL kernel are the two key components that have to be provided in order to enable WSL2. As you are aware, the Virtual Machine Platform for WSL2, "uses Hyper-V architecture to enable its virtualization.". And "Some 3rd party applications cannot work when Hyper-V is in use, which means they will not be able to run when WSL 2 is enabled, such as VMware and VirtualBox."

That is, of course, also true for HAXM. "In order to install HAXM properly, both Hyper-V and WSL2 features have to be disabled."

Up to this point, I think I'm just recapping what you already know, since there seemed to be some confusion on the topic in the comments.

But to get back to your question, because Hyper-V (even in its WSL2 subset) is a Type 1 Hypervisor, it runs before Windows even starts. Once it is enabled, Windows runs on top of Hyper-V rather than the other way around.

So yes, once you turn back on the Virtual Machine Platform and reboot, HAXM will no longer run. There's no way for a Type 2 hypervisor to "win the race", since the Type 1 will always start first.

Note that some virtualization technologies support Nested Virtualization and can now run alongside (on top of) Hyper-V and/or WSL2's VMP. VMWare, VirtualBox, and KVM all have nested virtualization enabled now.

Unfortunately, it seems from that Github issue that HAXM is not one of them, and the issue was closed without any seeming intent to add that feature.

NotTheDr01ds
  • 17,574
  • 4
  • 44
  • 81
  • 5
    There's probably no real reason for Android Studio to *need* HAXM nowadays – I recall its emulator was Qemu-based, and Qemu did in fact receive a MS HV backend a few years ago (alongside HAXM, KVM, and others). – u1686_grawity Oct 12 '21 at 08:20
  • Well the truth is, you can use WSA, now that you have WSL2 anyway. WSA works with Android Studio without problem, at least in my case. – Xiao-Feng Li Jun 16 '22 at 23:22