News for hackers. Stuff that matters.
Re:Microsoft submits Linux kernel patches to enable complete... by selsta on Wednesday September 16, 2020 @05:54AM (#24491114)
WSL2 is a simple virtual machine. Nothing you couldn’t do on macOS with e.g. multipass.
Re:Microsoft submits Linux kernel patches to enable complete... by mtzet on Wednesday September 16, 2020 @06:09AM (#24491206)
Not really. Under HyperV both the Windows and Linux kernel run subsidiary to the HyperV hypervisor, so in that sense Windows itself is "just a virtual machine".

The work in TFA describes patches to make the Linux kernel communicate with the hypervisor (sharing information like used memory pages). In my book that's pretty sophisticated.

EDIT: The work appears to be available on Github https://github.com/microsoft/WSL2-Linux-Kernel/commits/linux...

Re:Microsoft submits Linux kernel patches to enable complete... by AshamedCaptain on Wednesday September 16, 2020 @06:17AM (#24491228)
It doesn't matter how the hypervisor is arranged, but it is still just a virtual machine. Just because it happens to run on a type1 vs type2 hypervisor means not much, or just go ask around whether Xen is any faster than KVM these days.
Re:Microsoft submits Linux kernel patches to enable complete... by danieldk on Wednesday September 16, 2020 @06:22AM (#24491246)
But the filesystem integration is much better than a VM in macOS, being able to run Window programs from Linux, etc.

Also, Windows has decent X11 servers that work well with retina displays, which can't be said of XQuartz.

Re:Microsoft submits Linux kernel patches to enable complete... by tremon on Wednesday September 16, 2020 @07:50AM (#24491693)
The filesystem integration is not without flaws though, it doesn't seem to implement full posix semantics.

Many times in WSL2 I've had a git rebase fail because it couldn't overwrite existing files, and every time it could be fixed by just running git rebase --continue. The actual problem seems to be that WSL2 system calls return before the NTFS operation completes, so quick successions of create-after-unlink or write-after-rename can have unexpected results.

For this reason I still keep a WSL1 environment, it doesn't have the same issues (and doesn't appear to be any slower for filesystem operations).

Re:Microsoft submits Linux kernel patches to enable complete... by Filligree on Wednesday September 16, 2020 @09:11AM (#24492347)
> For this reason I still keep a WSL1 environment, it doesn't have the same issues (and doesn't appear to be any slower for filesystem operations).

It's definitely a great deal slower for filesystem operations inside the Linux system. Filesystem operations outside the VM's disk image go through 9p, which gives you basically the same performance for both.

Re:Microsoft submits Linux kernel patches to enable complete... by AshamedCaptain on Wednesday September 16, 2020 @06:41AM (#24491319)
"Windows programs for Linux"? It doesn't really have any better filesystem integration. The filesystem is stored on a disk image on WSL2 as on any other VM. You can mount other host filesystems from inside the VM in any hypervisor I know of.

Ack on XQuartz being crap (thought it does have Retina support these days, at least for non-rootless mode), but this is not really a problem of the VM.

Re:Microsoft submits Linux kernel patches to enable complete... by skinkestek on Wednesday September 16, 2020 @06:53AM (#24491368)
It works so crazy well that sometimes it works and then I stop and think: how did that work.

Example: I type code ./somefolder in WSL and it opens VSCode on Windows, editing the folder I specified.

Edit: danieldk replied just before me, but I think my answer adds to that instead of just duplicating danieldks.

Also danieldks answer highlights something important: it doesn't seem to be just magic shell wrappers (or if it is they are truly magic).

VSCode is somewhat special when it comes to editing files, Notepad is not.

Re:Microsoft submits Linux kernel patches to enable complete... by danieldk on Wednesday September 16, 2020 @06:50AM (#24491355)
"Windows programs for Linux"?

Whoops, typo. Windows programs from Linux, I'll fix that.

You can mount other host filesystems from inside the VM in any hypervisor I know of.

In most hypervisors you can't do a

  notepad.exe foo.txt
or

  TextEdit.app foo.txt
for that matter in a Linux VM,
Re:Microsoft submits Linux kernel patches to enable complete... by microcolonel on Wednesday September 16, 2020 @08:48AM (#24492126)
With virtio-fs I think this is becoming more doable. Of course, it's not quite as fast as running a guest filesystem on virtio-blk yet, but maybe it'll get there.
Re:Microsoft submits Linux kernel patches to enable complete... by fomine3 on Friday September 18, 2020 @12:12AM (#24512921)
WSL can run `notepad.exe foo` from bash. Not only fs integration.
Re:Microsoft submits Linux kernel patches to enable complete... by microcolonel on Friday September 18, 2020 @09:42AM (#24516654)
> WSL can run `notepad.exe foo` from bash.

Isn't that just a binary loader, like you can do with wine/qemu on any Linux? Surely it's mostly just proxying the pipes, replicating the working directory, and maybe keeping some of the environment variables. The filesystem integration seems like the trickiest part of that altogether.

Re:Microsoft submits Linux kernel patches to enable complete... by dboreham on Wednesday September 16, 2020 @10:40AM (#24493137)
Also networking. e.g. you can spin up a Node.js server in Linux then connect to it with Chrome on Windows at http://localhost
Re:Microsoft submits Linux kernel patches to enable complete... by Diggsey on Wednesday September 16, 2020 @07:51AM (#24491702)
It's really not. With WSL2 the kernel runs in a VM, but user-space programs do not. As a result, CPU-bound programs suffer close to zero overhead compared to running natively on linux.

AFAIK, there's no way to achieve anything like this on macOS.

Re:Microsoft submits Linux kernel patches to enable complete... by crumbshot on Wednesday September 16, 2020 @08:25AM (#24491912)
That is not quite correct, it is in WSL1 that they are NT processes, with Linux syscall emulation.

But in WSL2 the whole thing runs in a Hyper-V VM, with a customised Linux kernel (available via http://linux.microsoft.com) to help with interoperability between WSL and Windows.

Re:Microsoft submits Linux kernel patches to enable complete... by qalmakka on Wednesday September 16, 2020 @08:56AM (#24492196)
You got it completely wrong. WSL1 was a system call translation layer, and everything worked directly on the Windows kernel, like Windows programs do under WINE. WSL2 is an standard Hyper-V virtual machine, no more no less, with a custom Linux kernel build and a ext4 root filesystem stored in a .vhdx image. Every process runs as a native Linux process under the Microsoft's Linux kernel, _inside_ the VM. What makes it more convenient than simply opening the Hyper-V manager and creating a VM is ease of installation, maintenance and integration with Windows (using the 9p protocol to allow file access).
Re:Microsoft submits Linux kernel patches to enable complete... by withinboredom on Wednesday September 16, 2020 @09:30AM (#24492505)
And you got it all wrong :p. It’s not a “standard Hyper-V virtual machine” you can’t make one from scratch.
Re:Microsoft submits Linux kernel patches to enable complete... by qalmakka on Wednesday September 16, 2020 @11:34AM (#24493652)
With "standard Hyper-V virtual machine" I mean that's like every other VM, because it runs under its own instance of vmwp.exe, spawned by vmms.exe, like every other one you may have in the system.
Re:Microsoft submits Linux kernel patches to enable complete... by withinboredom on Wednesday September 16, 2020 @12:41PM (#24494379)
Now I want to take those executables apart and see if it does any special handling.
Re:Microsoft submits Linux kernel patches to enable complete... by Sangeppato on Wednesday September 16, 2020 @08:12AM (#24491832)
Do you have any source/documentation for this? I'd really like to read more about it, my understanding has always been that WSL2 was more or less a classic VM on a type-1 hypervisor (Hyper-V)
Re:Microsoft submits Linux kernel patches to enable complete... by tilolebo on Wednesday September 16, 2020 @06:37AM (#24491306)
WSL2 is a simple VM like Docker is a simple Linux container.
Re:Microsoft submits Linux kernel patches to enable complete... by withinboredom on Wednesday September 16, 2020 @06:02AM (#24491153)
But it’s not simple. It’s nothing like a “simple” VM.
Re:Microsoft submits Linux kernel patches to enable complete... by Sangeppato on Wednesday September 16, 2020 @06:05AM (#24491176)
It's a headless VM that runs on Hyper-V
Re:Microsoft submits Linux kernel patches to enable complete... by AstralStorm on Wednesday September 16, 2020 @07:05AM (#24491428)
Once Microsoft finishes the work on DXGI for Linux, it won't even have to be headless.

It's also very paravirtualized, which is why HyperV enlightenments are required for WSL2 guest.

Re:Microsoft submits Linux kernel patches to enable complete... by withinboredom on Wednesday September 16, 2020 @07:06AM (#24491433)
Re:Microsoft submits Linux kernel patches to enable complete... by Sangeppato on Wednesday September 16, 2020 @07:15AM (#24491477)
Sure, it has some nice integrations, but I don't see how this article is in contradiction with what I've said. (To be clear, I didn't mean it as a critique, I like Hyper-V)