vagrant fails to create box with libvirt

4

I am trying to setup a box with vagrant and libvirt with the following Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.define :test_vm do |test_vm|
    test_vm.vm.box = "test"
    test_vm.vm.network :private_network, :ip => '10.20.30.40'
  end

  config.vm.provider :libvirt do |libvirt|
    libvirt.driver = "qemu"
    libvirt.host = "localhost"
    libvirt.connect_via_ssh = false
    libvirt.username = "root"
    libvirt.storage_pool_name = "data"
  end
end

On RHEL 6.4 I get the following error

Error while connecting to libvirt: Error making a connection to libvirt URI qemu://localhost/system?no_verify=1:
Call to virConnectOpen failed: Unable to import client certificate /etc/pki/CA/cacert.pem

I tried to setup the cert like described here http://libvirt.org/remote.html#Remote_TLS_CA but this didnt change anything.

If i try to connect via ssh vagrant is able to slowly upload the box but afterwards I get the next failure

Call to virDomainCreateWithFlags failed: internal error Process exited while reading console log output: char device redirected to /dev/pts/20
qemu-kvm: -drive file=/local/data/virtualbox/root_1372773363.img,if=none,id=drive-virtio-disk0,format=qcow2: could not open disk image /local/data/virtualbox/root_1372773363.img: Invalid argument

On Fedora 17 or Arch Linux I cannot even install the vagrant-libvirt plugin, because it cannot find the libvirt library (lying under /usr/lib).

Does someone somehow manage to get vagrant working with libvirt or is the libvirt plugin still to alpha?

TIA && have a nice day!

Basti

Bastian Ballmann

Posted 2013-07-03T08:59:31.247

Reputation: 41

Answers

3

I got this Error while connecting to libvirt error but it was simply a case that I was running vagrant up without specifying the provider.

In my case I needed

$ vagrant up --provider virtualbox

icc97

Posted 2013-07-03T08:59:31.247

Reputation: 396

1

I got this error while trying yo vagrant up a machine, without having virtualbox already installed (although I had previously written I needed it).

Installing virtualbox fixed this issue right away.

xarlymg89

Posted 2013-07-03T08:59:31.247

Reputation: 113

0

I too had this same issue. To fix it I had to essentially follow this guide : http://wiki.libvirt.org/page/TLSSetup

Note that the guide has multiple steps and it is LONG. Its not an "easy" fix though once you have the CAcert/key HostCert/key and ClientCert/key all in place, with the correct permissions and the correct ownership, everything works as expected.

thanks for reporting this and I hope this helps.

cloudnull

Posted 2013-07-03T08:59:31.247

Reputation: 1