test/vhost: Allow string names for vhost targets

Don't require these to be numbered.

Change-Id: I385f579b41d24eea02e157e53c4fc1530864bb5b
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/461389
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Ben Walker 2019-06-04 13:55:21 -07:00 committed by Jim Harris
parent cefe9145e4
commit fa563858fa
20 changed files with 69 additions and 74 deletions

View File

@ -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

View File

@ -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

View File

@ -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
}

View File

@ -698,5 +698,5 @@ fi
pmem_clean_pool_file
report_test_completion "pmem"
vhost_kill
vhost_kill 0
timing_exit pmem

View File

@ -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
local vhost_name="$1"
if [[ -z "$vhost_name" ]]; then
error "vhost name must be provided to get_vhost_dir"
return 1
fi
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/}"
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"

View File

@ -91,7 +91,7 @@ notice ""
notice "Setting up VM"
notice ""
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir)/rpc.sock"
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
for vm_conf in ${vms[@]}; do
IFS=',' read -ra conf <<< "$vm_conf"
@ -254,7 +254,7 @@ if ! $no_shutdown; then
fi
notice "Testing done -> shutting down"
notice "killing vhost app"
vhost_kill
vhost_kill 0
notice "EXIT DONE"
notice "==============="

View File

@ -65,7 +65,7 @@ fio_job=$testdir/fio_jobs/default_integrity.job
tmp_attach_job=$testdir/fio_jobs/fio_attach.job.tmp
tmp_detach_job=$testdir/fio_jobs/fio_detach.job.tmp
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir)/rpc.sock"
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
function print_test_fio_header() {
notice "==============="
@ -181,7 +181,7 @@ function reboot_all_and_prepare() {
function post_test_case() {
vm_shutdown_all
vhost_kill
vhost_kill 0
}
function on_error_exit() {

View File

@ -37,7 +37,7 @@ vhosttestinit
source $testdir/autotest.config
PLUGIN_DIR=$rootdir/examples/bdev/fio_plugin
RPC_PY="$rootdir/scripts/rpc.py -s $(get_vhost_dir)/rpc.sock"
RPC_PY="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
if [ ! -x $FIO_PATH ]; then
error "Invalid path of fio binary"
@ -50,6 +50,7 @@ fi
trap 'rm -f *.state $rootdir/spdk.tar.gz $rootdir/fio.tar.gz $(get_vhost_dir)/Virtio0;\
error_exit "${FUNCNAME}""${LINENO}"' ERR SIGTERM SIGABRT
function run_spdk_fio() {
fio_bdev --ioengine=spdk_bdev "$@" --spdk_mem=1024 --spdk_single_seg=1
}
@ -109,7 +110,7 @@ timing_exit run_spdk_fio_unmap
$RPC_PY delete_nvme_controller Nvme0
timing_enter vhost_kill
vhost_kill
vhost_kill 0
timing_exit vhost_kill
vhosttestfini

View File

@ -52,7 +52,7 @@ done
vhosttestinit
. $(readlink -e "$(dirname $0)/../common.sh") || exit 1
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir)/rpc.sock"
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
trap 'error_exit "${FUNCNAME}" "${LINENO}"' SIGTERM SIGABRT ERR
@ -98,6 +98,6 @@ clean_lvol_cfg
$rpc_py delete_nvme_controller Nvme0
notice "Shutting down SPDK vhost app..."
vhost_kill
vhost_kill 0
vhosttestfini

View File

@ -6,7 +6,7 @@ source $rootdir/test/common/autotest_common.sh
source $rootdir/test/vhost/common.sh
source $rootdir/scripts/common.sh
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir)/rpc.sock"
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
vm_count=1
max_disks=""
@ -282,6 +282,6 @@ $rpc_py get_bdevs
$rpc_py get_vhost_controllers
notice "Shutting down SPDK vhost app..."
vhost_kill
vhost_kill 0
vhosttestfini

View File

@ -21,7 +21,7 @@ function migration_tc1_configure_vhost()
target_vm=1
incoming_vm_ctrlr=naa.Malloc0.$incoming_vm
target_vm_ctrlr=naa.Malloc0.$target_vm
rpc="$rootdir/scripts/rpc.py -s $(get_vhost_dir)/rpc.sock"
rpc="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
trap 'migration_tc1_error_handler; error_exit "${FUNCNAME}" "${LINENO}"' INT ERR EXIT
@ -115,7 +115,7 @@ function migration_tc1()
migration_tc1_clean_vhost_config
notice "killing vhost app"
vhost_kill
vhost_kill 0
notice "Migration TC1 SUCCESS"
}

View File

@ -129,9 +129,9 @@ function migration_tc2_configure_vhost()
notice "Setting up VMs"
vm_setup --os="$os_image" --force=$incoming_vm --disk-type=spdk_vhost_scsi --disks=VhostScsi0 \
--migrate-to=$target_vm --memory=1024 --vhost-num=0
--migrate-to=$target_vm --memory=1024 --vhost-name=0
vm_setup --force=$target_vm --disk-type=spdk_vhost_scsi --disks=VhostScsi0 --incoming=$incoming_vm --memory=1024 \
--vhost-num=1
--vhost-name=1
# Run everything
vm_run $incoming_vm $target_vm

View File

@ -40,7 +40,7 @@ function host_2_start_vhost()
$rpc add_vhost_scsi_lun $target_vm_ctrl 0 Nvme0n1
vm_setup --os="$os_image" --force=$target_vm --disk-type=spdk_vhost_scsi --disks=VhostScsi0 \
--memory=512 --vhost-num=1 --incoming=$incoming_vm
--memory=512 --vhost-name=1 --incoming=$incoming_vm
vm_run $target_vm
sleep 1

View File

@ -73,7 +73,7 @@ if [[ $RUN_NIGHTLY -eq 1 ]]; then
vhost_json_config 0 $testdir/conf.json
notice ""
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir)/rpc.sock"
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
# General commands
notice "Trying to remove nonexistent controller"
@ -142,7 +142,7 @@ if [[ $RUN_NIGHTLY -eq 1 ]]; then
notice "Testing done -> shutting down"
notice "killing vhost app"
vhost_kill
vhost_kill 0
notice "EXIT DONE"
notice "==============="

View File

@ -139,7 +139,7 @@ while getopts 'xh-:' optchar; do
esac
done
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir)/rpc.sock"
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
if [[ -n $custom_cpu_cfg ]]; then
source $custom_cpu_cfg
@ -386,7 +386,7 @@ else
else
cleanup_lvol_cfg
fi
vhost_kill
vhost_kill 0
fi
if [[ -n "$kernel_cpus" ]]; then

View File

@ -5,7 +5,7 @@ rootdir=$(readlink -f $testdir/../../..)
source $rootdir/test/common/autotest_common.sh
source $rootdir/test/vhost/common.sh
rpc_py="$testdir/../../../scripts/rpc.py -s $(get_vhost_dir)/rpc.sock"
rpc_py="$testdir/../../../scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
vm_img=""
disk="Nvme0n1"
@ -130,6 +130,6 @@ blk_ro_tc1
$rpc_py delete_nvme_controller Nvme0
vhost_kill
vhost_kill 0
vhosttestfini

View File

@ -5,7 +5,7 @@ rootdir=$(readlink -f $testdir/../../..)
source $rootdir/test/common/autotest_common.sh
source $rootdir/test/vhost/common.sh
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir)/rpc.sock"
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
function run_spdk_fio() {
fio_bdev --ioengine=spdk_bdev \
@ -27,6 +27,6 @@ run_fio_pid=$!
sleep 1
run_spdk_fio --size=50% --offset=50% --filename=VirtioBlk0
wait $run_fio_pid
vhost_kill
vhost_kill 0
vhosttestfini

View File

@ -7,7 +7,7 @@ source $rootdir/test/common/autotest_common.sh
source $rootdir/test/vhost/common.sh
source $rootdir/test/bdev/nbd_common.sh
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir)/rpc.sock"
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
vm_no="0"
function err_clean
@ -21,7 +21,7 @@ function err_clean
$rpc_py remove_vhost_controller naa.vhost_vm.$vm_no
$rpc_py destroy_lvol_bdev $lvb_u
$rpc_py destroy_lvol_store -u $lvs_u
vhost_kill
vhost_kill 0
exit 1
}
@ -80,11 +80,11 @@ timing_exit create_lvol
timing_enter convert_vm_image
modprobe nbd
trap 'nbd_stop_disks $(get_vhost_dir)/rpc.sock /dev/nbd0; err_clean "${FUNCNAME}" "${LINENO}"' ERR
nbd_start_disks "$(get_vhost_dir)/rpc.sock" $lvb_u /dev/nbd0
trap 'nbd_stop_disks $(get_vhost_dir 0)/rpc.sock /dev/nbd0; err_clean "${FUNCNAME}" "${LINENO}"' ERR
nbd_start_disks "$(get_vhost_dir 0)/rpc.sock" $lvb_u /dev/nbd0
qemu-img convert $os_image -O raw /dev/nbd0
sync
nbd_stop_disks $(get_vhost_dir)/rpc.sock /dev/nbd0
nbd_stop_disks $(get_vhost_dir 0)/rpc.sock /dev/nbd0
sleep 1
timing_exit convert_vm_image
@ -119,7 +119,7 @@ $rpc_py remove_vhost_scsi_target naa.vhost_vm.$vm_no 0
$rpc_py remove_vhost_controller naa.vhost_vm.$vm_no
$rpc_py destroy_lvol_bdev $lvb_u
$rpc_py destroy_lvol_store -u $lvs_u
vhost_kill
vhost_kill 0
timing_exit clean_vhost
timing_exit vhost_boot

View File

@ -5,7 +5,7 @@ rootdir=$(readlink -f $testdir/../../..)
source $rootdir/test/common/autotest_common.sh
source $rootdir/test/vhost/common.sh
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir)/rpc.sock"
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
ctrl_type="spdk_vhost_scsi"
ssh_pass=""
vm_num="0"
@ -132,6 +132,6 @@ notice "Shutting down Windows VM..."
vm_kill $vm_num
notice "Shutting down SPDK vhost app..."
vhost_kill
vhost_kill 0
rm -f $aio_file

View File

@ -14,7 +14,7 @@ aio_file="$testdir/aio_disk"
ssh_pass=""
vm_num=1
keep_results_dir=false
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir)/rpc.sock"
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
function usage()
{
@ -76,7 +76,7 @@ dos2unix $testdir/results/WIN_SCSI_*.log
notice "Kill vm 1"
vm_kill "$vm_num"
notice "Kill spdk"
vhost_kill
vhost_kill 0
notice "Remove $aio_file"
rm -f $aio_file