Commit 391503d7 authored by Maciej Wawryk's avatar Maciej Wawryk Committed by Ben Walker
Browse files

scripts/vagrant: allow using custom emulator



We want to use Vagrant scripts in our CI.
It will allow us to remove statically configured
virtual machines and spawn new instances dynamically.

This patch allows us to use custom version of emulator
instead of preinstalled on host.

Signed-off-by: default avatarMaciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: Iff79cd28d4d5b21fcf327db455ef060182f0f4ef
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/465925


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarKarol Latecki <karol.latecki@intel.com>
parent 1e91f5bd
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -94,6 +94,7 @@ Vagrant.configure(2) do |config|
  spdk_dir=(ENV['SPDK_DIR'] || "none")
  vhost_host_dir=(ENV['VHOST_HOST_DIR'] || "none")
  vhost_vm_dir=(ENV['VHOST_VM_DIR'] || "none")
  vmemulator=(ENV['SPDK_QEMU_EMULATOR'] || "")

  config.ssh.forward_agent = true
  config.ssh.forward_x11 = true
@@ -121,6 +122,9 @@ Vagrant.configure(2) do |config|
  config.vm.provider "libvirt" do |libvirt, override|
    libvirt.random_hostname = "1"
    libvirt.disk_bus = "virtio"
    if not vmemulator.empty?
      libvirt.emulator_path = "#{vmemulator}"
    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
@@ -139,10 +143,10 @@ Vagrant.configure(2) do |config|
    libvirt.qemuargs :value => "-device"
    libvirt.qemuargs :value => "nvme,drive=D22,serial=1234"
    libvirt.driver = "kvm"
    libvirt.graphics_type = "spice"
    libvirt.graphics_type = "vnc"
    libvirt.memory = "#{vmram}"
    libvirt.cpus = "#{vmcpu}"
    libvirt.video_type = "qxl"
    libvirt.video_type = "cirrus"

    # Optional field if we want use other storage pools than default
    # libvirt.storage_pool_name = "vm"
+17 −8
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ display_help() {
	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 "  --qemu-emulator=<path>          directory path with emulator, default: ${SPDK_QEMU_EMULATOR}"
	echo "  -r dry-run"
	echo "  -l use a local copy of spdk, don't try to rsync from the host."
	echo "  -d deploy a test vm by provisioning all prerequisites for spdk autotest"
@@ -55,6 +56,7 @@ SPDK_VAGRANT_DISTRO="distro"
SPDK_VAGRANT_VMCPU=4
SPDK_VAGRANT_VMRAM=4096
SPDK_VAGRANT_PROVIDER="virtualbox"
SPDK_QEMU_EMULATOR=""
OPTIND=1
NVME_FILE="nvme_disk.img"

@@ -64,6 +66,7 @@ while getopts ":b:n:s:x:p:vrldh-:" opt; do
		case "${OPTARG}" in
			vhost-host-dir=*) VHOST_HOST_DIR="${OPTARG#*=}" ;;
			vhost-vm-dir=*) VHOST_VM_DIR="${OPTARG#*=}" ;;
			qemu-emulator=*) SPDK_QEMU_EMULATOR="${OPTARG#*=}" ;;
			*) echo "Invalid argument '$OPTARG'" ;;
		esac
		;;
@@ -161,6 +164,7 @@ if [ ${VERBOSE} = 1 ]; then
	echo SPDK_VAGRANT_HTTP_PROXY=$SPDK_VAGRANT_HTTP_PROXY
	echo VHOST_HOST_DIR=$VHOST_HOST_DIR
	echo VHOST_VM_DIR=$VHOST_VM_DIR
	echo SPDK_QEMU_EMULATOR=$SPDK_QEMU_EMULATOR
	echo
fi

@@ -188,6 +192,10 @@ 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
@@ -195,6 +203,7 @@ if [ ${DRY_RUN} = 1 ]; then
	printenv SPDK_VAGRANT_VMCPU
	printenv SPDK_VAGRANT_PROVIDER
	printenv SPDK_VAGRANT_HTTP_PROXY
	printenv SPDK_QEMU_EMULATOR
	printenv SPDK_DIR
fi