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: Karol Latecki <karol.latecki@intel.com> Change-Id: If575fd871f906de5f9d89b2f3972fa54e3208147 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6682 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Maciej Wawryk <maciejx.wawryk@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
b33da506b5
commit
9f5f5da819
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -95,7 +95,7 @@ trap 'error_exit "${FUNCNAME}" "${LINENO}"' SIGTERM SIGABRT ERR
|
||||
vm_kill_all
|
||||
|
||||
notice "running SPDK vhost"
|
||||
vhost_run 0 --cpumask $spdk_mask
|
||||
vhost_run -n "0" -a "--cpumask $spdk_mask"
|
||||
notice "..."
|
||||
|
||||
trap 'clean_lvol_cfg; error_exit "${FUNCNAME}" "${LINENO}"' SIGTERM SIGABRT ERR
|
||||
|
@ -55,7 +55,7 @@ function migration_tc1() {
|
||||
log_file="/root/$(basename ${job_file%%.*}).log"
|
||||
|
||||
# Run vhost
|
||||
vhost_run 0
|
||||
vhost_run -n 0
|
||||
migration_tc1_configure_vhost
|
||||
|
||||
notice "Setting up VMs"
|
||||
|
@ -99,8 +99,8 @@ function migration_tc2_configure_vhost() {
|
||||
$rootdir/scripts/gen_nvme.sh | $rpc_nvmf load_subsystem_config
|
||||
timing_exit start_nvmf_tgt
|
||||
|
||||
vhost_run 0 "-m 0x1 -s 512 -u"
|
||||
vhost_run 1 "-m 0x2 -s 512 -u"
|
||||
vhost_run -n 0 -a "-m 0x1 -s 512 -u"
|
||||
vhost_run -n 1 -a "-m 0x2 -s 512 -u"
|
||||
|
||||
local rdma_ip_list
|
||||
local nvmf_target_ip
|
||||
|
@ -63,7 +63,7 @@ notice "==============="
|
||||
notice ""
|
||||
notice "running SPDK"
|
||||
notice ""
|
||||
vhost_run 0 "-m 0xf"
|
||||
vhost_run -n 0 -a "-m 0xf"
|
||||
notice ""
|
||||
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
|
||||
$rpc_py bdev_malloc_create -b Malloc0 128 4096
|
||||
|
@ -301,7 +301,7 @@ if [[ "$ctrl_type" == "kernel_vhost" ]]; then
|
||||
targetcli ls
|
||||
else
|
||||
notice "Configuring SPDK vhost..."
|
||||
vhost_run "${vhost_num}" "--no-gen-nvme" "-p ${vhost_main_core}" "-m ${vhost_reactor_mask}"
|
||||
vhost_run -n "${vhost_num}" -g -a "-p ${vhost_main_core} -m ${vhost_reactor_mask}"
|
||||
notice "..."
|
||||
|
||||
if [[ $use_split == true ]]; then
|
||||
|
@ -122,7 +122,7 @@ function blk_ro_tc1() {
|
||||
vm_shutdown_all
|
||||
}
|
||||
|
||||
vhost_run 0
|
||||
vhost_run -n 0
|
||||
if [[ -z $x ]]; then
|
||||
set +x
|
||||
fi
|
||||
|
@ -17,7 +17,7 @@ vhosttestinit "--no_vm"
|
||||
|
||||
trap 'error_exit "${FUNCNAME}" "${LINENO}"' ERR SIGTERM SIGABRT
|
||||
|
||||
vhost_run 0
|
||||
vhost_run -n 0
|
||||
|
||||
$rpc_py bdev_malloc_create -b Malloc 124 4096
|
||||
$rpc_py vhost_create_blk_controller Malloc.0 Malloc
|
||||
|
@ -61,7 +61,7 @@ vhosttestinit
|
||||
|
||||
trap 'err_clean "${FUNCNAME}" "${LINENO}"' ERR
|
||||
timing_enter start_vhost
|
||||
vhost_run 0
|
||||
vhost_run -n 0
|
||||
timing_exit start_vhost
|
||||
|
||||
timing_enter create_lvol
|
||||
|
@ -52,7 +52,7 @@ mkdir -p $testdir/results
|
||||
dd if=/dev/zero of=$aio_file bs=1M count=512
|
||||
|
||||
timing_enter vhost_run
|
||||
vhost_run 0
|
||||
vhost_run -n 0
|
||||
$rpc_py bdev_nvme_set_hotplug -e
|
||||
$rpc_py bdev_malloc_create 256 4096 -b Malloc0
|
||||
$rpc_py bdev_aio_create $aio_file Aio0 512
|
||||
|
Loading…
Reference in New Issue
Block a user