From 9f5f5da81958d5628ac8f6f4107018193e1e1a85 Mon Sep 17 00:00:00 2001 From: Karol Latecki Date: Wed, 3 Mar 2021 18:34:59 +0100 Subject: [PATCH] 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 Change-Id: If575fd871f906de5f9d89b2f3972fa54e3208147 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6682 Tested-by: SPDK CI Jenkins Reviewed-by: Maciej Wawryk Reviewed-by: Tomasz Zawadzki Reviewed-by: Jim Harris --- test/vhost/common.sh | 27 ++++++++++++------- test/vhost/fio/fio.sh | 2 +- test/vhost/fiotest/fio.sh | 2 +- test/vhost/hotplug/scsi_hotplug.sh | 2 +- test/vhost/integrity/integrity_start.sh | 2 +- test/vhost/lvol/lvol_test.sh | 2 +- test/vhost/migration/migration-tc1.sh | 2 +- test/vhost/migration/migration-tc2.sh | 4 +-- test/vhost/other/negative.sh | 2 +- test/vhost/perf_bench/vhost_perf.sh | 2 +- test/vhost/readonly/readonly.sh | 2 +- test/vhost/shared/shared.sh | 2 +- test/vhost/vhost_boot/vhost_boot.sh | 2 +- test/vhost/windows/windows_scsi_compliance.sh | 2 +- 14 files changed, 32 insertions(+), 23 deletions(-) diff --git a/test/vhost/common.sh b/test/vhost/common.sh index 260ac23d4..249f777e8 100644 --- a/test/vhost/common.sh +++ b/test/vhost/common.sh @@ -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" diff --git a/test/vhost/fio/fio.sh b/test/vhost/fio/fio.sh index 3d8bf6092..6861e7a4b 100755 --- a/test/vhost/fio/fio.sh +++ b/test/vhost/fio/fio.sh @@ -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 diff --git a/test/vhost/fiotest/fio.sh b/test/vhost/fiotest/fio.sh index 676186837..a395ae0c5 100755 --- a/test/vhost/fiotest/fio.sh +++ b/test/vhost/fiotest/fio.sh @@ -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 diff --git a/test/vhost/hotplug/scsi_hotplug.sh b/test/vhost/hotplug/scsi_hotplug.sh index 40132ab8a..173078fff 100755 --- a/test/vhost/hotplug/scsi_hotplug.sh +++ b/test/vhost/hotplug/scsi_hotplug.sh @@ -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 diff --git a/test/vhost/integrity/integrity_start.sh b/test/vhost/integrity/integrity_start.sh index ff3e98bda..c72404575 100755 --- a/test/vhost/integrity/integrity_start.sh +++ b/test/vhost/integrity/integrity_start.sh @@ -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 diff --git a/test/vhost/lvol/lvol_test.sh b/test/vhost/lvol/lvol_test.sh index e484a4b16..6920eff87 100755 --- a/test/vhost/lvol/lvol_test.sh +++ b/test/vhost/lvol/lvol_test.sh @@ -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 diff --git a/test/vhost/migration/migration-tc1.sh b/test/vhost/migration/migration-tc1.sh index 6d5a436ef..0e56a835a 100644 --- a/test/vhost/migration/migration-tc1.sh +++ b/test/vhost/migration/migration-tc1.sh @@ -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" diff --git a/test/vhost/migration/migration-tc2.sh b/test/vhost/migration/migration-tc2.sh index b8e70b784..9f1e4d48b 100644 --- a/test/vhost/migration/migration-tc2.sh +++ b/test/vhost/migration/migration-tc2.sh @@ -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 diff --git a/test/vhost/other/negative.sh b/test/vhost/other/negative.sh index 80eb7dfdc..f7cc5b7b8 100755 --- a/test/vhost/other/negative.sh +++ b/test/vhost/other/negative.sh @@ -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 diff --git a/test/vhost/perf_bench/vhost_perf.sh b/test/vhost/perf_bench/vhost_perf.sh index e1ad195ae..edc35fdc7 100755 --- a/test/vhost/perf_bench/vhost_perf.sh +++ b/test/vhost/perf_bench/vhost_perf.sh @@ -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 diff --git a/test/vhost/readonly/readonly.sh b/test/vhost/readonly/readonly.sh index ad66f72e0..9ae8132cd 100755 --- a/test/vhost/readonly/readonly.sh +++ b/test/vhost/readonly/readonly.sh @@ -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 diff --git a/test/vhost/shared/shared.sh b/test/vhost/shared/shared.sh index bc06517bc..9c902289a 100755 --- a/test/vhost/shared/shared.sh +++ b/test/vhost/shared/shared.sh @@ -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 diff --git a/test/vhost/vhost_boot/vhost_boot.sh b/test/vhost/vhost_boot/vhost_boot.sh index f36f146d7..60743d670 100755 --- a/test/vhost/vhost_boot/vhost_boot.sh +++ b/test/vhost/vhost_boot/vhost_boot.sh @@ -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 diff --git a/test/vhost/windows/windows_scsi_compliance.sh b/test/vhost/windows/windows_scsi_compliance.sh index d7c854592..450df73da 100755 --- a/test/vhost/windows/windows_scsi_compliance.sh +++ b/test/vhost/windows/windows_scsi_compliance.sh @@ -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