Show HN: Vmctl/Vmcli – Easily Run Linux VMs on M1 Macs

by gyf304on 1/15/21, 3:26 AMwith 28 comments
by gyf304on 1/15/21, 3:27 AM

I recently got myself a M1 Mac and I want to run Linux on it. By reading the docker M1 tech preview release (https://www.docker.com/blog/download-and-try-the-tech-previe...), I was made aware of the existence of Virtualization.framework on recent macOS releases.

Virtualization.framework provides 99% of the building blocks for running a Linux VM on a Mac, but there’s no off-the-shelf CLI for running a VM.

Inspired by https://github.com/evansm7/vftool, I wrote another CLI (vmcli) with some more features (better termios handling / escape sequence detection) in Swift, and build a script (vmctl) to daemon-ize vmcli and help manage VMs. I also made a script for provisioning a Ubuntu VM, so you can run a Ubuntu VM from scratch in minutes.

by borison 1/15/21, 6:54 AM

Here is a previous discussion of a similar tool that also lists some of the limitations (like inability to use bridged networking without Apple's permission) of using Virtualization.framework: https://news.ycombinator.com/item?id=25382529

I am personally more interested in tools that are based on Hypervisor.framework (which as I understand offers lower-level support for virtualization). Anyone knows what is the current state of Qemu support for M1 (last time I heard there were some out-of-tree patches)?

by ulzerajon 1/15/21, 4:16 AM

This is cool. Definitely going to test it. Years ago I’ve looked into something like this but found only find xhyve which looked a bit crude.

Ended using Parallels Desktop Lite which to my understanding is a GUI to VF. Used to be free for Linux VMs then they’ve changed to yearly subscriptions. And they charge premium for a year of their glorified virt-manager.

To make things worse their 1 year subscription is blocking me from changing countries on app store. I hate that company to guts now.

by e12eon 1/15/21, 10:46 AM

So looking at: https://developer.apple.com/documentation/virtualization I see that the host supports virtio for providing devices - but this is a hypervisor, not an emulator? You can't run amd64 VMs on m1 and vice-versa? Is there a "standard" 64bit arm target that means pre-built VMs are available? It should also be possible to run windows arm VMs?

by prime31on 1/15/21, 6:29 PM

For those looking for a UI and full desktop environment UTM has full support for the M1 now: https://github.com/utmapp/UTM

by 6a74on 1/15/21, 7:11 AM

Wow. This is fantastic. I had no idea Virtualization.framework was a thing. I've installed and tested vmctl/vmcli out on my M1 MacBook Air. Your instructions worked like a charm.

Edit: I don't see the option to list running VMs though. I was hoping to check that powering off the VM worked. The inability to ping the VM tells me it is off, but if I didn't have the IP, I don't know how I would check this.

by stephenron 1/15/21, 8:48 PM

I wonder how practical it would be to implement a vagrant provider on top of this.

Has anyone tried running this on an intel Mac?

by GEBBLon 1/15/21, 1:09 PM

Thank you so much. I bit the bullet and bought an M1 Mac but I’ve been really missing a Linux VM for hackthebox etc and was having to route through a Dropbox droplet. This should solve my issue

by amedvednikovon 1/15/21, 8:41 AM

Amazing, thank you! Looks much cleaner than virtualbox. I assume the performance is much better as well.

Any way to build it without installing xcode, just with xcode command line tools?

by proyb2on 1/15/21, 5:16 PM

A quick benchmark, Vmctl has fare slight lower/better latencies than Parallels.