Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VMware compatibility with WSL2 (should raise awareness of limitations) #1820

Open
polarathene opened this issue Sep 24, 2023 · 3 comments
Open
Assignees

Comments

@polarathene
Copy link

polarathene commented Sep 24, 2023

Documentation Issue

UPDATE:

  • In my case I had been configuring VMs with non-default settings, notably CPU features enabled (as shown at the end of this post), that are not compatible with Hyper-V VBS (which WSL2 enables?).
  • Additionally existing VM guests with those features enabled cannot be resumed from a suspended state when changing between VMware modes traditional and host VBS (shutdown VM first and disable the CPU features).

The current docs for WSL2 don't indicate either concern, which introduces a bad first impression + a poor UX which can be frustrating to troubleshoot. It would be a more positive experience to such users if the documentation could give a heads-up so that enabling WSL2 does not feel so disruptive (with various errors for VMware usage).


Note
WSL 2 will work with VMware 15.5.5+ and VirtualBox 6+. Learn more in our FAQs.
Source

For those using VirtualBox, you may need to consider the version that you are running and whether it is compatible with WSL 2. (See WSL GitHub repository issue 798 for the full discussion. It appears that VirtualBox v6.1.16 works well with WSL 2, but that other versions may experience issues.)
Source

Similar caveat for VMware might be relevant?

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.
However, recently both VirtualBox and VMware have released versions that support Hyper-V and WSL2. Learn more about VirtualBox's changes here and VMware's changes here.
For troubleshooting issues, take a look at the VirtualBox issue discussions in the WSL repo on GitHub.
Source

  • "recently" may be inaccurate if this was referring to 2020.
  • "support" is also not seamless (at least with VMware) as described earlier.

It'd be helpful to clarify this restricted compatibility upfront, I had checked the docs prior to installing WSL2, which implied I could still access my VMWare guests without configuration changes. If I had known in advance it would have been easier to prepare for, instead of the added friction imposed after enabling Hyper-V / WSL2.

Make sure that the hypervisor launch is enabled in your boot configuration. You can validate this by running (elevated powershell):
bcdedit /enum | findstr -i hypervisorlaunchtype
If you see hypervisorlaunchtype Off, then the hypervisor is disabled. To enable it run in an elevated powershell:
bcdedit /set hypervisorlaunchtype Auto

Additionally, if you have 3rd party hypervisors installed (Such as VMware or VirtualBox) then please ensure you have these on the latest versions which can support HyperV (VMware 15.5.5+ and VirtualBox 6+) or are turned off.
Source

$ bcdedit /enum | findstr -i hypervisorlaunchtype
hypervisorlaunchtype    Auto

VMware Workstation Player 17.x (installed prior to WSL2).


Additional Context:

  • If I set the hypervisorlaunchtype to auto, WSL can run but VMware cannot run my Win 11 virtual machine and report my platform does not support virtualized amd-v/rvi.
  • If I set the hypervisorlaunchtype to off, my Win 11 virtual machine can run but WSL can't.
    Source

Advice for basic workaround to switch between the two.


A user recently referenced a SuperUser answer:

When WSL2 is enabled, the "Virtual Machine Platform" feature is turned on in Windows.

This is a subset of Hyper-V functionality, which enables a type 1 hypervisor.
Once this is enabled, Windows itself is actually running inside the hypervisor.

As a result, VMWare is a "nested" (type 2) hypervisor attempting to run inside the VMP type 1 hypervisor.
In order for this to work, you'll need all of the components involved to support the Nested Virtualization feature.


When Hyper-V is enabled on the Windows host, the hypervisor is running at ring 3 while without it, the hypervisor runs at ring 0.
So it is expected to be slower as there are additional layers of software (the WHP API and so on) before it gets to the CPU virtualisation features.

With version 16, you will also get a warning about disabling mitigations when the ULM is detected.
To disable mitigations, change the side channel mitigations setting in the advanced panel of the virtual machine settings. Refer to VMware KB article 79832 at https://kb.vmware.com/s/article/79832 for more details.
The advanced options mentioned in KB79832 is not available in Workstation Player. You can add the following line to the vmx: ulm.disableMitigations="TRUE"
Source

Above provides more technical insight on different context + ULM mitigation (impact would vary by HW).

Additional advice on steps to revert Windows virtualization features to restore previous usable VMware experience (deactivate WSL, VBS (via group policy?), VMP (link advises)).

Link to documentation page

From quoted sources above:

In fairness, VMware hasn't updated their own docs since 2020Q2, only stating support for VMware Workstation 15.x, as if to imply anything newer is also unsupported 🤷‍♂️

  • This sub-article on the topic also suggests that VMware Workstation is compatible with Hyper-V host with VT-x / AMD-V, but that is not the case (at least on Windows Home).

Suggested Improvements

VMware and VirtualBox are referenced in docs together, and direct users to a rather long issue (382 comments) from July 2020 at: #798

There's likely too much noise built up over time in that thread. It may be wiser to have two separate issues in 2023 for WSL2 2.0.0 going forward, one for VirtualBox and another for VMware?

It seems to be the preferred approach to delegate information to a Github issue than refine the docs content on the subject presumably?


I'd like to request an improvement on the actual docs that at least clarify the situation with VMware support.

In the "Virtual Machine Settings" window for a guest, the CPU section has two checkboxes in the "Virtualization Engine" subsection. Neither can be enabled when WSL2 / Hyper-V is active:

image

This can impact performance, which the VMware docs "Limitations of Host VBS mode" also notes performance will be degraded. VMware will prompt awareness about mitigations also being applied when attempting to run in a nested context and that it'll affect performance further.

Similar reports on performance becoming abysmal is noted for VirtualBox in it's dedicated issue.

Similar request for clarification on compatibility to be documented for VirtualBox (can work without certain features and reduced performance): #1807 (comment)

@absinthewww
Copy link

I've been having issues with VMs on my laptop for months and months. Specifically, they will freeze, hang, mess up resuming, especially after I have put my laptop on sleep and then opened it again. I thought it was my laptop doing some weird power management stuff, but I realised that it only happens when WSL2 is on.

It has to have something to do with all this compatibility stuff. It's ridiculous tbh, WSL2 + VM was sold as seamless but there are all these issues years on.

@craigloewen-msft
Copy link
Collaborator

@polarathene is your request here to update the WSL docs to include information on how to run it with VMware to make it compatible? Our goal on the docs is to keep it to WSL specific information. WSL relies on Hyper-V, and VMware has support for Hyper-V our recommendation is that any VMware set up information should be found on the VMware docs.

@polarathene
Copy link
Author

TL;DR: Installing WSL2 prevents access to existing VMware guests (configured with VT-x / AMD-V).

  • The user must uninstall WSL2 or accept data loss by discarding suspended VM guest state, otherwise the VM will not run.
  • WSL2 docs should not mislead the reader, this caveat should be explicitly documented.

@polarathene is your request here to update the WSL docs to include information on how to run it with VMware to make it compatible?

My request is to warn the reader that enabling WSL2 as documented may prevent access to their existing VMs.

I have detailed the issues in the original post above, but effectively following the WSL2 docs:

  • An existing VMware guest may be configured with features that are not compatible with ULM / VBS mode, that prevents them starting.
  • Bigger frustration is suspended VMs. You cannot access these without:
    • Throwing away the suspended state.
    • Alternatively, reverting the WSL2 installation to resume the VM guest and save anything necessary so that it can be shutdown without data loss and reconfigured.

WSL relies on Hyper-V, and VMware has support for Hyper-V

I am aware. That link you provided is in my original message (from a quote of the current WSL2 docs).

This does not mean a user with VMware is going to have a smooth experience when they enable WSL2 and later discover that they have to stop what they're doing and backup WSL2 work to restore later, so that they can uninstall WSL2 to backup the incompatible VM guests.

If they were warned in advance from WSL2 docs, instead of being mislead that VMware is compatible (as if no friction would be introduced preventing access to existing VMs), this would have been a much more positive experience for the user.


Regardless, even if the user is aware of the limitations of the Hyper-V compatible mode, due to those limitations performance of the VM guests suffers.

For a casual user who doesn't enable the virtualization performance features, they're none the wiser, but this is fairly standard. It's the same virtualization features that WSL2 wants.

So yes, VMware guests can be configured to work with WSL2 installed, but it's not without drawbacks.

WSL2 experience (drawbacks)

My primary interest in WSL2 was curiosity as I have run Linux as a daily driver. My VMware guest running Linux was working well and I used it with Docker, I was curious to try Docker Desktop on Windows and that required WSL2 too.

WSL2 has some convenience, but depending on workload the resource usage can be quite problematic, especially in low-disk space scenarios where WSL2 poses a risk. I would still endorse a VM guest given all the issues and friction experienced with WSL2.

Additionally, my experience with WSL2 was:

  • High memory usage based on disk I/O. Building a project that would require little memory but write 3GB would raise memory usage to a similar amount for quite a while even after the build was done. It would slowly be released unless shutting the WSL2 instance down.
  • Memory usage in WSL2 would also carry over into similar disk usage. Which like the memory allocation, would be released with the same pattern.
  • There is the new VHD sparse feature, but it's still not quite right with Docker Desktop. Something is going on with that integration would still accumulate disk space and require the GUI to explicitly purge the WSL2 data volume, as the cleanup CLI commands would not cover whatever WSL2 specific storage management was happening there. It is known to be resolved with export + import of the data vdisk (earlier detailed comment).
  • If the host disk runs out of space because of these WSL2 operations, WSL2 becomes unresponsive until a system reboot. You cannot shut it down. Likewise this locks memory usage (which will slowly dissipate still, but you cannot kill the related process), quite problematic since WSL2 is the source of the disk bloat (especially with the memory + disk I/O buffer using up actual disk).
Off-topic - Windows corruption

I have features of Windows that no longer work. For example:

$ powercfg /batteryreport /output battery_report.html
The Power Efficiency Diagnostic library (energy.dll) could not be loaded.

I'm inclined to believe the out of disk space events were related to that, causing some corruption (related commands for windows diagnostics to scan/repair corrupted data it manages fails). However, that could be due to something else as Windows on this laptop has encountered various problems over the past 6 months related to graphics drivers, forced updates (Windows or vendor firmware), power management, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants