scripts/vagrant: add configuration for vhost tests

Use libvirt provider to provision the VM by syncing vhost dir
which holds all dependencies needed to run vhost tests
(VM image, fio binary and SSH keys).

Change-Id: If8c65ef683cae37301e980fdaecc753c7371aeeb
Signed-off-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-on: https://review.gerrithub.io/421919
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Karol Latecki 2018-08-10 16:11:02 +02:00 committed by Jim Harris
parent 039a4c6cb0
commit 9a361ac01d
2 changed files with 43 additions and 4 deletions

View File

@ -62,6 +62,8 @@ Vagrant.configure(2) do |config|
vmcpu=(ENV['SPDK_VAGRANT_VMCPU'] || 2)
vmram=(ENV['SPDK_VAGRANT_VMRAM'] || 4096)
spdk_dir=(ENV['SPDK_DIR'] || "none")
vhost_host_dir=(ENV['VHOST_HOST_DIR'] || "none")
vhost_vm_dir=(ENV['VHOST_VM_DIR'] || "none")
config.ssh.forward_agent = true
config.ssh.forward_x11 = true
@ -87,12 +89,14 @@ Vagrant.configure(2) do |config|
# 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|
libvirt.random_hostname = "1"
libvirt.disk_bus = "virtio"
# 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"
puts "If run with libvirt provider please execute create_nvme_img.sh"
end
libvirt.qemuargs :value => "-drive"
@ -114,6 +118,13 @@ Vagrant.configure(2) do |config|
config.vm.synced_folder "#{spdk_dir}", "/home/vagrant/spdk_repo/spdk", type: "rsync", rsync__auto: false
end
if vhost_host_dir != "none"
config.vm.synced_folder "#{vhost_host_dir}", "#{vhost_vm_dir}", type: "rsync", rsync__auto: false
config.vm.provision "shell", inline: "sudo mkdir -p /root/.ssh"
config.vm.provision "shell", inline: "sudo cp #{vhost_vm_dir}/spdk_vhost_id_rsa* /root/.ssh"
config.vm.provision "shell", inline: "sudo chmod 600 /root/.ssh/spdk_vhost_id_rsa"
end
# Copy in the user's tools if they exists
if File.directory?(File.expand_path("~/vagrant_tools"))
config.vm.synced_folder "~/vagrant_tools", "/home/vagrant/tools", type: "rsync", rsync__auto: false

View File

@ -22,10 +22,14 @@ display_help() {
echo " -s <ram-size> in kb default: ${SPDK_VAGRANT_VMRAM}"
echo " -n <num-cpus> 1 to 4 default: ${SPDK_VAGRANT_VMCPU}"
echo " -x <http-proxy> default: \"${SPDK_VAGRANT_HTTP_PROXY}\""
echo " -p <provider> libvirt or virtualbox"
echo " --vhost-host-dir=<path> directory path with vhost test dependencies"
echo " (test VM qcow image, fio binary, ssh keys)"
echo " --vhost-vm-dir=<path> directory where to put vhost dependencies in VM"
echo " -r dry-run"
echo " -h help"
echo " -v verbose"
echo
echo
echo " Examples:"
echo
echo " $0 -x http://user:password@host:port fedora27"
@ -47,8 +51,15 @@ SPDK_VAGRANT_VMCPU=4
SPDK_VAGRANT_VMRAM=4096
OPTIND=1
while getopts ":n:s:x:vrh" opt; do
while getopts ":n:s:x:p:vrh-:" opt; do
case "${opt}" in
-)
case "${OPTARG}" in
vhost-host-dir=*) VHOST_HOST_DIR="${OPTARG#*=}" ;;
vhost-vm-dir=*) VHOST_VM_DIR="${OPTARG#*=}" ;;
*) echo "Invalid argument '$OPTARG'" ;;
esac
;;
x)
http_proxy=$OPTARG
https_proxy=$http_proxy
@ -60,6 +71,9 @@ while getopts ":n:s:x:vrh" opt; do
s)
SPDK_VAGRANT_VMRAM=$OPTARG
;;
p)
PROVIDER=$OPTARG
;;
v)
VERBOSE=1
;;
@ -119,6 +133,8 @@ if [ ${VERBOSE} = 1 ]; then
echo SPDK_VAGRANT_VMCPU=$SPDK_VAGRANT_VMCPU
echo SPDK_VAGRANT_VMRAM=$SPDK_VAGRANT_VMRAM
echo SPDK_VAGRANT_HTTP_PROXY=$SPDK_VAGRANT_HTTP_PROXY
echo VHOST_HOST_DIR=$VHOST_HOST_DIR
echo VHOST_VM_DIR=$VHOST_VM_DIR
echo
fi
@ -127,6 +143,18 @@ export SPDK_VAGRANT_VMCPU
export SPDK_VAGRANT_VMRAM
export SPDK_DIR
if [ -n "$PROVIDER" ]; then
provider="--provider=${PROVIDER}"
fi
if [ -n "$VHOST_HOST_DIR" ]; then
export VHOST_HOST_DIR
fi
if [ -n "$VHOST_VM_DIR" ]; then
export VHOST_VM_DIR
fi
if [ ${DRY_RUN} = 1 ]; then
echo "Environemnt Variables"
printenv SPDK_VAGRANT_DISTRO
@ -154,7 +182,7 @@ if [ ${DRY_RUN} != 1 ]; then
vagrant plugin install vagrant-proxyconf
fi
fi
vagrant up
vagrant up $provider
echo ""
echo " SUCCESS!"
echo ""