summaryrefslogtreecommitdiffstats
path: root/src/spdk/scripts/vagrant
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /src/spdk/scripts/vagrant
parentInitial commit. (diff)
downloadceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz
ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/spdk/scripts/vagrant')
-rw-r--r--src/spdk/scripts/vagrant/README.md237
-rw-r--r--src/spdk/scripts/vagrant/Vagrantfile291
-rw-r--r--src/spdk/scripts/vagrant/Vagrantfile_openstack_vm82
-rw-r--r--src/spdk/scripts/vagrant/Vagrantfile_vhost_vm138
-rw-r--r--src/spdk/scripts/vagrant/autorun-spdk.conf31
-rwxr-xr-xsrc/spdk/scripts/vagrant/create_nvme_img.sh77
-rwxr-xr-xsrc/spdk/scripts/vagrant/create_openstack_vm.sh33
-rwxr-xr-xsrc/spdk/scripts/vagrant/create_vbox.sh334
-rwxr-xr-xsrc/spdk/scripts/vagrant/create_vhost_vm.sh132
-rw-r--r--src/spdk/scripts/vagrant/local.conf51
-rwxr-xr-xsrc/spdk/scripts/vagrant/run-autorun.sh245
-rwxr-xr-xsrc/spdk/scripts/vagrant/update.sh98
12 files changed, 1749 insertions, 0 deletions
diff --git a/src/spdk/scripts/vagrant/README.md b/src/spdk/scripts/vagrant/README.md
new file mode 100644
index 000000000..323a26d2d
--- /dev/null
+++ b/src/spdk/scripts/vagrant/README.md
@@ -0,0 +1,237 @@
+# SPDK Vagrant and VirtualBox
+
+The following guide explains how to use the scripts in the `spdk/scripts/vagrant`. Mac, Windows, and Linux platforms are supported.
+
+1. Install and configure [Git](https://git-scm.com/) on your platform.
+2. Install [VirtualBox 5.1](https://www.virtualbox.org/wiki/Downloads) or newer
+3. Install* [VirtualBox Extension Pack](https://www.virtualbox.org/wiki/Downloads)
+4. Install and configure [Vagrant 1.9.4](https://www.vagrantup.com) or newer
+
+* Note: The extension pack has different licensing than main VirtualBox, please
+ review them carefully as the evaluation license is for personal use only.
+
+## Mac OSX Setup (High Sierra)
+
+Quick start instructions for OSX:
+
+1. Install Homebrew
+2. Install Virtual Box Cask
+3. Install Virtual Box Extension Pack*
+4. Install Vagrant Cask
+
+* Note: The extension pack has different licensing than main VirtualBox, please
+ review them carefully as the evaluation license is for personal use only.
+
+```
+ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
+ brew doctor
+ brew update
+ brew cask install virtualbox
+ brew cask install virtualbox-extension-pack
+ brew cask install vagrant
+```
+
+## Windows 10 Setup
+
+1. Windows platforms should install some form of git.
+2. Install [VirtualBox 5.1](https://www.virtualbox.org/wiki/Downloads) or newer
+3. Install* [VirtualBox Extension Pack](https://www.virtualbox.org/wiki/Downloads)
+4. Install and configure [Vagrant 1.9.4](https://www.vagrantup.com) or newer
+
+* Note: The extension pack has different licensing than main VirtualBox, please
+ review them carefully as the evaluation license is for personal use only.
+
+- Note: VirtualBox requires virtualization to be enabled in the BIOS.
+- Note: You should disable Hyper-V in Windows RS 3 laptop. Search `windows features` un-check Hyper-V, restart laptop
+
+## Linux Setup
+
+Following the generic instructions should be sufficient for most Linux distributions. For more thorough instructions on installing VirtualBox on your distribution of choice, please see the following [guide](https://www.virtualbox.org/wiki/Linux_Downloads).
+
+ Examples on Fedora26/Fedora27/Fedora28
+
+1. yum check-update
+2. yum update -y
+3. yum install qt*
+4. yum install libsdl*
+5. rpm -ivh VirtualBox-5.2-5.2.16_123759_fedora26-1.x86_64.rpm (select the right version in https://www.virtualbox.org/wiki/Linux_Downloads)
+6. VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-5.2.16.vbox-extpack(install the same pack* as your installed version of VirtualBox)
+7. rpm -ivh vagrant_2.1.2_x86_64.rpm
+
+* Note: The extension pack has different licensing than main VirtualBox, please
+ review them carefully as the evaluation license is for personal use only.
+
+## Configure Vagrant
+
+If you are behind a corporate firewall, configure the following proxy settings.
+
+1. Set the http_proxy and https_proxy
+2. Install the proxyconf plugin
+
+```
+ $ export http_proxy=....
+ $ export https_proxy=....
+ $ vagrant plugin install vagrant-proxyconf
+```
+
+## Download SPDK from GitHub
+
+Use git to clone a new spdk repository. GerritHub can also be used. See the instructions at [spdk.io](http://www.spdk.io/development/#gerrithub) to setup your GerritHub account. Note that this spdk repository will be rsync'd into your VM, so you can use this repository to continue development within the VM.
+
+## Create a Virtual Box
+
+Use the `spdk/scripts/vagrant/create_vbox.sh` script to create a VM of your choice. Supported VM platforms are:
+
+- centos7
+- ubuntu16
+- ubuntu18
+- fedora26
+- fedora27
+- fedora28
+- freebsd11
+
+```
+$ spdk/scripts/vagrant/create_vbox.sh -h
+ Usage: create_vbox.sh [-n <num-cpus>] [-s <ram-size>] [-x <http-proxy>] [-hvrld] <distro>
+
+ distro = <centos7 | ubuntu16 | ubuntu18 | fedora26 | fedora27 | fedora28 | freebsd11>
+
+ -s <ram-size> in kb default: 4096
+ -n <num-cpus> 1 to 4 default: 4
+ -x <http-proxy> default: ""
+ -p <provider> libvirt or virtualbox
+ --vhost-host-dir=<path> directory path with vhost test dependencies
+ (test VM qcow image, fio binary, ssh keys)
+ --vhost-vm-dir=<path> directory where to put vhost dependencies in VM
+ -r dry-run
+ -l use a local copy of spdk, don't try to rsync from the host.
+ -d deploy a test vm by provisioning all prerequisites for spdk autotest
+ -h help
+ -v verbose
+
+ Examples:
+
+ ./scripts/vagrant/create_vbox.sh -x http://user:password@host:port fedora27
+ ./scripts/vagrant/create_vbox.sh -s 2048 -n 2 ubuntu16
+ ./scripts/vagrant/create_vbox.sh -rv freebsd
+ ./scripts/vagrant/create_vbox.sh fedora26
+```
+
+It is recommended that you call the `create_vbox.sh` script from outside of the spdk repository. Call this script from a parent directory. This will allow the creation of multiple VMs in separate <distro> directories, all using the same spdk repository. For example:
+
+```
+ $ spdk/scripts/vagrant/create_vbox.sh -s 2048 -n 2 fedora26
+```
+
+This script will:
+
+1. create a subdirectory named <distro> in your $PWD
+2. copy the needed files from `spdk/scripts/vagrant/` into the <distro> directory
+3. create a working virtual box in the <distro> directory
+4. rsync the `~/.gitconfig` file to `/home/vagrant/` in the newly provisioned virtual box
+5. rsync a copy of the source `spdk` repository to `/home/vagrant/spdk_repo/spdk` (optional)
+6. rsync a copy of the `~/vagrant_tools` directory to `/home/vagrant/tools` (optional)
+7. execute vm_setup.sh on the guest to install all spdk dependencies (optional)
+
+This arrangement allows the provisioning of multiple, different VMs within that same directory hierarchy using the same spdk repository. Following the creation of the vm you'll need to ssh into your virtual box and finish the VM initialization.
+
+```
+ $ cd <distro>
+ $ vagrant ssh
+```
+
+## Finish VM Initialization
+
+A copy of the `spdk` repository you cloned will exist in the `spdk_repo` directory of the `/home/vagrant` user account. After using `vagrant ssh` to enter your VM you must complete the initialization of your VM by running the `scripts/vagrant/update.sh` script. For example:
+
+```
+ $ script -c 'sudo spdk_repo/spdk/scripts/vagrant/update.sh' update.log
+```
+
+The `update.sh` script completes initialization of the VM by automating the following steps.
+
+1. Runs yum/apt-get update (Linux)
+2. Runs the scripts/pdkdep.sh script
+3. Installs the FreeBSD source in /usr/sys (FreeBSD only)
+
+This only needs to be done once. This is also not necessary for Fedora VMs provisioned with the -d flag. The `vm_setup` script performs these operations instead.
+
+## Post VM Initialization
+
+Following VM initialization you must:
+
+1. Verify you have an emulated NVMe device
+2. Compile your spdk source tree
+3. Run the hello_world example to validate the environment is set up correctly
+
+### Verify you have an emulated NVMe device
+
+```
+ $ lspci | grep "Non-Volatile"
+ 00:0e.0 Non-Volatile memory controller: InnoTek Systemberatung GmbH Device 4e56
+```
+
+### Compile SPDK
+
+```
+ $ cd spdk_repo/spdk
+ $ git submodule update --init
+ $ ./configure --enable-debug
+ $ make
+```
+
+### Run the hello_world example script
+
+```
+ $ sudo scripts/setup.sh
+ $ sudo ./build/examples/hello_bdev
+```
+
+### Running autorun.sh with vagrant
+
+After running vm_setup.sh the `run-autorun.sh` can be used to run `spdk/autorun.sh` on a Fedora vagrant machine. Note that the `spdk/scripts/vagrant/autorun-spdk.conf` should be copied to `~/autorun-spdk.conf` before starting your tests.
+
+```
+ $ cp spdk/scripts/vagrant/autorun-spdk.conf ~/
+ $ spdk/scripts/vagrant/run-autorun.sh -h
+ Usage: scripts/vagrant/run-autorun.sh -d <path_to_spdk_tree> [-h] | [-q] | [-n]
+ -d : Specify a path to an SPDK source tree
+ -q : No output to screen
+ -n : Noop - dry-run
+ -h : This help
+
+ Examples:
+ run-spdk-autotest.sh -d . -q
+ run-spdk-autotest.sh -d /home/vagrant/spdk_repo/spdk
+```
+
+## FreeBSD Appendix
+
+---
+**NOTE:** As of this writing the FreeBSD Virtualbox instance does not correctly support the vagrant-proxyconf feature.
+---
+
+The following steps are done by the `update.sh` script. It is recommended that you capture the output of `update.sh` with a typescript. E.g.:
+
+```
+ $ script update.log sudo spdk_repo/spdk/scripts/vagrant/update.sh
+```
+
+1. Updates the pkg catalog
+1. Installs the needed FreeBSD packages on the system by calling pkgdep.sh
+2. Installs the FreeBSD source in /usr/src
+
+```
+ $ sudo pkg upgrade -f
+ $ sudo spdk_repo/spdk/scripts/pkgdep.sh --all
+ $ sudo git clone --depth 10 -b releases/11.1.0 https://github.com/freebsd/freebsd.git /usr/src
+```
+
+To build spdk on FreeBSD use `gmake MAKE=gmake`. E.g.:
+
+```
+ $ cd spdk_repo/spdk
+ $ git submodule update --init
+ $ ./configure --enable-debug
+ $ gmake MAKE=gmake
+```
diff --git a/src/spdk/scripts/vagrant/Vagrantfile b/src/spdk/scripts/vagrant/Vagrantfile
new file mode 100644
index 000000000..ccf6d632e
--- /dev/null
+++ b/src/spdk/scripts/vagrant/Vagrantfile
@@ -0,0 +1,291 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+require 'open3'
+def checkboxtype(distro)
+ localboxes, stderr, status = Open3.capture3("vagrant box list")
+ if localboxes.include? "spdk/"+distro
+ return "spdk/"+distro
+ else
+ case distro
+ when "centos7"
+ return "centos/7"
+ when "centos8"
+ return "centos/8"
+ when "ubuntu1604"
+ return "peru/ubuntu-16.04-server-amd64"
+ when "ubuntu1804"
+ return "peru/ubuntu-18.04-server-amd64"
+ when "fedora30"
+ return "generic/fedora30"
+ when "fedora31"
+ return "generic/fedora31"
+ when "fedora32"
+ return "generic/fedora32"
+ when "arch"
+ return "generic/arch"
+ when "freebsd11"
+ return "generic/freebsd11"
+ when "freebsd12"
+ return "generic/freebsd12"
+ when "clearlinux"
+ return "AntonioMeireles/ClearLinux"
+ else
+ "Invalid argument #{distro}"
+ abort("Invalid argument!")
+ end
+ end
+end
+
+Vagrant.configure(2) do |config|
+
+ # Pick the right distro and bootstrap, default is fedora30
+ distro = ( ENV['SPDK_VAGRANT_DISTRO'] || "fedora30")
+ provider = (ENV['SPDK_VAGRANT_PROVIDER'] || "virtualbox")
+
+ # Get all variables for creating vm
+ vmcpu=(ENV['SPDK_VAGRANT_VMCPU'] || 2)
+ vmram=(ENV['SPDK_VAGRANT_VMRAM'] || 4096)
+ spdk_dir=(ENV['SPDK_DIR'] || "none")
+ vmemulator=(ENV['SPDK_QEMU_EMULATOR'] || "")
+ emulated_nvme_types=(ENV['NVME_DISKS_TYPE'] || "nvme").split(',')
+ nvme_namespaces=(ENV['NVME_DISKS_NAMESPACES'] || "").split(',')
+ nvme_file=(ENV['NVME_FILE'] || "").split(',')
+ nvme_cmbs=(ENV['NVME_CMB'] || "").split(',')
+ vagrantfile_dir=(ENV['VAGRANTFILE_DIR'] || "none")
+
+ # generic/freebsd boxes do not work properly with vagrant-proxyconf and
+ # have issues installing rsync and sshfs for syncing files. NFS is
+ # pre-installed, so use it.
+ # generic/fedora boxes on the other hand have problems running NFS
+ # service so use sshfs+rsync combo instead.
+ plugins_sync_backend = {type: :sshfs}
+ # Remove --copy-links from default rsync cmdline since we do want to sync
+ # actual symlinks as well. Also, since copy is made between host and its
+ # local VM we don't need to worry about saturating the local link so skip
+ # the compression to speed up the whole transfer.
+ files_sync_backend = {type: "rsync", rsync__auto: false, rsync__args: ["--archive", "--verbose", "--delete"]}
+ if (distro.include? "freebsd") || (distro.include? "clearlinux")
+ plugins_sync_backend = {type: :nfs, nfs_udp: false}
+ files_sync_backend = {type: :nfs, nfs_udp: false, mount_options: ['ro']}
+ end
+ config.vm.box = checkboxtype(distro)
+ config.vm.box_check_update = false
+ config.vm.synced_folder '.', '/vagrant', disabled: true
+
+ # Copy in the .gitconfig if it exists
+ if File.file?(File.expand_path("~/.gitconfig"))
+ config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig"
+ end
+
+ # Copy the tsocks configuration file for use when installing some spdk test pool dependencies
+ if File.file?("/etc/tsocks.conf")
+ $tsocks_copy = <<-SCRIPT
+ sudo -s
+ mv -f tsocks.conf /etc/tsocks.conf
+ chown root /etc/tsocks.conf
+ chmod 644 /etc/tsocks.conf
+ SCRIPT
+ config.vm.provision "file", source: "/etc/tsocks.conf", destination: "tsocks.conf"
+ config.vm.provision "shell", inline: $tsocks_copy
+ end
+
+ # vagrant-cachier caches apt/yum etc to speed subsequent
+ # vagrant up
+ # to enable, run
+ # vagrant plugin install vagrant-cachier
+ #
+ if Vagrant.has_plugin?("vagrant-cachier")
+ config.cache.scope = :box
+ config.cache.synced_folder_opts = plugins_sync_backend
+ end
+
+ # use http proxy if avaiable
+ if ENV['http_proxy']
+ if Vagrant.has_plugin?("vagrant-proxyconf")
+ config.proxy.http = ENV['http_proxy']
+ config.proxy.https = ENV['https_proxy']
+ config.proxy.no_proxy = "localhost,127.0.0.1"
+ end
+
+ # Proxyconf does not seem to support FreeBSD boxes or at least it's
+ # docs do not mention that. Set up proxy configuration manually.
+ if distro.include?("freebsd")
+ $freebsd_proxy = <<-SCRIPT
+ sudo -s
+ echo "export http_proxy=#{ENV['http_proxy']}" >> /etc/profile
+ echo "export https_proxy=#{ENV['http_proxy']}" >> /etc/profile
+ echo "pkg_env: {http_proxy: #{ENV['http_proxy']}}" > /usr/local/etc/pkg.conf
+ chown root:wheel /usr/local/etc/pkg.conf
+ chmod 644 /usr/local/etc/pkg.conf
+ SCRIPT
+ config.vm.provision "shell", inline: $freebsd_proxy
+ end
+ end
+
+ # freebsd and clearlinux boxes in order to have spdk sources synced from
+ # host properly will use NFS with "ro" option enabled to prevent changes
+ # on host filesystem.
+ # To make sources usable in the guest VM we need to unmount them and use
+ # local copy.
+ if distro.include? "freebsd"
+ $freebsd_spdk_repo = <<-SCRIPT
+ sudo -s
+ cp -R /home/vagrant/spdk_repo/spdk /tmp/spdk
+ umount /home/vagrant/spdk_repo/spdk && rm -rf /home/vagrant/spdk_repo/spdk
+ mv /tmp/spdk /home/vagrant/spdk_repo/spdk
+ chown -R vagrant:vagrant /home/vagrant/spdk_repo/spdk
+ SCRIPT
+ config.vm.provision "shell", inline: $freebsd_spdk_repo
+ elsif distro.include? "clearlinux"
+ $clearlinux_spdk_repo = <<-SCRIPT
+ sudo -s
+ cp -R /home/vagrant/spdk_repo/spdk /tmp/spdk
+ umount /home/vagrant/spdk_repo/spdk && rm -rf /home/vagrant/spdk_repo/spdk
+ mv /tmp/spdk /home/vagrant/spdk_repo/spdk
+ chown -R clear:clear /home/vagrant/spdk_repo/spdk
+ SCRIPT
+ config.vm.provision "shell", inline: $clearlinux_spdk_repo
+ end
+
+ config.ssh.forward_agent = true
+ config.ssh.forward_x11 = true
+ if ENV['VAGRANT_PASSWORD_AUTH'] == "1"
+ config.ssh.username = "vagrant"
+ config.ssh.password = "vagrant"
+ end
+
+ config.vm.provider "virtualbox" do |vb|
+ vb.customize ["modifyvm", :id, "--ioapic", "on"]
+ vb.memory = "#{vmram}"
+ vb.cpus = "#{vmcpu}"
+
+ nvme_disk=(ENV['NVME_FILE'] || "nvme_disk.img")
+ unless File.exist? (nvme_disk)
+ vb.customize ["createhd", "--filename", nvme_disk, "--variant", "Fixed", "--size", "1024"]
+ vb.customize ["storagectl", :id, "--name", "nvme", "--add", "pcie", "--controller", "NVMe", "--portcount", "1", "--bootable", "off"]
+ vb.customize ["storageattach", :id, "--storagectl", "nvme", "--type", "hdd", "--medium", nvme_disk, "--port", "0"]
+ end
+
+ #support for the SSE4.x instruction is required in some versions of VB.
+ 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|
+ libvirt.random_hostname = "1"
+ libvirt.disk_bus = "virtio"
+
+ # generic/freebsd boxes need to be explicitly run with SCSI bus,
+ # otherwise boot process fails on mounting the disk
+ if (distro.include?("freebsd"))
+ libvirt.disk_bus = "scsi"
+ end
+
+ # Run generic/arch boxes explicitly with IDE bus,
+ # otherwise boot process fails on mounting the disk
+ if (distro.include?("arch"))
+ libvirt.disk_bus = "ide"
+ end
+
+ if not vmemulator.empty?
+ libvirt.emulator_path = "#{vmemulator}"
+ libvirt.machine_type = "pc"
+ end
+
+ # we put nvme_disk inside default pool to eliminate libvirt/SELinux Permissions Problems
+ # and to be able to run vagrant from user $HOME directory
+
+ # Loop to create all emulated disks set
+ emulated_nvme_types.each_with_index { |disk, index|
+ if ENV['NVME_FILE']
+ nvme_disk_id="#{disk}" + "-#{index}"
+ nvme_disk="#{nvme_file["#{index}".to_i]}"
+ else
+ nvme_disk="/var/lib/libvirt/images/nvme_disk.img"
+ end
+
+ unless File.exist? (nvme_disk)
+ puts "If run with libvirt provider please execute create_nvme_img.sh"
+ end
+
+ if disk == "nvme"
+ libvirt.qemuargs :value => "-drive"
+ libvirt.qemuargs :value => "format=raw,file=#{nvme_disk},if=none,id=#{nvme_disk_id}"
+ libvirt.qemuargs :value => "-device"
+ nvme_drive = "nvme,drive=#{nvme_disk_id},serial=1234#{index}"
+ if !nvme_namespaces["#{index}".to_i].nil? && nvme_namespaces["#{index}".to_i] != 1
+ nvme_drive << ",namespaces=#{nvme_namespaces["#{index}".to_i]}"
+ end
+ if !nvme_cmbs["#{index}".to_i].nil? && nvme_cmbs["#{index}".to_i] == "true"
+ # Fix the size of the buffer to 128M
+ nvme_drive << ",cmb_size_mb=128"
+ end
+ libvirt.qemuargs :value => nvme_drive
+ elsif disk == "ocssd"
+ libvirt.qemuargs :value => "-drive"
+ libvirt.qemuargs :value => "format=raw,file=#{nvme_disk},if=none,id=#{nvme_disk_id}"
+ libvirt.qemuargs :value => "-device"
+ # create ocssd drive with special parameters
+ # lba_index=4 it is LBA namespace format, 4 means that block size is 4K and have 64B metadata
+ # lnum_lun, lnum_pln, lpgs_per_blk, lsecs_per_pg, lblks_per_pln this are parameters describing the device geometry
+ # we need to multiply these parameters by ourselves to have backend file minimal size:
+ # in our case: 4K * 8 * 2 * 1536 * 2 * 45 = 8640 MB
+ libvirt.qemuargs :value => "nvme,drive=#{nvme_disk_id},serial=deadbeef,oacs=0,namespaces=1,lver=2,lba_index=4,mdts=10,lnum_lun=8,lnum_pln=2,lpgs_per_blk=1536,lsecs_per_pg=2,lblks_per_pln=45,metadata=#{nvme_disk}_ocssd_md,nsdatafile=#{nvme_disk}_ocssd_blknvme.ns,laer_thread_sleep=3000,stride=4"
+ end
+ }
+
+ libvirt.driver = "kvm"
+ libvirt.graphics_type = "vnc"
+ libvirt.memory = "#{vmram}"
+ libvirt.cpus = "#{vmcpu}"
+ libvirt.video_type = "cirrus"
+
+ if ENV['VAGRANT_HUGE_MEM'] == "1"
+ libvirt.memorybacking :hugepages
+ end
+
+ # Optional field if we want use other storage pools than default
+ # libvirt.storage_pool_name = "vm"
+ end
+
+ # rsync the spdk directory if provision hasn't happened yet
+ # Warning: rsync does not work with freebsd boxes, so this step is disabled
+ if ENV['COPY_SPDK_DIR'] == "1" && spdk_dir != "none"
+ config.vm.synced_folder "#{spdk_dir}", "/home/vagrant/spdk_repo/spdk", files_sync_backend
+ end
+
+ # rsync artifacts from build
+ if ENV['COPY_SPDK_ARTIFACTS'] == "1"
+ config.vm.synced_folder "#{vagrantfile_dir}/output", "/home/vagrant/spdk_repo/output", plugins_sync_backend
+ end
+
+ # provision the vm with all of the necessary spdk dependencies for running the autorun.sh tests
+ if ENV['DEPLOY_TEST_VM'] == "1" && spdk_dir != "none"
+ config.vm.provision "shell" do |setup|
+ setup.path = "#{spdk_dir}/test/common/config/vm_setup.sh"
+ setup.privileged = false
+ setup.args = ["-u", "-i"]
+ end
+ end
+
+ # Clear CFLAGS in clear linux
+ if distro == "clearlinux"
+ $clearcflags = <<-SCRIPT
+ echo "export CFLAGS=" >> /etc/profile.d/clearcflags.sh
+ echo "export CFFLAGS=" >> /etc/profile.d/clearcflags.sh
+ echo "export CXXFLAGS=" >> /etc/profile.d/clearcflags.sh
+ echo "export FFLAGS=" >> /etc/profile.d/clearcflags.sh
+ echo "export THEANO_FLAGS=" >> /etc/profile.d/clearcflags.sh
+ SCRIPT
+ config.vm.provision "shell", inline: $clearcflags, run: "always"
+ 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", files_sync_backend
+ end
+end
diff --git a/src/spdk/scripts/vagrant/Vagrantfile_openstack_vm b/src/spdk/scripts/vagrant/Vagrantfile_openstack_vm
new file mode 100644
index 000000000..c66405a2c
--- /dev/null
+++ b/src/spdk/scripts/vagrant/Vagrantfile_openstack_vm
@@ -0,0 +1,82 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+Vagrant.configure(2) do |config|
+
+ # See: https://app.vagrantup.com/bento/boxes/ubuntu-18.04
+ config.vm.box = "bento/ubuntu-18.04"
+ config.vm.box_check_update = false
+
+ config.vm.provider :virtualbox do |vb|
+ vb.customize ["modifyvm", :id, "--hwvirtex", "off"]
+ end
+ if Vagrant.has_plugin?("vagrant-cachier")
+ config.cache.scope = :box
+ end
+
+ # use http proxy if avaiable
+ if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
+ config.proxy.http = ENV['http_proxy']
+ config.proxy.https = ENV['http_proxy']
+ config.proxy.no_proxy = "localhost,127.0.0.1,10.0.2.15"
+ end
+
+ vmcpu=(ENV['SPDK_VAGRANT_VMCPU'] || 10)
+ vmram=(ENV['SPDK_VAGRANT_VMRAM'] || 8192)
+ spdk_dir=(ENV['SPDK_DIR'] || "none")
+
+ config.ssh.forward_agent = true
+ config.ssh.forward_x11 = true
+
+ # Change root passwd and allow root SSH
+ config.vm.provision "shell", inline: 'echo -e "root\nroot" | sudo passwd root'
+ config.vm.provision "shell", inline: 'sudo sh -c "echo \"PermitRootLogin yes\" >> /etc/ssh/sshd_config"'
+ config.vm.provision "shell", inline: 'useradd -m -p sys_sgci -s /bin/bash sys_sgci'
+ config.vm.provision "shell", inline: 'usermod -aG sudo sys_sgci'
+
+ # Install needed deps
+ $apt_script = <<-SCRIPT
+ sudo apt -y update
+ sudo DEBIAN_FRONTEND=noninteractive apt -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
+ SCRIPT
+ config.vm.provision "shell", inline: $apt_script
+
+ # TODO: Next 2 lines break any future ssh communication via "vagrant ssh"
+ # I'd be good to check NIC names in ifconfig and then sed them in /etc/network/interfaces to eht0, eht1, and so on
+ config.vm.provision "shell", inline: 'sudo sh -c "echo \"auto eth0\" >> /etc/network/interfaces"'
+ config.vm.provision "shell", inline: 'sudo sh -c "echo \"iface eth0 inet dhcp\" >> /etc/network/interfaces"'
+
+ # This is to avoid annoying "Start job is running for wait for network to be configured" 2 minute timeout
+ # in case of not-so-perfect NIC and virtual network configuration for the VM
+ config.vm.provision "shell", inline: 'systemctl disable systemd-networkd-wait-online.service'
+ config.vm.provision "shell", inline: 'systemctl mask systemd-networkd-wait-online.service'
+
+ config.vm.provider "virtualbox" do |vb|
+ vb.customize ["modifyvm", :id, "--ioapic", "on"]
+ vb.memory = "#{vmram}"
+ vb.cpus = "#{vmcpu}"
+
+ #support for the SSE4.x instruction is required in some versions of VB.
+ vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.1", "1"]
+ vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.2", "1"]
+ end
+
+ if spdk_dir != "none"
+ config.vm.synced_folder "#{spdk_dir}", "/home/vagrant/spdk", type: "rsync",
+ rsync__exclude: ["ubuntu18"]
+ end
+
+ # Install needed drivers and tools
+ config.vm.provision "shell", inline: 'sudo apt-get install -y libibverbs* librdmacm* libnuma-dev libaio-dev libcunit1-dev ibverbs-utils rdma-core'
+
+ # 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
+ end
+
+ config.vm.provision "shell", inline: 'sudo useradd -s /bin/bash -d /opt/stack -m stack | echo "stack ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack'
+ config.vm.provision "shell", inline: 'sudo su - stack bash -c "git clone -b stable/stein https://git.openstack.org/openstack-dev/devstack /opt/stack/devstack"'
+ config.vm.provision "file", source: "#{spdk_dir}/scripts/vagrant/local.conf", destination: "/home/vagrant/local.conf"
+ config.vm.provision "shell", inline: 'sudo su - stack bash -c "cp /home/vagrant/local.conf /opt/stack/devstack"'
+ config.vm.provision "shell", inline: 'sudo su - stack bash -c "cd /opt/stack/devstack; ./stack.sh"'
+end
diff --git a/src/spdk/scripts/vagrant/Vagrantfile_vhost_vm b/src/spdk/scripts/vagrant/Vagrantfile_vhost_vm
new file mode 100644
index 000000000..4daeb105f
--- /dev/null
+++ b/src/spdk/scripts/vagrant/Vagrantfile_vhost_vm
@@ -0,0 +1,138 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+Vagrant.configure(2) do |config|
+
+ # Pick the right distro and bootstrap, default is ubuntu1604
+ distro = ( ENV['SPDK_VAGRANT_DISTRO'] || "ubuntu16")
+ case distro
+ when "ubuntu16"
+ # See: https://app.vagrantup.com/puppetlabs/boxes/ubuntu-16.04-64-nocm
+ config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
+ config.vm.box_version = "1.0.0"
+ when "ubuntu18"
+ # See: https://app.vagrantup.com/bento/boxes/ubuntu-18.04
+ config.vm.box = "bento/ubuntu-18.04"
+ config.vm.box_version = "201808.24.0"
+ when "fedora31"
+ # See: https://app.vagrantup.com/generic/boxes/fedora31
+ config.vm.box = "generic/fedora31"
+ config.vm.box_version = "2.0.6"
+ else
+ "Invalid argument #{distro}"
+ abort("Invalid argument!")
+ end
+ config.vm.box_check_update = false
+
+ # vagrant-cachier caches apt/yum etc to speed subsequent
+ # vagrant up
+ # to enable, run
+ # vagrant plugin install vagrant-cachier
+ #
+ if Vagrant.has_plugin?("vagrant-cachier")
+ config.cache.scope = :box
+ end
+
+ # use http proxy if avaiable
+ if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
+ config.proxy.http = ENV['http_proxy']
+ config.proxy.https = ENV['https_proxy']
+ config.proxy.no_proxy = "localhost,127.0.0.1"
+ end
+
+ vmcpu=(ENV['SPDK_VAGRANT_VMCPU'] || 2)
+ vmram=(ENV['SPDK_VAGRANT_VMRAM'] || 4096)
+ ssh_key_dir=(ENV['SPDK_VAGRANT_SSH_KEY'])
+ spdk_dir=(ENV['SPDK_DIR'] || "none")
+ install_deps=(ENV['INSTALL_DEPS'] || "false")
+
+ config.ssh.forward_agent = true
+ config.ssh.forward_x11 = true
+
+ # Change root passwd and allow root SSH
+ config.vm.provision "shell", inline: 'echo -e "root\nroot" | sudo passwd root'
+ config.vm.provision "shell", inline: 'sudo sh -c "echo \"PermitRootLogin yes\" >> /etc/ssh/sshd_config"'
+
+ # Use previously generated SSH keys for setting up a key pair
+ $ssh_key_gen_script = <<-SCRIPT
+ sudo mkdir -p /root/.ssh
+ cat /vagrant/ssh_keys/spdk_vhost_id_rsa.pub > /root/.ssh/authorized_keys
+ sudo chmod 644 /root/.ssh/authorized_keys
+ SCRIPT
+ config.vm.provision "shell", inline: $ssh_key_gen_script
+
+ # Install needed deps
+ $apt_script = <<-SCRIPT
+ sudo apt -y update
+ sudo DEBIAN_FRONTEND=noninteractive apt -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
+ sudo apt -y install -y fio sg3-utils bc
+ SCRIPT
+
+ $dnf_script = <<-SCRIPT
+ sudo dnf -y update
+ sudo dnf -y install fio sg3_utils bc
+ SCRIPT
+
+ $install_script = case distro
+ when "ubuntu16" then $apt_script
+ when "ubuntu18" then $apt_script
+ when "fedora31" then $dnf_script
+ else abort("#{distro} distribution is not supported yet")
+ end
+
+ config.vm.provision "shell", inline: $install_script
+
+ # Modify GRUB options
+ # console=ttyS0 earlyprintk=ttyS0 - reroute output to serial dev, so that QEMU can write output to file
+ # scsi_mod.use_blk_mq=1 - for multiqueue use
+ # net.ifnames=0 biosdevname=0 - do not rename NICs on boot. That way we ensure that addded NIC is always eth0.
+ # Reason for these options is that NIC can have different udev name during provisioning with Vagrant
+ # and then some other name while running SPDK tests which use Qemu without any hypervisor like vbox or libvirt
+ # so no corresponding configuration for this NIC name will be present in /etc.
+ config.vm.provision "shell", inline: 'sudo sed -ir s#GRUB_CMDLINE_LINUX=#GRUB_CMDLINE_LINUX=\"console=ttyS0\ earlyprintk=ttyS0\ scsi_mod.use_blk_mq=1\ net.ifnames=0\ biosdevname=0\"#g /etc/default/grub'
+ config.vm.provision "shell", inline: 'sudo sed -ir s#\"\"#\ #g /etc/default/grub'
+
+ update_grub_command = case distro
+ when "ubuntu16" then 'sudo update-grub'
+ when "ubuntu18" then 'sudo update-grub'
+ when "fedora31" then 'sudo grub2-mkconfig -o /boot/grub2/grub.cfg ; sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg'
+ else abort("#{distro} distribution is not supported yet")
+ end
+ config.vm.provision "shell", inline: update_grub_command
+
+ if distro.include? "ubuntu"
+ # TODO: Next 2 lines break any future ssh communication via "vagrant ssh"
+ # I'd be good to check NIC names in ifconfig and then sed them in /etc/network/interfaces to eht0, eht1, and so on
+ config.vm.provision "shell", inline: 'sudo sh -c "echo \"auto eth0\" >> /etc/network/interfaces"'
+ config.vm.provision "shell", inline: 'sudo sh -c "echo \"iface eth0 inet dhcp\" >> /etc/network/interfaces"'
+ end
+
+ if distro.include? "ubuntu18"
+ # This is to avoid annoying "Start job is running for wait for network to be configured" 2 minute timeout
+ # in case of not-so-perfect NIC and virtual network configuration for the VM
+ config.vm.provision "shell", inline: 'systemctl disable systemd-networkd-wait-online.service'
+ config.vm.provision "shell", inline: 'systemctl mask systemd-networkd-wait-online.service'
+ end
+
+ config.vm.provider "virtualbox" do |vb|
+ vb.customize ["modifyvm", :id, "--ioapic", "on"]
+ vb.memory = "#{vmram}"
+ vb.cpus = "#{vmcpu}"
+
+ #support for the SSE4.x instruction is required in some versions of VB.
+ vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.1", "1"]
+ vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.2", "1"]
+ end
+
+ if spdk_dir != "none"
+ config.vm.synced_folder "#{spdk_dir}", "/home/vagrant/spdk_repo/spdk", type: "rsync", rsync__auto: false
+ if install_deps.include? "true"
+ config.vm.provision "shell", inline: 'sudo /home/vagrant/spdk_repo/spdk/scripts/pkgdep.sh --all'
+ end
+ 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
+ end
+end
diff --git a/src/spdk/scripts/vagrant/autorun-spdk.conf b/src/spdk/scripts/vagrant/autorun-spdk.conf
new file mode 100644
index 000000000..067522c6f
--- /dev/null
+++ b/src/spdk/scripts/vagrant/autorun-spdk.conf
@@ -0,0 +1,31 @@
+# assign a value of 1 to all of the pertinent tests
+SPDK_RUN_VALGRIND=1
+SPDK_RUN_FUNCTIONAL_TEST=1
+SPDK_TEST_UNITTEST=1
+SPDK_TEST_AUTOBUILD=1
+SPDK_TEST_ISAL=1
+SPDK_TEST_ISCSI=0
+SPDK_TEST_ISCSI_INITIATOR=0
+SPDK_TEST_NVME=0
+SPDK_TEST_NVME_CLI=0
+SPDK_TEST_NVMF=1
+SPDK_TEST_RBD=0
+SPDK_TEST_CRYPTO=0
+SPDK_TEST_OCF=0
+# requires some extra configuration. see TEST_ENV_SETUP_README
+SPDK_TEST_VHOST=0
+SPDK_TEST_VHOST_INIT=0
+SPDK_TEST_BLOCKDEV=1
+SPDK_TEST_URING=0
+# doesn't work on vm
+SPDK_TEST_IOAT=0
+SPDK_TEST_BLOBFS=0
+SPDK_TEST_PMDK=0
+SPDK_TEST_LVOL=0
+SPDK_TEST_REDUCE=0
+SPDK_RUN_ASAN=1
+SPDK_RUN_UBSAN=1
+# Reduce the size of the hugepages
+HUGEMEM=1024
+# Set up the DEPENDENCY_DIR
+DEPENDENCY_DIR=/home/vagrant
diff --git a/src/spdk/scripts/vagrant/create_nvme_img.sh b/src/spdk/scripts/vagrant/create_nvme_img.sh
new file mode 100755
index 000000000..db758bd87
--- /dev/null
+++ b/src/spdk/scripts/vagrant/create_nvme_img.sh
@@ -0,0 +1,77 @@
+#!/usr/bin/env bash
+SYSTEM=$(uname -s)
+size="1024M"
+nvme_disk="/var/lib/libvirt/images/nvme_disk.img"
+type="nvme"
+
+function usage() {
+ echo "Usage: ${0##*/} [-s <disk_size>] [-n <backing file name>]"
+ echo "-s <disk_size> with postfix e.g. 2G default: 1024M"
+ echo " for OCSSD default: 9G"
+ echo "-n <backing file name> backing file path with name"
+ echo " default: /var/lib/libvirt/images/nvme_disk.img"
+ echo "-t <type> default: nvme available: ocssd"
+}
+
+while getopts "s:n:t:h-:" opt; do
+ case "${opt}" in
+ -)
+ echo " Invalid argument: $OPTARG"
+ usage
+ exit 1
+ ;;
+ s)
+ size=$OPTARG
+ ;;
+ n)
+ nvme_disk=$OPTARG
+ ;;
+ t)
+ type=$OPTARG
+ ;;
+ h)
+ usage
+ exit 0
+ ;;
+ *)
+ echo " Invalid argument: $OPTARG"
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+if [ ! "${SYSTEM}" = "FreeBSD" ]; then
+ WHICH_OS=$(lsb_release -i | awk '{print $3}')
+ case $type in
+ "nvme")
+ qemu-img create -f raw $nvme_disk $size
+ ;;
+ "ocssd")
+ if [ $size == "1024M" ]; then
+ size="9G"
+ fi
+ fallocate -l $size $nvme_disk
+ touch ${nvme_disk}_ocssd_md
+ ;;
+ *)
+ echo "We support only nvme and ocssd disks types"
+ exit 1
+ ;;
+ esac
+ #Change SE Policy on Fedora
+ if [ $WHICH_OS == "Fedora" ]; then
+ sudo chcon -t svirt_image_t $nvme_disk
+ fi
+
+ chmod 777 $nvme_disk
+ if [ $WHICH_OS == "Fedora" ]; then
+ chown qemu:qemu $nvme_disk
+ elif [ $WHICH_OS == "Ubuntu" ]; then
+ chown libvirt-qemu:kvm $nvme_disk
+ else
+ # That's just a wild guess for now
+ # TODO: needs improvement for other distros
+ chown libvirt-qemu:kvm $nvme_disk
+ fi
+fi
diff --git a/src/spdk/scripts/vagrant/create_openstack_vm.sh b/src/spdk/scripts/vagrant/create_openstack_vm.sh
new file mode 100755
index 000000000..a747b2808
--- /dev/null
+++ b/src/spdk/scripts/vagrant/create_openstack_vm.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+
+set -e
+
+testdir=$(readlink -f $(dirname $0))
+SPDK_DIR=$(readlink -f $testdir/../..)
+VAGRANT_TARGET="$PWD"
+VAGRANT_DISTRO="ubuntu18"
+
+export SPDK_DIR
+export SPDK_VAGRANT_VMRAM=8192
+export SPDK_VAGRANT_VMCPU=10
+
+mkdir -vp "${VAGRANT_TARGET}/${VAGRANT_DISTRO}"
+cp "${testdir}/Vagrantfile_openstack_vm" "${VAGRANT_TARGET}/${VAGRANT_DISTRO}/Vagrantfile"
+
+pushd "${VAGRANT_TARGET}/${VAGRANT_DISTRO}"
+if [ -n "${http_proxy}" ]; then
+ export http_proxy
+fi
+
+VBoxManage setproperty machinefolder "${VAGRANT_TARGET}/${VAGRANT_DISTRO}"
+vagrant up
+vagrant halt
+VBoxManage setproperty machinefolder default
+
+# Convert Vbox .vmdk image to qcow2
+vmdk_img=$(find ${VAGRANT_TARGET}/${VAGRANT_DISTRO} -name "ubuntu-18.04-amd64-disk001.vmdk")
+qemu-img convert -f vmdk -O qcow2 ${vmdk_img} ${VAGRANT_TARGET}/${VAGRANT_DISTRO}/openstack_vm_image.qcow2
+
+echo ""
+echo " SUCCESS!"
+echo ""
diff --git a/src/spdk/scripts/vagrant/create_vbox.sh b/src/spdk/scripts/vagrant/create_vbox.sh
new file mode 100755
index 000000000..71fd46d12
--- /dev/null
+++ b/src/spdk/scripts/vagrant/create_vbox.sh
@@ -0,0 +1,334 @@
+#!/usr/bin/env bash
+
+# create_vbox.sh
+#
+# Creates a virtual box with vagrant in the $PWD.
+#
+# This script creates a subdirectory called $PWD/<distro> and copies the Vagrantfile
+# into that directory before running 'vagrant up'
+
+set -e
+
+VAGRANT_TARGET="$PWD"
+
+DIR="$(cd "$(dirname $0)" && pwd)"
+SPDK_DIR="$(cd "${DIR}/../../" && pwd)"
+
+# The command line help
+display_help() {
+ echo
+ echo " Usage: ${0##*/} [-b nvme-backing-file] [-n <num-cpus>] [-s <ram-size>] [-x <http-proxy>] [-hvrldcu] <distro>"
+ echo
+ echo " distro = <centos7 | centos8| ubuntu1604 | ubuntu1804 | fedora30 |"
+ echo " fedora31 | fedora32 | freebsd11 | freebsd12 | arch | clearlinux>"
+ echo
+ 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\". Default: ${SPDK_VAGRANT_PROVIDER}"
+ echo " -b <nvme-backing-file> Emulated NVMe options."
+ echo " If no -b option is specified then this option defaults to emulating single"
+ echo " NVMe with 1 namespace and assumes path: /var/lib/libvirt/images/nvme_disk.img"
+ echo " -b option can be used multiple times for attaching multiple files to the VM"
+ echo " Parameters for -b option: <path>,<type>,<namespaces>,<cmb>"
+ echo " Available types: nvme, ocssd."
+ echo " -c Create all above disk, default 0"
+ echo " -H Use hugepages for allocating VM memory. Only for libvirt provider. Default: false."
+ echo " -u Use password authentication to the VM instead of SSH keys."
+ echo " -l Use a local copy of spdk, don't try to rsync from the host."
+ echo " -a Copy spdk/autorun.sh artifacts from VM to host system."
+ echo " -d Deploy a test vm by provisioning all prerequisites for spdk autotest"
+ echo " --qemu-emulator=<path> Path to custom QEMU binary. Only works with libvirt provider"
+ echo " --vagrantfiles-dir=<path> Destination directory to put Vagrantfile into."
+ echo " --package-box Install all dependencies for SPDK and create a local vagrant box version."
+ echo " -r dry-run"
+ echo " -h help"
+ echo " -v verbose"
+ echo
+ echo " Examples:"
+ echo
+ echo " $0 -x http://user:password@host:port fedora30"
+ echo " $0 -s 2048 -n 2 ubuntu16"
+ echo " $0 -rv freebsd"
+ echo " $0 fedora30"
+ echo " $0 -b /var/lib/libvirt/images/nvme1.img,nvme,1 fedora30"
+ echo " $0 -b /var/lib/libvirt/images/ocssd.img,ocssd fedora30"
+ echo " $0 -b /var/lib/libvirt/images/nvme5.img,nvme,5 -b /var/lib/libvirt/images/ocssd.img,ocssd fedora30"
+ echo
+}
+
+# Set up vagrant proxy. Assumes git-bash on Windows
+# https://stackoverflow.com/questions/19872591/how-to-use-vagrant-in-a-proxy-environment
+SPDK_VAGRANT_HTTP_PROXY=""
+
+VERBOSE=0
+HELP=0
+COPY_SPDK_DIR=1
+COPY_SPDK_ARTIFACTS=0
+DRY_RUN=0
+DEPLOY_TEST_VM=0
+SPDK_VAGRANT_DISTRO="distro"
+SPDK_VAGRANT_VMCPU=4
+SPDK_VAGRANT_VMRAM=4096
+SPDK_VAGRANT_PROVIDER="virtualbox"
+SPDK_QEMU_EMULATOR=""
+OPTIND=1
+NVME_DISKS_TYPE=""
+NVME_DISKS_NAMESPACES=""
+NVME_FILE=""
+NVME_AUTO_CREATE=0
+VAGRANTFILE_DIR=""
+VAGRANT_PASSWORD_AUTH=0
+VAGRANT_PACKAGE_BOX=0
+VAGRANT_HUGE_MEM=0
+
+while getopts ":b:n:s:x:p:u:vcraldHh-:" opt; do
+ case "${opt}" in
+ -)
+ case "${OPTARG}" in
+ package-box) VAGRANT_PACKAGE_BOX=1 ;;
+ qemu-emulator=*) SPDK_QEMU_EMULATOR="${OPTARG#*=}" ;;
+ vagrantfiles-dir=*) VAGRANTFILE_DIR="${OPTARG#*=}" ;;
+ *) echo "Invalid argument '$OPTARG'" ;;
+ esac
+ ;;
+ x)
+ http_proxy=$OPTARG
+ https_proxy=$http_proxy
+ SPDK_VAGRANT_HTTP_PROXY="${http_proxy}"
+ ;;
+ n)
+ SPDK_VAGRANT_VMCPU=$OPTARG
+ ;;
+ s)
+ SPDK_VAGRANT_VMRAM=$OPTARG
+ ;;
+ p)
+ SPDK_VAGRANT_PROVIDER=$OPTARG
+ ;;
+ v)
+ VERBOSE=1
+ ;;
+ c)
+ NVME_AUTO_CREATE=1
+ ;;
+ r)
+ DRY_RUN=1
+ ;;
+ h)
+ display_help >&2
+ exit 0
+ ;;
+ a)
+ COPY_SPDK_ARTIFACTS=1
+ ;;
+ l)
+ COPY_SPDK_DIR=0
+ ;;
+ d)
+ DEPLOY_TEST_VM=1
+ ;;
+ b)
+ NVME_FILE+="${OPTARG#*=} "
+ ;;
+ u)
+ VAGRANT_PASSWORD_AUTH=1
+ ;;
+ H)
+ VAGRANT_HUGE_MEM=1
+ ;;
+ *)
+ echo " Invalid argument: -$OPTARG" >&2
+ echo " Try: \"$0 -h\"" >&2
+ exit 1
+ ;;
+ esac
+done
+
+shift "$((OPTIND - 1))" # Discard the options and sentinel --
+
+SPDK_VAGRANT_DISTRO="$*"
+
+case "${SPDK_VAGRANT_DISTRO}" in
+ centos7)
+ export SPDK_VAGRANT_DISTRO
+ ;;
+ centos8)
+ export SPDK_VAGRANT_DISTRO
+ ;;
+ ubuntu1604)
+ export SPDK_VAGRANT_DISTRO
+ ;;
+ ubuntu1804)
+ export SPDK_VAGRANT_DISTRO
+ ;;
+ fedora30)
+ export SPDK_VAGRANT_DISTRO
+ ;;
+ fedora31)
+ export SPDK_VAGRANT_DISTRO
+ ;;
+ fedora32)
+ export SPDK_VAGRANT_DISTRO
+ ;;
+ freebsd11)
+ export SPDK_VAGRANT_DISTRO
+ ;;
+ freebsd12)
+ export SPDK_VAGRANT_DISTRO
+ ;;
+ arch)
+ export SPDK_VAGRANT_DISTRO
+ ;;
+ clearlinux)
+ export SPDK_VAGRANT_DISTRO
+ ;;
+ *)
+ echo " Invalid argument \"${SPDK_VAGRANT_DISTRO}\""
+ echo " Try: \"$0 -h\"" >&2
+ exit 1
+ ;;
+esac
+
+if ! echo "$SPDK_VAGRANT_DISTRO" | grep -q fedora && [ $DEPLOY_TEST_VM -eq 1 ]; then
+ echo "Warning: Test machine deployment is only available on fedora distros. Disabling it for this build"
+ DEPLOY_TEST_VM=0
+fi
+if [ -z "$NVME_FILE" ]; then
+ TMP="/var/lib/libvirt/images/nvme_disk.img"
+ NVME_DISKS_TYPE="nvme"
+else
+ TMP=""
+ for args in $NVME_FILE; do
+ while IFS=, read -r path type namespace cmb; do
+ TMP+="$path,"
+ if [ -z "$type" ]; then
+ type="nvme"
+ fi
+ if [[ -n $cmb ]]; then
+ NVME_CMB=${NVME_CMB:+$NVME_CMB,}true
+ fi
+ NVME_DISKS_TYPE+="$type,"
+ if [ -z "$namespace" ] && [ -n "$SPDK_QEMU_EMULATOR" ]; then
+ namespace="1"
+ fi
+ NVME_DISKS_NAMESPACES+="$namespace,"
+ if [ ${NVME_AUTO_CREATE} = 1 ]; then
+ $SPDK_DIR/scripts/vagrant/create_nvme_img.sh -t $type -n $path
+ fi
+ done <<< $args
+ done
+fi
+NVME_FILE=$TMP
+
+if [ ${VERBOSE} = 1 ]; then
+ echo
+ echo DIR=${DIR}
+ echo SPDK_DIR=${SPDK_DIR}
+ echo VAGRANT_TARGET=${VAGRANT_TARGET}
+ echo HELP=$HELP
+ echo DRY_RUN=$DRY_RUN
+ echo NVME_FILE=$NVME_FILE
+ echo NVME_DISKS_TYPE=$NVME_DISKS_TYPE
+ echo NVME_AUTO_CREATE=$NVME_AUTO_CREATE
+ echo NVME_DISKS_NAMESPACES=$NVME_DISKS_NAMESPACES
+ echo NVME_CMB=$NVME_CMB
+ echo SPDK_VAGRANT_DISTRO=$SPDK_VAGRANT_DISTRO
+ echo SPDK_VAGRANT_VMCPU=$SPDK_VAGRANT_VMCPU
+ echo SPDK_VAGRANT_VMRAM=$SPDK_VAGRANT_VMRAM
+ echo SPDK_VAGRANT_PROVIDER=$SPDK_VAGRANT_PROVIDER
+ echo SPDK_VAGRANT_HTTP_PROXY=$SPDK_VAGRANT_HTTP_PROXY
+ echo SPDK_QEMU_EMULATOR=$SPDK_QEMU_EMULATOR
+ echo VAGRANT_PACKAGE_BOX=$VAGRANT_PACKAGE_BOX
+ echo
+fi
+
+export SPDK_VAGRANT_HTTP_PROXY
+export SPDK_VAGRANT_VMCPU
+export SPDK_VAGRANT_VMRAM
+export SPDK_DIR
+export COPY_SPDK_DIR
+export COPY_SPDK_ARTIFACTS
+export DEPLOY_TEST_VM
+export NVME_CMB
+export NVME_DISKS_TYPE
+export NVME_DISKS_NAMESPACES
+export NVME_FILE
+export VAGRANT_PASSWORD_AUTH
+export VAGRANT_HUGE_MEM
+
+if [ -n "$SPDK_VAGRANT_PROVIDER" ]; then
+ provider="--provider=${SPDK_VAGRANT_PROVIDER}"
+fi
+
+if [ -n "$SPDK_VAGRANT_PROVIDER" ]; then
+ export SPDK_VAGRANT_PROVIDER
+fi
+
+if [ -n "$SPDK_QEMU_EMULATOR" ] && [ "$SPDK_VAGRANT_PROVIDER" == "libvirt" ]; then
+ export SPDK_QEMU_EMULATOR
+fi
+
+if [ ${DRY_RUN} = 1 ]; then
+ echo "Environemnt Variables"
+ printenv SPDK_VAGRANT_DISTRO
+ printenv SPDK_VAGRANT_VMRAM
+ printenv SPDK_VAGRANT_VMCPU
+ printenv SPDK_VAGRANT_PROVIDER
+ printenv SPDK_VAGRANT_HTTP_PROXY
+ printenv SPDK_QEMU_EMULATOR
+ printenv NVME_DISKS_TYPE
+ printenv NVME_AUTO_CREATE
+ printenv NVME_DISKS_NAMESPACES
+ printenv NVME_FILE
+ printenv SPDK_DIR
+ printenv VAGRANT_HUGE_MEM
+fi
+if [ -z "$VAGRANTFILE_DIR" ]; then
+ VAGRANTFILE_DIR="${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}-${SPDK_VAGRANT_PROVIDER}"
+ export VAGRANTFILE_DIR
+fi
+
+if [ -d "${VAGRANTFILE_DIR}" ]; then
+ echo "Error: ${VAGRANTFILE_DIR} already exists!"
+ exit 1
+fi
+
+if [ ${DRY_RUN} != 1 ]; then
+ mkdir -vp "${VAGRANTFILE_DIR}"
+ cp ${DIR}/Vagrantfile ${VAGRANTFILE_DIR}
+ pushd "${VAGRANTFILE_DIR}"
+ if [ -n "${http_proxy}" ]; then
+ export http_proxy
+ export https_proxy
+ if vagrant plugin list | grep -q vagrant-proxyconf; then
+ echo "vagrant-proxyconf already installed... skipping"
+ else
+ vagrant plugin install vagrant-proxyconf
+ fi
+ if echo "$SPDK_VAGRANT_DISTRO" | grep -q freebsd; then
+ cat > ~/vagrant_pkg.conf << EOF
+pkg_env: {
+http_proxy: ${http_proxy}
+}
+EOF
+ fi
+ fi
+ mkdir -p "${VAGRANTFILE_DIR}/output"
+ vagrant up $provider
+ if [ ${VAGRANT_PACKAGE_BOX} == 1 ]; then
+ vagrant ssh -c 'sudo spdk_repo/spdk/scripts/vagrant/update.sh'
+ vagrant halt
+ vagrant package --output spdk_${SPDK_VAGRANT_DISTRO}.box
+ vagrant box add spdk/${SPDK_VAGRANT_DISTRO} spdk_${SPDK_VAGRANT_DISTRO}.box \
+ && rm spdk_${SPDK_VAGRANT_DISTRO}.box
+ vagrant destroy
+ fi
+ echo ""
+ echo " SUCCESS!"
+ echo ""
+ echo " cd to ${VAGRANTFILE_DIR} and type \"vagrant ssh\" to use."
+ echo " Use vagrant \"suspend\" and vagrant \"resume\" to stop and start."
+ echo " Use vagrant \"destroy\" followed by \"rm -rf ${VAGRANTFILE_DIR}\" to destroy all trace of vm."
+ echo ""
+fi
diff --git a/src/spdk/scripts/vagrant/create_vhost_vm.sh b/src/spdk/scripts/vagrant/create_vhost_vm.sh
new file mode 100755
index 000000000..5ad416c3b
--- /dev/null
+++ b/src/spdk/scripts/vagrant/create_vhost_vm.sh
@@ -0,0 +1,132 @@
+#!/usr/bin/env bash
+
+# create_vhost_vm.sh
+#
+# Creates a virtual machine image used as a dependency for running vhost tests
+
+set -e
+
+VAGRANT_TARGET="$PWD"
+
+DIR="$(cd "$(dirname $0)" && pwd)"
+SPDK_DIR="$(cd "${DIR}/../../" && pwd)"
+USE_SSH_DIR=""
+MOVE_TO_DEFAULT_DIR=false
+INSTALL_DEPS=false
+
+# The command line help
+display_help() {
+ echo
+ echo " Usage: ${0##*/} <distro>"
+ echo
+ echo " distro = <ubuntu16 | ubuntu18 | fedora31> "
+ echo
+ echo " --use-ssh-dir=<dir path> Use existing spdk_vhost_id_rsa keys from specified directory"
+ echo " for setting up SSH key pair on VM"
+ echo " --install-deps Install SPDK build dependencies on VM. Needed by some of the"
+ echo " vhost and vhost initiator tests. Default: false."
+ echo " --move-to-default-dir Move generated files to default directories used by vhost test scripts."
+ echo " Default: false."
+ echo " --http-proxy Default: \"${SPDK_VAGRANT_HTTP_PROXY}\""
+ echo " -h help"
+ echo
+ echo " Examples:"
+ echo
+}
+
+while getopts ":h-:" opt; do
+ case "${opt}" in
+ -)
+ case "${OPTARG}" in
+ use-ssh-dir=*) USE_SSH_DIR="${OPTARG#*=}" ;;
+ move-to-default-dir) MOVE_TO_DEFAULT_DIR=true ;;
+ install-deps) INSTALL_DEPS=true ;;
+ http-proxy=*)
+ http_proxy=$OPTARG
+ https_proxy=$http_proxy
+ SPDK_VAGRANT_HTTP_PROXY="${http_proxy}"
+ ;;
+ *)
+ echo " Invalid argument -$OPTARG" >&2
+ echo " Try \"$0 -h\"" >&2
+ exit 1
+ ;;
+ esac
+ ;;
+ h)
+ display_help >&2
+ exit 0
+ ;;
+ *)
+ echo " Invalid argument: -$OPTARG" >&2
+ echo " Try: \"$0 -h\"" >&2
+ exit 1
+ ;;
+ esac
+done
+export SPDK_DIR
+export SPDK_VAGRANT_HTTP_PROXY
+export INSTALL_DEPS
+
+shift "$((OPTIND - 1))" # Discard the options and sentinel --
+
+SPDK_VAGRANT_DISTRO="$*"
+
+case "${SPDK_VAGRANT_DISTRO}" in
+ ubuntu16)
+ export SPDK_VAGRANT_DISTRO
+ ;;
+ ubuntu18)
+ export SPDK_VAGRANT_DISTRO
+ ;;
+ fedora31)
+ export SPDK_VAGRANT_DISTRO
+ ;;
+ *)
+ echo " Invalid argument \"${SPDK_VAGRANT_DISTRO}\""
+ echo " Try: \"$0 -h\"" >&2
+ exit 1
+ ;;
+esac
+
+mkdir -vp "${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}"
+cp ${DIR}/Vagrantfile_vhost_vm ${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}/Vagrantfile
+
+# Copy or generate SSH keys to the VM
+mkdir -vp "${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}/ssh_keys"
+
+if [[ -n $USE_SSH_DIR ]]; then
+ cp ${USE_SSH_DIR}/spdk_vhost_id_rsa* "${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}/ssh_keys"
+else
+ ssh-keygen -f "${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}/ssh_keys/spdk_vhost_id_rsa" -N "" -q
+fi
+export SPDK_VAGRANT_SSH_KEY="${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}/ssh_keys/spdk_vhost_id_rsa"
+
+pushd "${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}"
+if [ -n "${http_proxy}" ]; then
+ export http_proxy
+ export https_proxy
+ if vagrant plugin list | grep -q vagrant-proxyconf; then
+ echo "vagrant-proxyconf already installed... skipping"
+ else
+ vagrant plugin install vagrant-proxyconf
+ fi
+fi
+VBoxManage setproperty machinefolder "${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}"
+vagrant up
+vagrant halt
+VBoxManage setproperty machinefolder default
+
+# Convert Vbox .vmkd image to qcow2
+vmdk_img=$(find ${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO} -name "*.vmdk")
+qemu-img convert -f vmdk -O qcow2 ${vmdk_img} ${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}/vhost_vm_image.qcow2
+
+if $MOVE_TO_DEFAULT_DIR; then
+ sudo mkdir -p /home/sys_sgsw
+ sudo mv -f ${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}/vhost_vm_image.qcow2 /home/sys_sgsw/vhost_vm_image.qcow2
+ sudo mv -f ${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}/ssh_keys/spdk_vhost_id_rsa* ~/.ssh/
+fi
+
+echo ""
+echo " SUCCESS!"
+echo ""
diff --git a/src/spdk/scripts/vagrant/local.conf b/src/spdk/scripts/vagrant/local.conf
new file mode 100644
index 000000000..f392d4bbb
--- /dev/null
+++ b/src/spdk/scripts/vagrant/local.conf
@@ -0,0 +1,51 @@
+[[local|localrc]]
+ADMIN_PASSWORD=secret
+DATABASE_PASSWORD=secret
+RABBIT_PASSWORD=secret
+SERVICE_PASSWORD=secret
+HOST_IP=10.0.2.15
+USE_PYTHON3=True
+
+# These options define expected driver capabilities
+TEMPEST_VOLUME_DRIVER=spdk
+TEMPEST_VOLUME_VENDOR="Intel"
+TEMPEST_STORAGE_PROTOCOL=nvmet_rdma
+
+# Disable security groups entirely
+Q_USE_SECGROUP=False
+LIBVIRT_FIREWALL_DRIVER=nova.virt.firewall.NoopFirewallDriver
+CINDER_SECURE_DELETE=False
+public_interface=eth0
+
+[[test-config|$TEMPEST_CONFIG]]
+[compute]
+build_timeout = 1500
+fixed_network_name = net0
+
+[volume]
+build_timeout = 1500
+
+[validation]
+ssh_timeout = 396
+
+[[post-config|$CINDER_CONF]]
+[DEFAULT]
+default_volume_type = SPDK
+enabled_backends = spdk
+target_helper = spdk-nvmeof
+debug = True
+
+[spdk]
+spdk_rpc_ip = localhost
+spdk_rpc_port = 3333
+spdk_rpc_username = secret
+spdk_rpc_password = secret
+target_ip_address = 10.0.2.15
+target_port = 4260
+target_protocol = nvmet_rdma
+target_helper = spdk-nvmeof
+target_prefix = nqn.2014-08.org.spdk
+volume_driver = cinder.volume.drivers.spdk.SPDKDriver
+volume_backend_name = SPDK
+spdk_max_queue_depth = 64
+image_volume_cache_enabled = True
diff --git a/src/spdk/scripts/vagrant/run-autorun.sh b/src/spdk/scripts/vagrant/run-autorun.sh
new file mode 100755
index 000000000..28cefe474
--- /dev/null
+++ b/src/spdk/scripts/vagrant/run-autorun.sh
@@ -0,0 +1,245 @@
+#!/bin/bash
+
+#
+# BSD LICENSE
+#
+# Copyright (c) 2018 by NetApp, Inc.
+# All Rights Reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+if [ -z "${MAKE}" ]; then
+ export MAKE=make
+fi
+
+if [ -z "${GIT}" ]; then
+ export GIT=git
+fi
+
+if [ -z "${READLINK}" ]; then
+ export READLINK=readlink
+fi
+
+AUTOTEST_DRIVER_PATH=$($READLINK -f ${BASH_SOURCE%/*})
+SPDK_AUTOTEST_LOCAL_PATH=$PWD
+TIMESTAMP=$(date +"%Y%m%d%H%M%S")
+BUILD_NAME="build-${TIMESTAMP}"
+
+# The command line help
+display_help() {
+ echo
+ echo "Usage: $0 -d <path_to_spdk_tree> [-h] | [-q] | [-n]"
+ echo " -d : Specify a path to an SPDK source tree"
+ echo " -q : No output to screen"
+ echo " -n : Noop - dry-run"
+ echo " -h : This help"
+ echo
+ echo "Examples:"
+ echo " run-spdk-autotest.sh -d . -q"
+ echo " run-spdk-autotest.sh -d /home/vagrant/spdk_repo/spdk"
+ echo
+}
+
+set -e
+
+NOOP=0
+METHOD=0
+V=1
+OPTIND=1 # Reset in case getopts has been used previously in the shell.
+while getopts "d:qhn" opt; do
+ case "$opt" in
+ d)
+ SPDK_SOURCE_PATH=$($READLINK -f $OPTARG)
+ echo Using SPDK source at ${SPDK_SOURCE_PATH}
+ METHOD=1
+ ;;
+ q)
+ V=0
+ ;;
+ n)
+ NOOP=1
+ ;;
+ h)
+ display_help >&2
+ exit 0
+ ;;
+ *)
+ echo "Invalid option"
+ echo ""
+ display_help >&2
+ exit 1
+ ;;
+ esac
+done
+
+if [ -z "${SPDK_SOURCE_PATH}" ]; then
+ echo "Error: Must specify a source path "
+ display_help
+ exit 1
+fi
+
+# The following code verifies the input parameters and sets up the following variables:
+#
+# SPDK_AUTOTEST_LOCAL_PATH
+# GIT_REPO_PATH
+# GIT_BRANCH
+#
+
+case "$METHOD" in
+ 1)
+ if [ ! -d "${SPDK_SOURCE_PATH}" ]; then
+ echo "${SPDK_SOURCE_PATH} does not exist!"
+ exit 1
+ fi
+ if [ ! -d "${SPDK_SOURCE_PATH}/.git" ]; then
+ echo "${SPDK_SOURCE_PATH} is not a git repository"
+ exit 1
+ fi
+
+ GIT_REPO_SRC_DIR=$($READLINK -f "${SPDK_SOURCE_PATH}" | tr -t '/' ' ' | awk '{print $NF}')
+
+ if [ ! "${GIT_REPO_SRC_DIR}" = "spdk" ]; then
+ echo "The ${SPDK_SOURCE_PATH} git repository is not named \"spdk\""
+ exit 1
+ fi
+
+ pushd "${SPDK_SOURCE_PATH}"
+ GIT_REPO_SRC=$(git rev-parse --show-toplevel)
+ GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
+ popd
+
+ if [ "${SPDK_AUTOTEST_LOCAL_PATH}" = "${SPDK_SOURCE_PATH}" ]; then
+ SPDK_AUTOTEST_LOCAL_PATH=$($READLINK -f ${SPDK_AUTOTEST_LOCAL_PATH}/..)
+ echo "Set SPDK_AUTOTEST_LOCAL_PATH to ${SPDK_AUTOTEST_LOCAL_PATH}"
+ fi
+
+ if [ -d "${SPDK_AUTOTEST_LOCAL_PATH}/${GIT_BRANCH}" ]; then
+ if [ -d "${SPDK_AUTOTEST_LOCAL_PATH}/${GIT_BRANCH}/.git" ]; then
+ echo "${SPDK_AUTOTEST_LOCAL_PATH}/${GIT_BRANCH} is a git repository!"
+ exit 1
+ fi
+ fi
+
+ GIT_REPO_PATH="${SPDK_AUTOTEST_LOCAL_PATH}/${GIT_BRANCH}/${BUILD_NAME}"
+ ;;
+ *)
+ echo "Internal Error: Must specify a source path or branch name"
+ display_help
+ exit 1
+ ;;
+esac
+
+AUTOTEST_RESULTS="${SPDK_AUTOTEST_LOCAL_PATH}/${GIT_BRANCH}/${BUILD_NAME}"
+AUTOTEST_OUTPUT_PATH="${GIT_REPO_PATH}/output"
+rootdir="${GIT_REPO_PATH}/spdk"
+BUILD_LOG_FILE="${AUTOTEST_OUTPUT_PATH}/build.log"
+
+if [[ ${NOOP} -eq 1 ]]; then
+ echo "AUTOTEST_DRIVER_PATH $AUTOTEST_DRIVER_PATH"
+ #echo "SPDK_AUTOTEST_LOCAL_PATH $SPDK_AUTOTEST_LOCAL_PATH"
+ echo "AUTOTEST_OUTPUT_PATH $AUTOTEST_OUTPUT_PATH"
+ #echo "rootdir $rootdir"
+ echo "BUILD_LOG_FILE $BUILD_LOG_FILE"
+ #echo "GIT_BRANCH $GIT_BRANCH"
+ #echo "BUILD_NAME $BUILD_NAME"
+ echo "GIT_REPO_PATH $GIT_REPO_PATH"
+ echo "AUTOTEST_RESULTS $AUTOTEST_RESULTS"
+fi
+
+#
+# I'd like to keep these files under source control
+#
+if [[ -e "${AUTOTEST_DRIVER_PATH}/autorun-spdk.conf" ]]; then
+ conf="${AUTOTEST_DRIVER_PATH}/autorun-spdk.conf"
+fi
+if [[ -e ~/autorun-spdk.conf ]]; then
+ conf=~/autorun-spdk.conf
+fi
+
+if [[ -z $conf ]]; then
+ echo Conf file not found.
+ exit 1
+fi
+
+mkdir -pv --mode=775 "${AUTOTEST_OUTPUT_PATH}"
+rm -f latest
+ln -sv ${GIT_REPO_PATH} latest
+
+if [[ ${NOOP} -eq 0 ]]; then
+ echo V=$V
+ if [[ $V -eq 0 ]]; then
+ echo Quieting output
+ exec 3>&1 4>&2 > "${BUILD_LOG_FILE}" 2>&1
+ else
+ echo Teeing to ${BUILD_LOG_FILE}
+ exec > >(tee -a "${BUILD_LOG_FILE}") 2>&1
+ fi
+
+ case "$METHOD" in
+ 1)
+ echo "rsync git repository from ${GIT_REPO_SRC} to ${GIT_REPO_PATH}"
+ rsync -av "${GIT_REPO_SRC}" "${GIT_REPO_PATH}"
+ pushd "${GIT_REPO_PATH}/spdk"
+ sudo "${MAKE}" clean -j $(nproc)
+ sudo "${GIT}" clean -d -f
+ popd
+ ;;
+ *)
+ echo "Internal Error: Must specify a source path or branch name"
+ display_help
+ exit 1
+ ;;
+ esac
+
+ trap "echo ERROR; exit" INT TERM EXIT
+
+ pushd "${AUTOTEST_OUTPUT_PATH}"
+ export output_dir="${AUTOTEST_OUTPUT_PATH}"
+
+ # Runs agent scripts
+ "${rootdir}/autobuild.sh" "$conf"
+ sudo -E "${rootdir}/autotest.sh" "$conf"
+ "${rootdir}/autopackage.sh" "$conf"
+ sudo -E "${rootdir}/autorun_post.py" -d "${AUTOTEST_OUTPUT_PATH}" -r "${rootdir}"
+
+ echo "All Tests Passed" > ${GIT_REPO_PATH}/passed
+
+ # Redirect back to screen
+ if [[ $V -eq 0 ]]; then
+ echo Redirect to screen
+ exec 1>&3 2>&4 > >(tee -a "${BUILD_LOG_FILE}") 2>&1
+ fi
+
+ popd
+
+fi
+
+echo "all tests passed"
+
+echo Output directory: ${GIT_REPO_PATH}
+echo Build log: "${BUILD_LOG_FILE}"
diff --git a/src/spdk/scripts/vagrant/update.sh b/src/spdk/scripts/vagrant/update.sh
new file mode 100755
index 000000000..87bb21c9d
--- /dev/null
+++ b/src/spdk/scripts/vagrant/update.sh
@@ -0,0 +1,98 @@
+#!/usr/bin/env bash
+
+if [ ! "$USER" = "root" ]; then
+ echo
+ echo Error: must be run as root!
+ echo
+ exit 1
+fi
+
+set -e
+
+DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+SPDK_DIR="$(cd "${DIR}/../../" && pwd)"
+echo "SPDK_DIR = $SPDK_DIR"
+
+# Bug fix for vagrant rsync problem
+if [ -d /home/vagrant/spdk_repo ]; then
+ echo "Fixing permissions on /home/vagrant/spdk_repo"
+ chown vagrant /home/vagrant/spdk_repo
+ chgrp vagrant /home/vagrant/spdk_repo
+fi
+
+# Setup for run-autorun.sh
+if [ ! -f /home/vagrant/autorun-spdk.conf ]; then
+ echo "Copying scripts/vagrant/autorun-spdk.conf to /home/vagrant"
+ cp ${SPDK_DIR}/scripts/vagrant/autorun-spdk.conf /home/vagrant
+ chown vagrant /home/vagrant/autorun-spdk.conf
+ chgrp vagrant /home/vagrant/autorun-spdk.conf
+fi
+
+SYSTEM=$(uname -s)
+
+if [ "$SYSTEM" = "FreeBSD" ]; then
+ # Do initial setup for the system
+ pkg upgrade -f
+ ${SPDK_DIR}/scripts/pkgdep.sh --all
+ if [ -d /usr/src/.git ]; then
+ echo
+ echo "/usr/src/ is a git repository"
+ echo "consider \"cd /usr/src/; git pull\" to update"
+ echo
+ else
+ git clone --depth 10 -b release/11.1.0 https://github.com/freebsd/freebsd.git /usr/src
+ fi
+else
+
+ # Make sure that we get the hugepages we need on provision boot
+ # Note: The package install should take care of this at the end
+ # But sometimes after all the work of provisioning, we can't
+ # get the requested number of hugepages without rebooting.
+ # So do it here just in case
+ sysctl -w vm.nr_hugepages=1024
+ HUGEPAGES=$(sysctl -n vm.nr_hugepages)
+ if [ $HUGEPAGES != 1024 ]; then
+ echo "Warning: Unable to get 1024 hugepages, only got $HUGEPAGES"
+ echo "Warning: Adjusting HUGEMEM in /home/vagrant/autorun-spdk.conf"
+ sed "s/HUGEMEM=.*$/HUGEMEM=${HUGEPAGES}/g" /home/vagrant/autorun-spdk.conf > /home/vagrant/foo.conf
+ mv -f /home/vagrant/foo.conf /home/vagrant/autorun-spdk.conf
+ fi
+
+ # Figure out what system we are running on
+ if [ -f /etc/lsb-release ]; then
+ . /etc/lsb-release
+ elif [ -f /etc/redhat-release ]; then
+ yum update -y
+ yum install -y redhat-lsb
+ DISTRIB_ID=$(lsb_release -si)
+ DISTRIB_RELEASE=$(lsb_release -sr)
+ DISTRIB_CODENAME=$(lsb_release -sc)
+ DISTRIB_DESCRIPTION=$(lsb_release -sd)
+ fi
+
+ # Do initial setup for the system
+ if [ "$DISTRIB_ID" == "Ubuntu" ]; then
+ set -xv
+ export DEBIAN_PRIORITY=critical
+ export DEBIAN_FRONTEND=noninteractive
+ export DEBCONF_NONINTERACTIVE_SEEN=true
+ # Standard update + upgrade dance
+ apt-get update --assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
+ apt-get upgrade --assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"
+ ${SPDK_DIR}/scripts/pkgdep.sh --all
+ apt-get clean
+ elif [ "$DISTRIB_ID" == "CentOS" ]; then
+ # Standard update + upgrade dance
+ yum check-update
+ yum update -y
+ ${SPDK_DIR}/scripts/pkgdep.sh --all
+ yum clean all
+ elif [ "$DISTRIB_ID" == "Fedora" ]; then
+ yum check-update
+ yum update -y
+ "$SPDK_DIR"/scripts/pkgdep.sh --all
+ sudo -u vagrant "$SPDK_DIR"/test/common/config/vm_setup.sh -i
+ yum clean all
+ fi
+ cat /dev/null > ~/.bash_history && history -c
+fi