Skip to content
Hiroshi Miura edited this page Jun 5, 2014 · 5 revisions

Preparation

You need to install several packages before install vagrant-kvm. It is recommended to use 64bit OS for host.

It is best for running vagrant-kvm on Ubuntu LTS Trusty(14.04) and later.

If you are using Saucy(13.10) or Ubuntu LTS Precise(12.04), you need to install backported libvirt/qemu and most recent kernel.

You can use Personal Package Archive(PPA) for Precise and Saucy with running following as root.

sudo apt-add-repository ppa:miurahr/vagrant
sudo apt-get update

There is an issue which causes libvirt error with some kernel versions. https://bugs.launchpad.net/apparmor/+bug/1236455 https://github.com/adrahon/vagrant-kvm/issues/130#issuecomment-33306527

For precise (12.04.02 LTS): linux-image 3.2 series are official and no problem. If you use precise-backports, linux-image 3.5, 3.8 and 3.13 series are OK. For 3.11 series, you should use 3.11.0-15-generic and later. For Saucy(13.10): linux-image 3.11 series are offcial, and please check your kernel is linux-image-3.11.0-15 or later.

Installation of dependency packages.

sudo apt-get install -y ruby2.0-dev
 ## NOTE qemu-bin should be installed before libvirt-bin
sudo apt-get install -y qemu qemu-kvm
sudo apt-get install -y libvirt-dev libvirt-bin
sudo apt-get install -y git gcc
sudo apt-get install -y nfs-kernel-server
sudo apt-get install -y bsdtar
sudo apt-get install -y libxml2-dev libxslt-dev
sudo apt-get install -y redir

You may need to reboot after installation of dependency packages.

Add the user to libvirtd group

Access to the management layer of libvirt is controlled through membership to the libvirtd unix group.

To enable libvirt management access for a user, add them to this group:

$ sudo usermod -G libvirtd  -a ~~usrname~~

Install Vagrant

There is an ubuntu/debian package that can be downloaded from vagrantup.com.

Install vagrant-kvm

vagrant plugin install vagrant-kvm

or to test development version,

git clone https://github.com/adrahon/vagrant-kvm.git
cd vagrant-kvm
gem build vagrant-kvm.gemspec
vagrant plugin install vagrant-kvm-0.1.4.gem

Troubleshooting

vagrant up fails with a permission error

Some versions of Ubuntu kernel has a bug that will cause vagrant-kvm to fail with a permission error on vagrant up. It is a kernel bug with the AppArmor security framework.

As a workaround, run the following commands to disable access control for libvirt helper.

sudo apt-get install -y apparmor-profiles apparmor-utils
sudo aa-complain /usr/lib/libvirt/virt-aa-helper