Commit fa563858 authored by Ben Walker's avatar Ben Walker Committed by Jim Harris
Browse files

test/vhost: Allow string names for vhost targets



Don't require these to be numbered.

Change-Id: I385f579b41d24eea02e157e53c4fc1530864bb5b
Signed-off-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/461389


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent cefe9145
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -133,6 +133,6 @@ truncate -s 400M $testdir/aio_bdev_0 $testdir/aio_bdev_1
vhost_start
$testdir/lvol_test.py $rpc_py $total_size $block_size $testdir $rootdir/app/vhost "${test_cases[@]}"

vhost_kill
vhost_kill 0
rm -rf $testdir/aio_bdev_0 $testdir/aio_bdev_1
trap - SIGINT SIGTERM EXIT
+1 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ $VHOST_RPC construct_vhost_scsi_controller naa.VhostScsi0.3
$VHOST_RPC add_vhost_scsi_lun naa.VhostScsi0.3 0 "Nvme0n1"

# start qemu based VM.
vm_setup --os="$VM_IMAGE" --disk-type=spdk_vhost_scsi --disks="VhostScsi0"  --force=3 --vhost-num=3
vm_setup --os="$VM_IMAGE" --disk-type=spdk_vhost_scsi --disks="VhostScsi0"  --force=3 --vhost-name=3

vm_run 3

+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ function error()
	echo -e "ERROR: $1"
	echo "error code: $error_code"
	echo "==========="
	vhost_kill
	vhost_kill 0
	pmem_clean_pool_file
	return $error_code
}
+1 −1
Original line number Diff line number Diff line
@@ -698,5 +698,5 @@ fi

pmem_clean_pool_file
report_test_completion "pmem"
vhost_kill
vhost_kill 0
timing_exit pmem
+31 −37
Original line number Diff line number Diff line
@@ -96,42 +96,34 @@ function notice()

function get_vhost_dir()
{
	if [[ ! -z "$1" ]]; then
		assert_number "$1"
		local vhost_num=$1
	else
		local vhost_num=0
	fi
	local vhost_name="$1"

	echo "$TARGET_DIR/${vhost_num}"
}

function vhost_list_all()
{
	shopt -s nullglob
	local vhost_list="$(echo $TARGET_DIR/[0-9]*)"
	shopt -u nullglob

	if [[ ! -z "$vhost_list" ]]; then
		vhost_list="$(basename --multiple $vhost_list)"
		echo "${vhost_list//vhost/}"
	if [[ -z "$vhost_name" ]]; then
		error "vhost name must be provided to get_vhost_dir"
		return 1
	fi

	echo "$TARGET_DIR/${vhost_name}"
}

function vhost_run()
{
	local vhost_num="$1"
	local vhost_name="$1"

	assert_number "$vhost_num"
	shift

	local vhost_dir="$(get_vhost_dir $vhost_num)"
	if [[ -z "$vhost_name" ]]; then
		error "vhost name must be provided to vhost_run"
		return 1
	fi

	local vhost_dir="$(get_vhost_dir $vhost_name)"
	local vhost_app="$rootdir/app/vhost/vhost"
	local vhost_log_file="$vhost_dir/vhost.log"
	local vhost_pid_file="$vhost_dir/vhost.pid"
	local vhost_socket="$vhost_dir/usvhost"
	notice "starting vhost app in background"
	[[ -r "$vhost_pid_file" ]] && vhost_kill $vhost_num
	[[ -r "$vhost_pid_file" ]] && vhost_kill 0 $vhost_name
	[[ -d $vhost_dir ]] && rm -f $vhost_dir/*
	mkdir -p $vhost_dir

@@ -175,13 +167,14 @@ function vhost_load_config()
function vhost_kill()
{
	local rc=0
	local vhost_num=0
	if [[ ! -z "$1" ]]; then
		vhost_num=$1
		assert_number "$vhost_num"
	local vhost_name="$1"

	if [[ -z "$vhost_name" ]]; then
		error "Must provide vhost name to vhost_kill"
		return 0
	fi

	local vhost_pid_file="$(get_vhost_dir $vhost_num)/vhost.pid"
	local vhost_pid_file="$(get_vhost_dir $vhost_name)/vhost.pid"

	if [[ ! -r $vhost_pid_file ]]; then
		warning "no vhost pid file found"
@@ -229,14 +222,15 @@ function vhost_kill()

function vhost_rpc
{
	local vhost_num=0
	if [[ ! -z "$1" ]]; then
		vhost_num=$1
		assert_number "$vhost_num"
	local vhost_name="$1"

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

	$rootdir/scripts/rpc.py -s $(get_vhost_dir $vhost_num)/rpc.sock $@
	$rootdir/scripts/rpc.py -s $(get_vhost_dir $vhost_name)/rpc.sock $@
}

###
@@ -521,7 +515,7 @@ function vm_setup()
	local force_vm=""
	local guest_memory=1024
	local queue_number=""
	local vhost_dir="$(get_vhost_dir)"
	local vhost_dir="$(get_vhost_dir 0)"
	while getopts ':-:' optchar; do
		case "$optchar" in
			-)
@@ -538,7 +532,7 @@ function vm_setup()
				queue_num=*) local queue_number=${OPTARG#*=} ;;
				incoming=*) local vm_incoming="${OPTARG#*=}" ;;
				migrate-to=*) local vm_migrate_to="${OPTARG#*=}" ;;
				vhost-num=*) local vhost_dir="$(get_vhost_dir ${OPTARG#*=})" ;;
				vhost-name=*) local vhost_dir="$(get_vhost_dir ${OPTARG#*=})" ;;
				spdk-boot=*) local boot_from="${OPTARG#*=}" ;;
				*)
					error "unknown argument $OPTARG"
@@ -1097,7 +1091,7 @@ function run_fio()
#
function at_app_exit()
{
	local vhost_num
	local vhost_name

	notice "APP EXITING"
	notice "killing all VMs"
@@ -1105,8 +1099,8 @@ function at_app_exit()
	# Kill vhost application
	notice "killing vhost app"

	for vhost_num in $(vhost_list_all); do
		vhost_kill $vhost_num
	for vhost_name in $(ls $TARGET_DIR); do
		vhost_kill $vhost_name
	done

	notice "EXIT DONE"
Loading