32

I'm getting started Vagrant and want to use it with KVM/qemu (and the Virtual Machine Manager GUI), instead of installing VirtualBox. So I first installed Vagrant:

$ vagrant --version
Vagrant 1.9.1

$ vagrant box list
There are no installed boxes! Use `vagrant box add` to add some

As per these posts, I require vagrant-libvirt for it to work with KVM, so I installed that next:

$ vagrant plugin list
vagrant-libvirt (0.0.37)
vagrant-share (1.1.6, system)

Next, I to add a CentOS(7) box using vagrant box add "centos/7" and selected libvirt, when prompted. After which, I ran vagrant init and didn't encounter any errors:

$ vagrant init centos/7
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

However, vagrant up seems to be erroring out, like so:

$ vagrant up
No usable default provider could be found for your system.

Vagrant relies on interactions with 3rd party systems, known as
"providers", to provide Vagrant with resources to run development
environments. Examples are VirtualBox, VMware, Hyper-V.

The easiest solution to this message is to install VirtualBox, which
is available for free on all major platforms.

If you believe you already have a provider available, make sure it
is properly installed and configured. You can see more details about
why a particular provider isn't working by forcing usage with
`vagrant up --provider=PROVIDER`, which should give you a more specific
error message for that particular provider.
  • Here's the provider section in the Vagrantfile

    config.vm.provider :libvirt do |domain|
        domain.driver = "qemu"
        domain.memory = 512
        domain.cpus = 1
    end
    
  • I tried modifying it to:

    config.vm.provider :libvirt do |domain|
        domain.driver = "kvm"
        domain.host = 'localhost'
        domain.uri = 'qemu:///system'
        domain.memory = 512
        domain.cpus = 1
    end
    
  • I also tried vagrant up --provider=kvm, vagrant up --provider=qemu, and vagrant up --provider=libvirt too, to no avail.

Is there any step that I've missed? Or another package/dependency that needs to be installed?

Edit: After the adding centos/7 using vagrant, it shows up when running vagrant box list.

$ vagrant box list
centos/7 (libvirt, 1611.01)
rahuL
  • 3,330
  • 11
  • 54
  • 79
  • can you re-run `vagrant box list` after you've added the box – Frederic Henri Feb 10 '17 at 09:08
  • @FrédéricHenri `centos/7` shows up in the list. Added the output in the question – rahuL Feb 10 '17 at 09:33
  • hum .. is your installation of libvirt and qemu working correctly ? are you able to create qemu or kvm type virtual machines with `virsh` or `virt-manager` – Frederic Henri Feb 10 '17 at 09:40
  • @FrédéricHenri - yes it does, though I've only used it with the GUI (VMM) thus far. `$ sudo virsh list` shows a proper output `12 SS_Work running`, [like so](https://gist.github.com/anonymous/a4bc0e8cceacd9d653d83c2afff93dcb) – rahuL Feb 10 '17 at 09:48

3 Answers3

11

Start vagrant box with command

vagrant up --provider=kvm

Although it has been said in https://seven.centos.org/2017/08/updated-centos-vagrant-images-available-v1707-01/ that

The vagrant-libvirt plugin is only compatible with Vagrant 1.5 to 1.8

Jmt
  • 119
  • 1
  • 4
  • 6
    update 2019-07-21: quote from that vagrant-libvirt README https://github.com/vagrant-libvirt/vagrant-libvirt#installation : "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." – Christoph Lösch Jul 21 '19 at 21:42
10

You can use either the command line option --provider=kvm or you can set the VAGRANT_DEFAULT_PROVIDER environment variable:

export VAGRANT_DEFAULT_PROVIDER=kvm  # <-- may be in ~/.profile, /etc/profile, or elsewhere

vagrant up
ReWrite
  • 2,668
  • 1
  • 22
  • 14
1

vagrant-libvirt(0.0.40) is compatible with Vagrant 2.0.2 if you are running Ruby 2.3, at least on Linux Mint 18.3 (Ubuntu 16.04). I used vagrant from the Debian download on the vagrantUp website and installed the plugin using it without any problem.

DaveC49
  • 29
  • 1
  • 3
  • I don't think this is true. The [vagrant-libvirt README](https://github.com/vagrant-libvirt/vagrant-libvirt#installation) says "Vagrant-libvirt supports Vagrant 1.5, 1.6, 1.7 and 1.8". That README also recommends not installing vagrant with `yum`. – falsePockets Feb 13 '19 at 07:00
  • 1
    update 2019-07-21: quote from that readme: "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." – Christoph Lösch Jul 21 '19 at 21:40