If you're running on Linux, you have the option of using vagrant-spk
with Vagrant's libvirt
backend. Some developers have performance or reliability issues with VirtualBox and prefer to use
libvirt.
Some caveats:
libvirt
is not the default Vagrant backend, and is nowhere near as widely used as the VirtualBox backend. Things may break, either in Vagrant,libvirt
, or invagrant-spk
.- You will have to do some additional up-front configuration, which may be annoying/burdensome.
That said, Drew (@zarvox) uses the libvirt backend for all of his vagrant-spk work, and would prefer that it work for people in general, so if you're so inclined, try it out, and file bugs if you hit issues. Thanks!
On Fedora, this would be:
sudo dnf install virt-manager libvirt libvirt-daemon
On Debian/Ubuntu:
sudo apt-get install libvirtd virt-manager
Fedora:
sudo dnf install vagrant
Fedora:
sudo dnf install vagrant-libvirt
This is necessary to allow mounting shared folders from your user's home directory (or wherever the app you're developing is located) read-write, and getting the correct permissions out the other side.
Fedora: edit /etc/libvirt/qemu.conf
and set the following keys (there are comment blocks for each
in the default config):
security_driver = "none"
user = "root"
group = "root"
dynamic_ownership = 0
clear_emulator_capabilities = 0
- The first key says "disable SELinux enforcement".
- The second and third say "run qemu-kvm as root", which is needed so that the process has
CAP_DAC_OVERRIDE
and can create files owned by your user account. - The fourth key says "don't change files to be owned by root". We want files owned by your user account, by and large.
- The fifth key says "don't drop
CAP_DAC_OVERRIDE
". Linux has a curious feature which allows processes running as root to drop certain privileges. However, in this case, we need the one that allows you to read/modify/write files owned by other users (namely, the user you are doing development as).
We need the vagrant-mutate
plugin to import a box originally packaged for VirtualBox, convert it
to the libvirt disk image format, and register it as the equivalent box name for Vagrant to use it.
Install the plugin:
vagrant plugin install mutate
Import the VirtualBox box:
vagrant box add sandstorm/debian-jessie64
Produce an appropriate box for usage with libvirt:
vagrant mutate sandstorm/debian-jessie64 libvirt
Fedora users can skip this step.
To make sure vagrant
knows to use the libvirt backend for managing VMs, you'll need to set an
environment variable:
export VAGRANT_DEFAULT_PROVIDER=libvirt
You'll probably want to put the above line in your $HOME/.bashrc
so you don't have to type it every time
you open a shell that you use vagrant-spk
in.
Now, whenever you use vagrant-spk, vagrant should attempt to use the libvirt backend when creating VMs. :)
If you have an app where vagrant-spk previously created a VirtualBox VM, vagrant will continue to interact
with that VM until you run vagrant-spk destroy
, after which the next vagrant-spk up
should create a libvirt VM.
I also needed to
dnf install
theredhat-rpm-config
,libvirt-devel
, andruby-devel
packages, plus:and
(see fog/fog-libvirt#16)