Coder Social home page Coder Social logo

vagrant-qemu's Introduction

Vagrant Qemu Provider

This is a simple Vagrant plugin that adds a qemu provider to Vagrant, allowing Vagrant to control and provision machines using qemu.

Environment preparation

First make sure qemu works in your environment. If qemu is not installed yet,

brew install qemu

It is optional, but we strongly suggest installing qemu-virgl to enable graphical acceleration:

brew install akirakyle/qemu-virgl/qemu-virgl

If vagrant is not installed yet, you should install it:

brew install vagrant

If any troubles met for vagrant installation, check other options

Build and install

Clone this repo:

git clone https://github.com/billyan2018/vagrant-qemu

Then build and install

rake build && vagrant plugin install pkg/vagrant-qemu-0.2.22.gem

Demo

Run an ARM64 VM

vagrant init billyan2018/devbox \
  --box-version 0.1.0
vagrant up --provider="libvirt"

as convention, the username/password are both vagrant Screen:

Run an AMD64 VM

vagrant init failfish/precise64

Add this part in the Vagrantfile:

  config.vm.provider :libvirt do |lv|
    lv.qemu_command = "qemu-system-x86_64" 
    lv.machine = "q35"
    lv.cpu = "max"
    lv.memory = "4G"
    lv.display="cocoa,gl=es"	
  end

Then vagrant up --provider="libvirt" Screen:

Configuration items

Item Description Default value
qemu_command the command to call qemu, like qemu-system-aarch64 or qemu-system-x86_64 "qemu-system-aarch64"
machine machine type, run qemu-system-aarch64 -machine help to see the types supported "virt,accel=hvf,highmem=off"
cpu run qemu-system-aarch64 -cpu help to check CPU supported "host"
smp Specify the number of cores the guest is permitted to use "2"
memory Memory size "4G"
display Available display backend types: qemu-system-aarch64 -display help "cocoa,gl=es"
gpu "virtio-gpu-gl-pci"
mouse mouse type "usb-tablet"
firmware_location The firmware to boot the machine no value for x86, otherwise "/opt/homebrew/share/qemu/edk2-aarch64-code.fd"
additional_line any content you would like to append at the end of the command NA

vagrant-qemu's People

Contributors

billyan2018 avatar elijahr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

vagrant-qemu's Issues

`lv.qemu_command` is ignored

I'm trying to run an AMD64 image on an M1 mac. The image was built in this same machine with Packer. I set lv.qemu_command = "qemu-system-x86_64" but it still runs qemu-system-aarch64.

Machine: MacBook Air M1
OS: macOS Ventura, Version 13.0 Beta (22A5311f)

❯ vagrant --version
Vagrant 2.2.19
❯ vagrant plugin list
vagrant-qemu (0.1.8, global)

Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.box = "c10l/debian-11.4"
  config.vm.box_version = "202208.02.0"

  config.vm.synced_folder ".", "/vagrant", disabled: true

  config.vm.provider :libvirt do |lv|
    lv.qemu_command = "qemu-system-x86_64"
  end
end

When I run it:

❯ vagrant up
Bringing machine 'default' up with 'qemu' provider...
==> default: Checking if box 'c10l/debian-11.4' version '202208.02.0' is up to date...
==> default: Importing a QEMU instance
    default: Creating and registering the VM...
    default: Successfully imported VM
==> default: Warning! The QEMU provider doesn't support any of the Vagrant
==> default: high-level network configurations (`config.vm.network`). They
==> default: will be silently ignored.
==> default: Starting the instance...
A command executed by Vagrant didn't complete successfully!
The command run along with the output from the command is shown
below.

Command: ["qemu-system-aarch64", "-machine", "virt,accel=hvf,highmem=off", "-cpu", "cortex-a72", "-smp", "2", "-m", "4G", "-device", "virtio-net-device,netdev=net0", "-netdev", "user,id=net0,hostfwd=tcp::50022-:22", "-drive", "if=virtio,format=qcow2,file=/Users/cassianoleal/src/proxmox/client-go/.vagrant/machines/default/qemu/vgXb4TTamTE/linked-box.img", "-drive", "if=pflash,format=raw,file=/Users/cassianoleal/src/proxmox/client-go/.vagrant/machines/default/qemu/vgXb4TTamTE/edk2-aarch64-code.fd,readonly=on", "-drive", "if=pflash,format=raw,file=/Users/cassianoleal/src/proxmox/client-go/.vagrant/machines/default/qemu/vgXb4TTamTE/edk2-arm-vars.fd", "-chardev", "socket,id=mon0,path=/Users/cassianoleal/.vagrant.d/tmp/vagrant-qemu/vgXb4TTamTE/qemu_socket,server=on,wait=off", "-mon", "chardev=mon0,mode=readline", "-chardev", "socket,id=ser0,path=/Users/cassianoleal/.vagrant.d/tmp/vagrant-qemu/vgXb4TTamTE/qemu_socket_serial,server=on,wait=off", "-serial", "chardev:ser0", "-pidfile", "/Users/cassianoleal/src/proxmox/client-go/.vagrant/machines/default/qemu/vgXb4TTamTE/qemu.pid", "-parallel", "null", "-monitor", "none", "-display", "none", "-vga", "none", "-daemonize", {:notify=>[:stdout, :stderr, :stdin]}]

Stderr: qemu-system-aarch64: Addressing limited to 32 bits, but memory exceeds it by 1073741824 bytes



Stdout: 

1 ❯ 

libvirt provider on Apple m1

Hello,

it's not possible for me to install vagrant-libvirt (it doesn't compile on Apple M1; ruby-libvirt tries to compile for x86_64 instead).

How do I get libvirt provider then?


$ vagrant up --provider=libvirt
The provider 'libvirt' could not be found, but was requested to
back the machine 'default'. Please use a provider that exists.

Vagrant knows about the following providers: docker, hyperv, virtualbox, qemu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.