Commit 9f5f5da8 authored by Karol Latecki's avatar Karol Latecki Committed by Tomasz Zawadzki
Browse files

test/vhost: use getopts in vhost_run function



Use getopts instead of using positional args. This
will be needed in future commits when more optional
parameters will be added.

Signed-off-by: default avatarKarol Latecki <karol.latecki@intel.com>
Change-Id: If575fd871f906de5f9d89b2f3972fa54e3208147
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6682


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarMaciej Wawryk <maciejx.wawryk@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent b33da506
Loading
Loading
Loading
Loading
+18 −9
Original line number Diff line number Diff line
@@ -104,20 +104,29 @@ function get_vhost_dir() {
}

function vhost_run() {
	local vhost_name="$1"
	local OPTIND
	local vhost_name
	local run_gen_nvme=true

	while getopts "n:a:g" optchar; do
		case "$optchar" in
			n) vhost_name="$OPTARG" ;;
			a) vhost_args="$OPTARG" ;;
			g)
				run_gen_nvme=false
				notice "Skipping gen_nvme.sh NVMe bdev configuration"
				;;
			*)
				error "Unknown param $optchar"
				return 1
				;;
		esac
	done

	if [[ -z "$vhost_name" ]]; then
		error "vhost name must be provided to vhost_run"
		return 1
	fi
	shift

	if [[ "$1" == "--no-gen-nvme" ]]; then
		notice "Skipping gen_nvmf.sh NVMe bdev configuration"
		run_gen_nvme=false
		shift
	fi

	local vhost_dir
	vhost_dir="$(get_vhost_dir $vhost_name)"
@@ -135,7 +144,7 @@ function vhost_run() {
		return 1
	fi

	local cmd="$vhost_app -r $vhost_dir/rpc.sock $*"
	local cmd="$vhost_app -r $vhost_dir/rpc.sock $vhost_args"

	notice "Loging to:   $vhost_log_file"
	notice "Socket:      $vhost_socket"
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ timing_enter vhost_fio

trap "at_app_exit; process_shm --id 0; exit 1" SIGINT SIGTERM EXIT

vhost_run vhost0 "-m 0x1"
vhost_run -n vhost0 -a "-m 0x1"

# Create vhost scsi controller
vhost_rpc vhost0 bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE -b Malloc0
+1 −1
Original line number Diff line number Diff line
@@ -91,7 +91,7 @@ if [[ $test_type =~ "spdk_vhost" ]]; then
	notice ""
	notice "running SPDK"
	notice ""
	vhost_run 0
	vhost_run -n 0
	rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
	$rpc_py bdev_split_create Nvme0n1 4
	$rpc_py bdev_malloc_create -b Malloc0 128 4096
+1 −1
Original line number Diff line number Diff line
@@ -61,7 +61,7 @@ notice "==============="
notice ""
notice "running SPDK"
notice ""
vhost_run 0
vhost_run -n 0
$rpc_py bdev_nvme_set_hotplug -e
$rpc_py bdev_split_create Nvme0n1 16
$rpc_py bdev_malloc_create 128 512 -b Malloc
+1 −1
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ trap 'error_exit "${FUNCNAME}" "${LINENO}"' SIGTERM SIGABRT ERR
vm_kill_all

notice "Starting SPDK vhost"
vhost_run 0
vhost_run -n 0
notice "..."

# Set up lvols and vhost controllers
Loading