diff --git a/scripts/vagrant/Vagrantfile b/scripts/vagrant/Vagrantfile index 0b57d8a91..230495805 100644 --- a/scripts/vagrant/Vagrantfile +++ b/scripts/vagrant/Vagrantfile @@ -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 diff --git a/scripts/vagrant/create_vbox.sh b/scripts/vagrant/create_vbox.sh index 1e7e3e579..f7a75f650 100755 --- a/scripts/vagrant/create_vbox.sh +++ b/scripts/vagrant/create_vbox.sh @@ -22,10 +22,14 @@ display_help() { echo " -s in kb default: ${SPDK_VAGRANT_VMRAM}" echo " -n 1 to 4 default: ${SPDK_VAGRANT_VMCPU}" echo " -x default: \"${SPDK_VAGRANT_HTTP_PROXY}\"" + echo " -p libvirt or virtualbox" + echo " --vhost-host-dir= directory path with vhost test dependencies" + echo " (test VM qcow image, fio binary, ssh keys)" + echo " --vhost-vm-dir= 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 ""