4 ms·
To this day I wish they'd release decent (i.e. well documented) APIs for creating VMs like this yourself with Hyper-V. I sometimes have to spin a bunch of Windo
by easton 4y ago
To this day I wish they'd release decent (i.e. well documented) APIs for creating VMs like this yourself with Hyper-V. I sometimes have to spin a bunch of Windows VMs for testing, and if they could dynamically release RAM and CPU when they aren't using it it would be amazing. They have something like it with Windows Sandbox but you can only spin one at a time.
- fassssst 4y agoThere are PowerShell functions for creating VM’s.
- sebazzz 4y agoThat's not what OP meant. OP meant interfacing with Hyper-V from inside the VM. Things like dynamic memory allocation and release aren't some kind of black magic, but are something that is actually directly communicated by the guest VM.
- GordonS 4y agoHyper-V does support memory ballooning (dynamic memory allocation from host to VM) - is that what you mean, or do I misunderstand? This does need support in the guest VM, but I've only ever had issues with really old Linux distros.
- easton 4y agoMy comment was really kind of inaccurate, the difference isn't the memory ballooning, it's the special way WSL2 is able to interact with the host. It frees memory much better than normal Hyper-V VMs, and boots way faster than a regular Ubuntu VM. Microsoft implemented a Firecracker style microVM (they call it "Krypton") for Hyper-V, which is used for WSL2, Edge Application Guard (run Edge in a VM), and Windows Sandbox. There aren't any real good docs on how to create one yourself using the Host Compute Service.
- GordonS 4y agoThat makes sense, thanks for explaining!
- kritr 4y agoTo add to this a little bit. There is deeper host side integration for these applications and the VM’s are virtual address backed (the guest vm’s memory is represented as a process on the host), which adds more opportunities to free up physical memory. The windows sandbox architecture page covers some of this. https://learn.microsoft.com/en-us/windows/security/threat-protection/windows-sandbox/windows-sandbox-architecture https://learn.microsoft.com/en-us/windows/security/threat-pr... Also WSL2, if I recall correctly, has a relatively minimal base OS with a custom init binary. I would say if you’re looking to use Host Compute Service, your best option would be to look at the way https://github.com/microsoft/hcsshim https://github.com/microsoft/hcsshim initializes containers.