2016-12-14 20:34:03 +00:00
|
|
|
#!/usr/bin/env bash
|
2022-11-02 15:49:40 +00:00
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
# Copyright (C) 2016 Intel Corporation
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
2019-05-10 17:54:24 +00:00
|
|
|
testdir=$(readlink -f $(dirname $0))
|
|
|
|
rootdir=$(readlink -f $testdir/../../..)
|
|
|
|
source $rootdir/test/common/autotest_common.sh
|
|
|
|
source $rootdir/test/vhost/common.sh
|
|
|
|
|
2018-02-06 11:20:21 +00:00
|
|
|
ctrl_type="spdk_vhost_scsi"
|
|
|
|
vm_fs="ext4"
|
|
|
|
|
2020-05-07 11:27:06 +00:00
|
|
|
function usage() {
|
|
|
|
[[ -n $2 ]] && (
|
|
|
|
echo "$2"
|
|
|
|
echo ""
|
|
|
|
)
|
2018-02-06 11:20:21 +00:00
|
|
|
echo "Shortcut script for doing automated test"
|
|
|
|
echo "Usage: $(basename $1) [OPTIONS]"
|
|
|
|
echo
|
|
|
|
echo "-h, --help Print help and exit"
|
|
|
|
echo " --ctrl-type=TYPE Controller type to use for test:"
|
|
|
|
echo " spdk_vhost_scsi - use spdk vhost scsi"
|
|
|
|
echo " --fs=FS_LIST Filesystems to use for test in VM:"
|
|
|
|
echo " Example: --fs=\"ext4 ntfs ext2\""
|
|
|
|
echo " Default: ext4"
|
|
|
|
echo " spdk_vhost_blk - use spdk vhost block"
|
|
|
|
echo "-x set -x for script debug"
|
|
|
|
exit 0
|
2016-12-14 20:34:03 +00:00
|
|
|
}
|
|
|
|
|
2020-05-07 11:27:06 +00:00
|
|
|
function clean_lvol_cfg() {
|
2018-02-06 11:20:21 +00:00
|
|
|
notice "Removing lvol bdev and lvol store"
|
2019-08-29 10:33:16 +00:00
|
|
|
$rpc_py bdev_lvol_delete lvol_store/lvol_bdev
|
2019-08-29 12:07:56 +00:00
|
|
|
$rpc_py bdev_lvol_delete_lvstore -l lvol_store
|
2017-12-07 11:14:29 +00:00
|
|
|
}
|
|
|
|
|
2018-02-06 11:20:21 +00:00
|
|
|
while getopts 'xh-:' optchar; do
|
|
|
|
case "$optchar" in
|
|
|
|
-)
|
2020-05-07 11:27:06 +00:00
|
|
|
case "$OPTARG" in
|
|
|
|
help) usage $0 ;;
|
|
|
|
ctrl-type=*) ctrl_type="${OPTARG#*=}" ;;
|
|
|
|
fs=*) vm_fs="${OPTARG#*=}" ;;
|
|
|
|
*) usage $0 "Invalid argument '$OPTARG'" ;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
h) usage $0 ;;
|
|
|
|
x)
|
|
|
|
set -x
|
|
|
|
x="-x"
|
|
|
|
;;
|
|
|
|
*) usage $0 "Invalid argument '$OPTARG'" ;;
|
2018-02-06 11:20:21 +00:00
|
|
|
esac
|
|
|
|
done
|
2016-12-14 20:34:03 +00:00
|
|
|
|
2019-05-17 21:09:40 +00:00
|
|
|
vhosttestinit
|
|
|
|
|
2019-05-01 22:13:48 +00:00
|
|
|
. $(readlink -e "$(dirname $0)/../common.sh") || exit 1
|
2019-06-04 20:55:21 +00:00
|
|
|
rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
|
2016-12-14 20:34:03 +00:00
|
|
|
|
2018-02-06 11:20:21 +00:00
|
|
|
trap 'error_exit "${FUNCNAME}" "${LINENO}"' SIGTERM SIGABRT ERR
|
2016-12-14 20:34:03 +00:00
|
|
|
|
2018-02-06 11:20:21 +00:00
|
|
|
# Try to kill if any VM remains from previous runs
|
|
|
|
vm_kill_all
|
2016-12-14 20:34:03 +00:00
|
|
|
|
2018-02-06 11:20:21 +00:00
|
|
|
notice "Starting SPDK vhost"
|
2021-03-03 17:34:59 +00:00
|
|
|
vhost_run -n 0
|
2018-02-06 11:20:21 +00:00
|
|
|
notice "..."
|
2017-12-07 11:14:29 +00:00
|
|
|
|
2018-02-06 11:20:21 +00:00
|
|
|
# Set up lvols and vhost controllers
|
|
|
|
trap 'clean_lvol_cfg; error_exit "${FUNCNAME}" "${LINENO}"' SIGTERM SIGABRT ERR
|
2019-09-30 10:51:55 +00:00
|
|
|
notice "Creating lvol store and lvol bdev on top of Nvme0n1"
|
2019-08-29 13:31:19 +00:00
|
|
|
lvs_uuid=$($rpc_py bdev_lvol_create_lvstore Nvme0n1 lvol_store)
|
2019-08-29 11:01:30 +00:00
|
|
|
$rpc_py bdev_lvol_create lvol_bdev 10000 -l lvol_store
|
2017-12-07 11:14:29 +00:00
|
|
|
|
2018-02-06 11:20:21 +00:00
|
|
|
if [[ "$ctrl_type" == "spdk_vhost_scsi" ]]; then
|
2019-09-24 14:29:10 +00:00
|
|
|
$rpc_py vhost_create_scsi_controller naa.Nvme0n1.0
|
2019-09-27 20:53:41 +00:00
|
|
|
$rpc_py vhost_scsi_controller_add_target naa.Nvme0n1.0 0 lvol_store/lvol_bdev
|
2018-02-06 11:20:21 +00:00
|
|
|
elif [[ "$ctrl_type" == "spdk_vhost_blk" ]]; then
|
2019-09-30 10:51:55 +00:00
|
|
|
$rpc_py vhost_create_blk_controller naa.Nvme0n1.0 lvol_store/lvol_bdev
|
2017-08-09 10:38:11 +00:00
|
|
|
fi
|
2017-12-07 11:14:29 +00:00
|
|
|
|
2018-02-06 11:20:21 +00:00
|
|
|
# Set up and run VM
|
|
|
|
setup_cmd="vm_setup --disk-type=$ctrl_type --force=0"
|
2019-06-03 22:16:21 +00:00
|
|
|
setup_cmd+=" --os=$VM_IMAGE"
|
2018-02-06 11:20:21 +00:00
|
|
|
setup_cmd+=" --disks=Nvme0n1"
|
|
|
|
$setup_cmd
|
2016-12-14 20:34:03 +00:00
|
|
|
|
2018-02-06 11:20:21 +00:00
|
|
|
# Run VM
|
|
|
|
vm_run 0
|
2019-03-25 13:14:55 +00:00
|
|
|
vm_wait_for_boot 300 0
|
2016-12-14 20:34:03 +00:00
|
|
|
|
2018-02-06 11:20:21 +00:00
|
|
|
# Run tests on VM
|
2019-05-10 17:54:24 +00:00
|
|
|
vm_scp 0 $testdir/integrity_vm.sh root@127.0.0.1:/root/integrity_vm.sh
|
2019-10-07 09:13:54 +00:00
|
|
|
vm_exec 0 "/root/integrity_vm.sh $ctrl_type \"$vm_fs\""
|
2016-12-14 20:34:03 +00:00
|
|
|
|
2018-02-06 11:20:21 +00:00
|
|
|
notice "Shutting down virtual machine..."
|
|
|
|
vm_shutdown_all
|
2016-12-14 20:34:03 +00:00
|
|
|
|
2018-02-06 11:20:21 +00:00
|
|
|
clean_lvol_cfg
|
2018-07-26 12:54:20 +00:00
|
|
|
|
2019-08-23 15:12:13 +00:00
|
|
|
$rpc_py bdev_nvme_detach_controller Nvme0
|
2018-07-26 12:54:20 +00:00
|
|
|
|
2018-02-06 11:20:21 +00:00
|
|
|
notice "Shutting down SPDK vhost app..."
|
2019-06-04 20:55:21 +00:00
|
|
|
vhost_kill 0
|
2019-05-17 21:09:40 +00:00
|
|
|
|
|
|
|
vhosttestfini
|