* [Libvirt](http://libvirt.org) - should work with version 1.5 or newer
* [Vagrant](http://www.vagrantup.com) - plugin attempts to support all since 1.5
* [GCC](https://gcc.gnu.org/install/) and [Make](https://www.gnu.org/software/make/) - used to compile native versions of ruby-libvirt and nokogiri when using upstream Vagrant
While we only test with upstream vagrant installed as a gem, we recommend that you install
vagrant as provided by your distribution as installing vagrant-libvirt involves linking between
libvirt (ruby-libvirt) and the ruby installation used by vagrant. Since upstream vagrant
provides an embedded ruby, this typically causes issues with missing symbols between libraries
included and what is expected by libvirt for the ruby bindings linking to work.
First, you should have both QEMU and Libvirt installed if you plan to run VMs on your
local system. For instructions, refer to your Linux distribution's documentation. Suggested
packages are provided in our guides for as a quick reference
{: .warning }
Before you start using vagrant-libvirt, please make sure your Libvirt
and QEMU installation is working correctly and you are able to create QEMU or
KVM type virtual machines with `virsh` or `virt-manager`.
Next, you must have Vagrant installed from your distribution packages.
Vagrant-libvirt supports Vagrant 2.0, 2.1 & 2.2. It should also work with earlier
releases from 1.5 onwards but they are not actively tested.
It's possible to define a function in `~/.bashrc`, for example:
```bash
vagrant(){
docker run -i --rm \
-e LIBVIRT_DEFAULT_URI \
-v /var/run/libvirt/:/var/run/libvirt/ \
-v ~/.vagrant.d:/.vagrant.d \
-v $(realpath "${PWD}"):${PWD} \
-w $(realpath "${PWD}") \
--network host \
vagrantlibvirt/vagrant-libvirt:latest \
vagrant $@
}
```
#### Using Podman
Preparing the podman run, only once:
```bash
mkdir -p ~/.vagrant.d/{boxes,data,tmp}
```
_N.B. This is needed until the entrypoint works for podman to only mount the `~/.vagrant.d` directory_
To run with Podman you need to include
```bash
--entrypoint /bin/bash \
--security-opt label=disable \
-v ~/.vagrant.d/boxes:/vagrant/boxes \
-v ~/.vagrant.d/data:/vagrant/data \
-v ~/.vagrant.d/tmp:/vagrant/tmp \
```
for example:
```bash
vagrant(){
podman run -it --rm \
-e LIBVIRT_DEFAULT_URI \
-v /var/run/libvirt/:/var/run/libvirt/ \
-v ~/.vagrant.d/boxes:/vagrant/boxes \
-v ~/.vagrant.d/data:/vagrant/data \
-v ~/.vagrant.d/tmp:/vagrant/tmp \
-v $(realpath "${PWD}"):${PWD} \
-w $(realpath "${PWD}") \
--network host \
--entrypoint /bin/bash \
--security-opt label=disable \
docker.io/vagrantlibvirt/vagrant-libvirt:latest \
vagrant $@
}
```
Running Podman in rootless mode maps the root user inside the container to your host user so we need to bypass [entrypoint.sh](https://github.com/vagrant-libvirt/vagrant-libvirt/blob/main/entrypoint.sh) and mount persistent storage directly to `/vagrant`.
#### Extending the container image with additional vagrant plugins
By default the image published and used contains the entire tool chain required
to reinstall the vagrant-libvirt plugin and it's dependencies, as this is the
default behaviour of vagrant anytime a new plugin is installed. This means it
should be possible to use a simple `FROM` statement and ask vagrant to install
additional plugins.
```
FROM vagrantlibvirt/vagrant-libvirt:latest
RUN vagrant plugin install <plugin>
```
### Ubuntu / Debian
{: .info }
You may need to modify your `sources.list` to uncomment the deb-src entries where using build-dep commands below.
Unless you can can install a newer ruby on Debian 8, it is likely that the distro vagrant approach will not be straight forward as vagrant-libvirt requires a fog-core and fog-libvirt releases that depend on ruby 2.5 or newer.
### Fedora
#### Fedora 32 and newer
{: .info }
Due to the involved nature of getting the linking to work correctly when using the upstream
vagrant, it is strongly recommended to either use the distro packaged vagrant, or the
install script from the vagrant-libvirt-qa approach.
If have problem with installation - check your linker. It should be `ld.gold`:
```shell
sudo alternatives --set ld /usr/bin/ld.gold
# OR
sudo ln -fs /usr/bin/ld.gold /usr/bin/ld
```
### LoadError Exceptions
If you encounter the following load error when using the vagrant-libvirt plugin (note the required by libssh):
```/opt/vagrant/embedded/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': /opt/vagrant/embedded/lib64/libcrypto.so.1.1: version `OPENSSL_1_1_1b' not found (required by /lib64/libssh.so.4) - /home/xxx/.vagrant.d/gems/2.4.6/gems/ruby-libvirt-0.7.1/lib/_libvirt.so (LoadError)```
then the following steps have been found to resolve the problem. Thanks to James Reynolds (see https://github.com/hashicorp/vagrant/issues/11020#issuecomment-540043472). The specific version of libssh will change over time so references to the rpm in the commands below will need to be adjusted accordingly.
{: .info }
See distro specific instructions for variations on this that contain version independent steps.
```shell
# Fedora
dnf download --source libssh
# centos 8 stream, doesn't provide source RPMs, so you need to download like so
then the following steps have been found to resolve the problem. After the steps below are complete, then reinstall the vagrant-libvirt plugin without setting the `CONFIGURE_ARGS`. Thanks to Marco Bevc (see https://github.com/hashicorp/vagrant/issues/11020#issuecomment-625801983):
```shell
# Fedora
dnf download --source krb5-libs
# centos 8 stream, doesn't provide source RPMs, so you need to download like so