Libvirt and Vagrant

Jul 28, 2020 15:43 · 223 words · 2 minute read libvirt vagrant

Libvirt is the default toolkit to manage virtualization platforms on Linux. Libvirt and qemu is a great combination with Vagrant. It’s the default combination on most Linux systems, also on my favorite - Fedora.

This combination allows for some awesome features and some restrictions. One of the restrictions is that Ubuntu isn’t available as a box, but Debian is. And Debian is the foundation of Ubuntu, and it’s more open than Ubuntu.

The biggest feature is that it allows for more permanent development environments and direct connection to already existing network bridges.


Allow your user to manage libvirt VMs on the computer.

sudo usermod -Ga libvirt $(whoami)


Below is an example of a Vagrantfile that creates a VM with connection to a bridge bridge0 on a network that restart automatically after a reboot of the host.

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config| = "debian/buster64"

  # Connect to bridge named bridge0 with public IP "public_network", dev: "bridge0", mode: "bridge", type: "bridge", ip: ""

  # Use rsync to sync files into /vagrant
  config.vm.synced_folder ".", "/vagrant", type: "rsync"

  # Libvirt provider
  config.vm.provider "libvirt" do |l|
    l.cpus = 1
    l.memory = "256"

    # Use qemu:///system sesion, not the user session qemu:///session
    l.qemu_use_session = false

    # Restart on host reboot
    l.autostart = true