-
Notifications
You must be signed in to change notification settings - Fork 822
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
Nested Virtualization for WSL2 VM #4193
Comments
You can get Hyper-V VM ID with |
Hi Biswa96 yes I will try and make it like Inception WIn10 -> wsl(VM) -> KVM -> OSX->Parrallels->Win10 :) |
I am interested in this as well. Is there any way to enable ExposeVirtualizationExtensions for the Hyper-V instance running WSL2? |
Well my main desktop rig has been rebuilt around ryzen 3600. Unfortunately, windows does not support nested virtualization in any form for and processors. So it seems a linux Kvm host as the base operating system is required now. You can enable nested in kvm and have osx and windows 10 SMS with pic box pass through which is almost natively Experiance. However you need two graphics cards. 1 for linux and 1 for your vm. |
This would be very useful to have, that way I don't have to have two separate Linux VMs (WSL2 + my GNS3 VM). Please enable this feature as it's already built into Hyper-V. |
Is there any comment on if and when this will be a thing? It's kind of a requirement for WSL2 to be actually useful, not being able to run VMs with KVM for hardware acceleration in 2019 is a bit.. concerning. I used WSL1 and it topped out being useful at letting me type Linux commands as it used to have all manner of port issues, restrictions, slowdowns and the like. WSL2 might be faster with I/O but VMs are a CORE REQUIREMENT of any remotely professional setup. If Microsoft want people to use Windows with WSL2 as a host operating system, WSL2 must support KVM or there needs to be another non-Intel way to get hardware virtualization working. |
Technically there's already everything in place for it to work. If someone wants to play with this right now with an insider build:
Point 1) in Microsofts upstream kernel might lead to a bit of discussion, but with both |
Yep, they just need to enable the "ExposeVirtualizationExtensions" feature as it's only available to Hyper-V machines that are in the Hyper-V manager. Since the WSL2 VM does not have a name, we can't apply it. |
@scottjoshuac |
What I'd like to do, and so which requires the WSL 2 isolated VM to be started every time with the Basically, I'm looking for the GUI desktop support of Windows, with the *nix support of WSL in Windows Terminal; as an alternative to MacOS. This has been working okay, until I try to get Minikube to run within the Hyper-V VM that is WSL 2; which it can't of course. Adding the parameter seems to be a no brainer, it's already there in the technology so there's not really any dev time needed, just testing, although I can see how having a VM running in the background when you kill your terminal session might prove to be a bit of a headache to handle though. The other point about AMD support is valid too, we need to see this support coming through as well, especially given AMD's current acendency in desktop and laptops. |
So, I got fed up with this situation today and decided to install Ubuntu in a Hyper-V VM with the And so my point from above, turning this on works and so it would be much more helpful if it was enabled for WSL 2.0, either by default or as a configurable, because then I wouldn't have to roll my own VM and add the flag manually. It's just the little additional touches which will make this so much more user focused. |
@steffengy how do you intercept creation and set |
@offlinehacker Sure, it's not very user-friendly though: https://gist.github.com/steffengy/62a0b5baa124830a4b0fe4334ccc2606 |
There are some changes in WSL2 Linux kernel repo with v4.19.104. The config files has some KVM features enabled. So, one may compile the kernel now and try it. No hacky step required. |
@Biswa96 seems like it, though I'd argue that the hacky step is not compiling the kernel but fiddling with HCS. |
HCS (Hyper-V Compute System) APIs isn't fully** documented for WSL2. But compiling Linux kernel is. ** but it can be found in Windows SDK. And also Docker Desktop uses it. |
@Biswa96 Except that using the HCS API doesn't help here. You currently have to interfere with how LxssManager interacts with HCS and due to LxssManager being a protected process you have to do a lot of hackery (as shown in the GIST) to intercept API calls in HCS internals, which is entirely undocumented besides debug symbols. So yeah building the kernel in anycase is the very very easy part. |
@steffengy Thank you for sharing. Ok i tried windbg script, but on my build of windows 19041.81, i do not get Which build of windows are you running? This method is really hacked up, but i kind of expected that you need to hook dll methods, what else to expect in windows. |
@offlinehacker |
@steffengy I have modified your script and managed to get it work. Don't need two step process anymore, directly read, parse, modify and write memory. https://gist.github.com/offlinehacker/4d48f46fdcd64c9a24e3952c69bfcd09 |
@offlinehacker Great that you enjoy it, I updated the gist above with your changes. :) |
@steffengy and @offlinehacker thanks for sharing this! I may switch back to Windows now... Although I'm getting used to Linux as my primary and have Wine running the only Windows app I "need" (League of Legends) so it's a tough choice! |
I am always using Linux for development, windows was just a gateway drug, as I want to have portable dev environment, that also runs in hyper-v 😅 Just look at ridiculous hacks we need to do, to change a json string passing from one service to other, where in Linux it would be 5 minute fix. Microsoft has done a lot for open source in last years, but as long as windows will not be more open, it is too rigid platform for a lot of developers. |
@steffengy thanks for updating gist 🙂 |
There's gotta be a better way to keep my wsl2 up to date rather than converting my entire OS (that's already pretty established) to a new insider ring, etc. Can I just download a new package of WSL2 somewhere? |
I can confirm this works in Win 11. I created a hyperv VM on my Windows 10 with |
Intel or AMD ? |
@crramirez : Intel (edited my comment) |
Hello, I tested with Windows 11 released version and the latest kernel update (not the WSL Store Preview) and I can confirm that the nested virtualization for AMD is enabled and working by default. The kvm_amd module is included in the kernel and started with nested=1. I tested it using livemedia-creator with qemu and the time to process dropped by half when yesterday I upgraded from Windows 10 to 11. Regards |
I also got this far. For future people if you also got this far try enabling Windows Hypervisor Platform.
After enabling Windows Hypervisor platform I finally got
|
I have AMD 4800H, windows 11 21h2 (22000.856), wsl kernel 5.10.102.1-microsoft-standard-WSL2
nested virtualization NOT working, Qemu is very slow |
How enable nested virtualization/KVm at Window 10 22H1/22H2 ? THX |
Dear Sir Do you use Windows 10 22H1/22H2 ? it can run https://github.com/budtmo/docker-android ? THX |
I have not used it in a while. |
@startergo & all as this post https://learn.microsoft.com/zh-tw/windows/wsl/wsl-config the ms still disable "nestedVirtualization" at win10 the laste version WSL (download from store) at Win11 it can run nestedVirtualization at win10 still not work PS C:\Users\Lan> wsl --version WinDbg PreView error log (dd0.17ac): Break instruction exception - code 80000003 (first chance) THX |
@CMingTseng, by any chance do you have an AMD processor? Because nested virtualization with AMD is not supported at all in Windows 10 |
Indeed, the WinDBG hack still works on Windows 10, but only if you don't update wsl. In short, if
Then the WinDBG hack should work as expected! |
So I'm getting very slow performance using libvirt inside WSL. It is using nested virtualization. But still its slow, especially loading of grub, the loading kernel, loading initrd steps. Do others encountered similar issues?
I'm running a simple debian image: debian-12-genericcloud-amd64.qcow2 |
hey @sarim , What kind of hardware is this running on? That's just from a quick glance through your supplied log. Hopefully that can be helpful. Other then that, I currently don't have the time/resources to validate your report. If anyone else can jump in to see wether this is reproducible? |
@Simbaclaws Thanks for taking a look. The cpu is AMD Ryzen 7 3700X. It has full support for virtualization. Ouput of lscpu from wsl.
|
perhaps some specific flags for acceleration are missing. you can use this stackoverflow answer to do a quick test what is and is not supported by your cpu: not sure if that could yield any potential results. you'll probably want to enable all flags for your cpu model in order to get better performance. |
@Simbaclaws I'm already using cpu mode=host-passthrough in libvirt. So it already has all the flags of host cpu. So I don't think it would yield any beneficial result :/ |
Do you run WSL2 at WIn11 ? or WIn 10 THX |
you're right, host-passthrough should already do those things. what about trying to get the cgroup backends available? Perhaps you need cgroups v2. Maybe have a look here? |
so we can not upgrade WSL2 version ? THX |
At WIndows 10 use the WSL2 (kernel version 5.15.79.1 ) How Pass ExposeVirtualizationExtensions to the utility VM and boot a different kernel. ? THX |
@CMingTseng windows 11. you can see my windows version in wsl --version output. @Simbaclaws I actually already have cgroups v2 enabled. kernel command line to disable cgroupsv1 and mount cgroupsv2. I use it to use podman. |
I'm kind of running out of ideas at this point. I do see the error message in your log saying it's missing the cgroup backend, but honestly don't know whether fixing it would yield better performance or not. Hopefully someone else can come up with a solution to your problem. I can not reproduce this right now since I'm on vacation. |
@Simbaclaws Thanks for taking a look. But I suspect It could be bug with WSL, so I was seeking other people's experience with it. If other people's VM's are running fast, then it would be plausible to debug my configuration. |
Correct! Thanks for the input. So, after applying the above version downgrade the WinDbg hack works. |
Greetings,
I am trying to do
Set-VMProcessor -VMName -ExposeVirtualizationExtensions $true
On the wsl2vm itself so I can use KVM inside it.
However, I cannot do that, and I don't know why Get-VM does not see the wsl2vm so I cannot expose these vars.
how do I do it?
The text was updated successfully, but these errors were encountered: