scripts/vagrant: add vagrant-libvirt provider

This patch add another provider for libvirt.
There are still few additional problems in vagrant-libvirt like:
-most recent vagrant-libvirt (0.0.39+)
-most recent qemu 2.10+
-must be run as: vagrant up --provider=libvirt

Change-Id: I6ad3497cd06bb1a490259c0afc93c6ea610967f8
Signed-off-by: Daniel Mrzyglod <daniel.mrzyglod@gmail.com>
Reviewed-on: https://review.gerrithub.io/389551
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Daniel Mrzyglod 2017-11-28 15:04:51 +01:00 committed by Jim Harris
parent 55a624ed09
commit 30dfc6d505
3 changed files with 60 additions and 1 deletions

View File

@ -21,6 +21,8 @@ export https_proxy=...
vagrant plugin install vagrant-proxyconf
~~~
In case you want use kvm/libvirt you should also install `vagrant-libvirt`
# VM Configuration {#vagrant_config}
This vagrant environment creates a VM based on environment variables found in `env.sh`.
@ -55,7 +57,16 @@ By default, the VM created is configured with:
# Providers {#vagrant_providers}
Currently only the VirtualBox provider is supported.
Currently VirtualBox & libvirt provider are supported.
For libvirt currently there is only centos 7 image avaiable.
To run with libvirt:
~~~{.sh}
./create_nvme_img.sh
vagrant up --provider=libvirt
~~~
# Running An Example {#vagrant_example}

View File

@ -8,6 +8,10 @@ Vagrant.configure(2) do |config|
if distro == 'centos7'
config.vm.box = "puppetlabs/centos-7.2-64-nocm"
config.ssh.insert_key = false
# Puppetlabs does not provide libvirt Box so we will use official one
config.vm.provider :libvirt do |libvirt|
config.vm.box = "centos/7"
end if Vagrant.has_plugin?('vagrant-libvirt')
else
config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
end
@ -67,4 +71,36 @@ Vagrant.configure(2) do |config|
vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.1", "1"]
vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.2", "1"]
end
# This setup was Tested on Fedora 27
# libvirt configuration need modern Qemu(tested on 2.10) & vagrant-libvirt in version 0.0.39+
# There are few limitation for SElinux - The file added outside libvirt must have proper SE ACL policy or setenforce 0
config.vm.provider "libvirt" do |libvirt, override|
# we put nvme_disk inside default pool to eliminate libvirt/SELinux Permissions Problems
# and to be able to run vagrant from user $HOME directory
nvme_disk = '/var/lib/libvirt/images/nvme_disk.img'
unless File.exist? (nvme_disk)
override.puts "If run with libvirt provider please execute create_nvme_img.sh"
end
libvirt.qemuargs :value => "-drive"
libvirt.qemuargs :value => "file=#{nvme_disk},if=none,id=D22"
libvirt.qemuargs :value => "-device"
libvirt.qemuargs :value => "nvme,drive=D22,serial=1234"
libvirt.driver = "kvm"
libvirt.graphics_type = "spice"
libvirt.memory = "#{vmram}"
libvirt.cpus = "#{vmcpu}"
libvirt.video_type = "qxl"
# Optional field if we want use other storage pools than default
# libvirt.storage_pool_name = "vm"
# rsync the vpp directory if provision hasn't happened yet
unless File.exist? (".vagrant/machines/default/libvirt/action_provision")
config.vm.synced_folder "../../", "/spdk", type: "rsync"
end
end
end

View File

@ -0,0 +1,12 @@
#!/usr/bin/env bash
WHICH_OS=`lsb_release -i | awk '{print $3}'`
nvme_disk='/var/lib/libvirt/images/nvme_disk.img'
qemu-img create -f raw $nvme_disk 1024M
#Change SE Policy on Fedora
if [ $WHICH_OS == "Fedora" ]; then
sudo chcon -t svirt_image_t $nvme_disk
fi
chmod 777 $nvme_disk
chown qemu:qemu $nvme_disk