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

Provider: utm qemu libvirt #2468

Open
georgestephanis opened this issue May 20, 2021 · 16 comments
Open

Provider: utm qemu libvirt #2468

georgestephanis opened this issue May 20, 2021 · 16 comments

Comments

@georgestephanis
Copy link

Was chatting with @evertiro in slack about this, logging some potentially useful links -- to the best of my knowledge, all linked projects here are free and open source.

UTM can run virtual machines beautifully on the M1 Macs using hypervisor -- https://mac.getutm.app/ -- it also has a version that runs on iPhones and iPads, but that's less salient to our purposes. https://github.com/utmapp/UTM/

There's been some questions on their repository about adding support for Vagrant:

utmapp/UTM#2496

with some planned changes that may make it more doable:

utmapp/UTM#2280

but it is noted there that UTM is largely a wrapper about QEMU.

UTM recently added some functionality to allow exporting the QEMU arguments out of UTM, if it simplifies anyone's workflow when doing initial explorations: utmapp/UTM@48a8fc7

QEMU -- https://www.qemu.org/ -- https://gitlab.com/qemu-project/qemu/ -- is a generic and open source machine emulator and virtualizer.

libvirt -- https://libvirt.org/ -- also works as a wrapper around qemu, and reportedly runs just fine on apple silicon! https://doesitarm.com/formula/libvirt/

It also has a vagrant provider: https://github.com/vagrant-libvirt/vagrant-libvirt

Anyway, just wanted to dump some starting points and research here for some assorted ways we could get VVV running smoothly on Apple Silicon with open source tools.

@welcome
Copy link

welcome bot commented May 20, 2021

Thanks for opening your first issue here! Be sure to follow the issue template and include your OS/Vagrant/VVV versions! Don't forget you can get support in the VVV slack at https://varyingvagrantvagrants.org/docs/en-US/slack/

VVV
Join the VVV Slack Workspace

@evertiro evertiro self-assigned this May 20, 2021
@evertiro evertiro changed the title Apple Silicon / M1 / utm qemu libvirt Provider: utm qemu libvirt May 20, 2021
@georgestephanis
Copy link
Author

georgestephanis commented May 20, 2021

Possibly salient notes from someone else:

https://gist.github.com/aserhat/91c1d5633d395d45dc8e5ab12c6b4767

Gist
QEMU and HVF. GitHub Gist: instantly share code, notes, and snippets.

@evertiro
Copy link
Contributor

I don't think this is necessarily an M1 or even Mac-specific thing. QEMU/libvirt are available for all three supported operating systems, so if we can make it work this could be our first completely free cross-platform provider. I say it's worth a shot!

@evertiro
Copy link
Contributor

I'd like to point out that libvirt already has a stable vagrant provider. I'd say that's probably the easiest place to start.

@tomjn
Copy link
Member

tomjn commented May 20, 2021

For MacOS we ideally want something using Apples hypervisor, which is what VMWare Docker and Parallels use

@georgestephanis
Copy link
Author

georgestephanis commented May 20, 2021

Based on what research I'd done, it seems qemu does also use hypervisor.

UTM explicitly says it does as well.

UTM employs Apple's Hypervisor virtualization framework to run ARM64 operating systems on Apple Silicon at near native speeds.

and

Under the hood of UTM is QEMU, a decades old, free and open source emulation software that is widely used and actively maintained.

According to https://www.naut.ca/blog/2020/08/26/ubuntu-vm-on-macos-with-libvirt-qemu/:

QEMU on the other hand has had support for Hypervisor.Framework since 2018.

@tomjn
Copy link
Member

tomjn commented May 20, 2021

then we need the following:

  • an arm64 Ubuntu 20 box
  • a provider plugin

This also assumes no efforts towards containerised VVV or native VVV

@tomjn
Copy link
Member

tomjn commented May 20, 2021

This libvirt box looks the most promising at the moment on vagrant clouds box catalog:

https://app.vagrantup.com/travismccollum/boxes/u20_arm64

There's also xhyve, which has been around a while and uses a port of bhyve to interface with Apples hypervisor framework

https://github.com/machyve/xhyve

We would need to build our own box though, and I couldn't find any information in a brief look for Apple Silicon compatibility

Vagrant Cloud by HashiCorp
Vagrant Cloud by HashiCorp
GitHub
xhyve, a lightweight OS X virtualization solution. Contribute to machyve/xhyve development by creating an account on GitHub.

@tomjn
Copy link
Member

tomjn commented May 20, 2021

If someone was willing to roll up their sleeves with xcode and some ruby, they could bypass all of these and build something specific to VVV+MacOS

This issue has a lot of interesting things in it machyve/xhyve#206

@evertiro
Copy link
Contributor

I mean eventually. Though I'm not normally a fan of writing ruby.

@tomjn
Copy link
Member

tomjn commented May 27, 2021

Multipass by canonical may be a viable alternative, it uses Apples hypervisor behind the scenes on MacOS, kvm on linux, and hyper-v on Windows. There's a Vagrant plugin but it hasn't been touched in 14 months.

We would need to figure out our own box system though, or if boxes even make sense for multipass, there's nothing in a search for multipass on vagrant cloud

@GregOriol
Copy link

GregOriol commented Nov 5, 2021

I'm very interested in this: I'd like to run an ubuntu x86 via vagrant on an M1 mac. The guest system runs with UTM/qemu, what is missing is the interaction with vagrant. It would be very useful in that setup because some packages I use inside the vagrant box (which is similar to the production environment) don't have available binaries for ubuntu arm...

@tomjn
Copy link
Member

tomjn commented Apr 8, 2022

It may be possible to build a primitive rigged vagrant plugin by building a VM in UTM that can be downloaded that's preconfigured then using utm:// links but it'll be hacky and probably have a GUI window:

https://github.com/utmapp/UTM/wiki/URL-Scheme-%E2%80%93-Automation-for-UTM-app-&-VMs

Also relevant: utmapp/UTM#3618

Possibly require us to mess with their plist format, it would require a bit of effort but it looks doable. The concern I have is shared/mounted folders may be a pain in the arse to figure out.

What I would like is someone who can do the following:

  • setup a UTM virtual machine on Apple Silicon running headless Ubuntu 20 with 2 or 3 shared folders
  • export that VM somewhere, including any plist files from UTM for inspection

This way we can try to reverse engineer some things and figure stuff out

cc @GregOriol @Mamaduka

@trinitronx
Copy link

trinitronx commented May 23, 2022

@tomjn
Copy link
Member

tomjn commented May 23, 2022

@trinitronx vagrant runs on Apple silicon, I and others have been using M1 type machines with Parallels for months.

If using macOS VM guests (yes, it's possible, but there's some tricks to it... e.g. they need NVRAM, and some magic incantations. It also requires vagrant-libvirt/vagrant-libvirt#1371 (comment).)

VVV uses debian/Ubuntu type VMs, we aren't interested in MacOS guests.

because hashicorp/vagrant#12548.

I don't see much progress here, especially with Vagrant being ported to Golang. Arm64 builds on golang should be significantly easier to get going, and I expect any Arm support vagrant provides to happen there first.

It makes dealing with this that much more difficult as writing a UTM provider for example means writing it in ruby with all the deprecations coming in 2.3 and 2.4, or, writing it in golang and having to wait for 2.3 for limited documentation to be released.


Another primary problem is that if we send users to install VirtualBox they get an installer, run it, reboot, done. But if we send them to install QEMU it's much more difficult. That's why we hoped UTM would resolve the issue. A lot of VVV users are not technical, don't know how to program, and struggle with the most basic aspects of CLI usage.

E.g. if we send users to libvirt.org or just say "you need libvirt" then ¯_(ツ)_/¯ we won't get any users, it's gibberish, years beyond the technical skill of 99% of the users who would need such a provider, making the whole endeavour pointless.

@georgestephanis
Copy link
Author

georgestephanis commented Jan 3, 2023

Just noting that I'd spotted this today as a possible way of letting vagrant use qemu directly as a vagrant plugin

https://github.com/ppggff/vagrant-qemu

GitHub
Use Vagrant to manage machines using QEMU. Test with Apple Silicon / M1 and CentOS aarch64 image - GitHub - ppggff/vagrant-qemu: Use Vagrant to manage machines using QEMU. Test with Apple Silicon /...

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

No branches or pull requests

5 participants