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

Add support to macOS Virtualization Framework #1757

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

laozc
Copy link

@laozc laozc commented Aug 3, 2023

This PR allows vagrant-libvirt to work with brew installed libvirt/QEMU with user networking.
Verified on Apple M2.

Vagrant.configure("2") do |config|
  config.vm.box = "ppggff/centos-7-aarch64-2009-4K"

  config.vm.provider "libvirt" do |virt|
    virt.driver = 'hvf'
    virt.loader = '/opt/homebrew/share/qemu/edk2-aarch64-code.fd'
    virt.nvram_template = '/opt/homebrew/share/qemu/edk2-arm-vars.fd'
    virt.nvram = "#{Dir.home}/works/libvirt-arm/edk2-arm-vars.fd"
    virt.uri = "qemu:///session"
    virt.system_uri = "qemu:///session"
    virt.socket = "#{Dir.home}/.cache/libvirt/libvirt-sock"
    # virt.qemu_user_networking = true
    # virt.cpu_mode = 'custom'
    # virt.cpu_match = 'exact'
    # virt.cpu_fallback = 'forbid'
    # virt.cpu_model = 'host'
  end

  config.vm.synced_folder ".", "/vagrant", disabled: false
end

Fixes: #1205

@github-actions
Copy link

github-actions bot commented Aug 5, 2023

Download the latest artifacts for this pull request here:

Copy link
Contributor

@electrofelix electrofelix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One query and I'm also wondering if you think it's reasonable to default the qemu URIs based on the host OS as well?

Also does user networking have other interpretations? https://wiki.qemu.org/Documentation/Networking suggests it's understood to mean something different to the host port forwarding. If there is a canonical resource referring to this approach as user networking will want to make sure referencing it in the docs.

Btw, thanks so much, it's great to have something here that will allow MacOS users to be able to use this project.

end
if qemu_user_networking
networks = []
else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm looking at this on a phone, so I could be missing something, if there can't be any networks for qemu_user_networking seems like could just return an empty list here and the rest of the function doesn't need to be modified at all?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're correct. Just made the change to return an empty list instead.

@laozc
Copy link
Author

laozc commented Aug 7, 2023

One query and I'm also wondering if you think it's reasonable to default the qemu URIs based on the host OS as well?

The current macOS brew package doesn't seem to offer qemu:///system like Linux.
I believe it would be great to set the default QEMU URI to minimize the user config.

Also does user networking have other interpretations? wiki.qemu.org/Documentation/Networking suggests it's understood to mean something different to the host port forwarding. If there is a canonical resource referring to this approach as user networking will want to make sure referencing it in the docs.

It is the same thing as mentioned in the wiki page.

Btw, thanks so much, it's great to have something here that will allow MacOS users to be able to use this project.

Sure. It's great to unblock people who experienced the same issue as I did. :)

@laozc
Copy link
Author

laozc commented Aug 11, 2023

Please be aware that the current latest libvirt version 9.6.0 has some issue on M1 Mac which prevents the volume from being created.
https://gitlab.com/libvirt/libvirt/-/issues/518

You may use libvirt 9.5.0.

@github-actions
Copy link

github-actions bot commented Sep 7, 2023

A docker image containing the code from this plugin to allow testing locally without installing
can be pulled from: ghcr.io/vagrant-libvirt/vagrant-libvirt:pr-1757-slim

If you need the image with the full dev toolchain, you can instead pull: ghcr.io/vagrant-libvirt/vagrant-libvirt:pr-1757

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

Successfully merging this pull request may close these issues.

Installing issue on Apple Silicon
2 participants