#!/usr/bin/env bash testdir=$(readlink -f $(dirname $0)) rootdir=$(readlink -f $testdir/../../..) 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 0)/rpc.sock" vm_count=1 max_disks="" ctrl_type="spdk_vhost_scsi" use_fs=false nested_lvol=false distribute_cores=false function usage() { [[ -n $2 ]] && ( echo "$2"; echo ""; ) echo "Shortcut script for doing automated test" echo "Usage: $(basename $1) [OPTIONS]" echo echo "-h, --help Print help and exit" echo " --fio-bin=PATH Path to FIO binary.;" echo " --vm-count=INT Virtual machines to use in test;" echo " Each VM will get one lvol bdev on each NVMe." echo " Default: 1" echo " --max-disks=INT Maximum number of NVMe drives to use in test." echo " Default: will use all available NVMes." echo " --ctrl-type=TYPE Controller type to use for test:" echo " spdk_vhost_scsi - use spdk vhost scsi" echo " spdk_vhost_blk - use spdk vhost block" echo " --nested-lvol If enabled will create additional lvol bdev" echo " on each NVMe for use as base device for next" echo " lvol store and lvol bdevs." echo " (NVMe->lvol_store->lvol_bdev->lvol_store->lvol_bdev)" echo " Default: False" echo " --thin-provisioning Create lvol bdevs thin provisioned instead of" echo " allocating space up front" echo " --distribute-cores Use custom config file and run vhost controllers" echo " on different CPU cores instead of single core." echo " Default: False" echo "-x set -x for script debug" echo " --multi-os Run tests on different os types in VMs" echo " Default: False" exit 0 } function clean_lvol_cfg() { notice "Removing nested lvol bdevs" for lvol_bdev in "${nest_lvol_bdevs[@]}"; do $rpc_py bdev_lvol_delete $lvol_bdev notice "nested lvol bdev $lvol_bdev removed" done notice "Removing nested lvol stores" for lvol_store in "${nest_lvol_stores[@]}"; do $rpc_py bdev_lvol_delete_lvstore -u $lvol_store notice "nested lvol store $lvol_store removed" done notice "Removing lvol bdevs" for lvol_bdev in "${lvol_bdevs[@]}"; do $rpc_py bdev_lvol_delete $lvol_bdev notice "lvol bdev $lvol_bdev removed" done notice "Removing lvol stores" for lvol_store in "${lvol_stores[@]}"; do $rpc_py bdev_lvol_delete_lvstore -u $lvol_store notice "lvol store $lvol_store removed" done } while getopts 'xh-:' optchar; do case "$optchar" in -) case "$OPTARG" in help) usage $0 ;; fio-bin=*) fio_bin="--fio-bin=${OPTARG#*=}" ;; vm-count=*) vm_count="${OPTARG#*=}" ;; max-disks=*) max_disks="${OPTARG#*=}" ;; ctrl-type=*) ctrl_type="${OPTARG#*=}" ;; nested-lvol) nested_lvol=true ;; distribute-cores) distribute_cores=true ;; thin-provisioning) thin=" -t " ;; multi-os) multi_os=true ;; *) usage $0 "Invalid argument '$OPTARG'" ;; esac ;; h) usage $0 ;; x) set -x x="-x" ;; *) usage $0 "Invalid argument '$OPTARG'" esac done vhosttestinit notice "Get NVMe disks:" nvmes=($(iter_pci_class_code 01 08 02)) if [[ -z $max_disks ]]; then max_disks=${#nvmes[@]} fi if [[ ${#nvmes[@]} -lt max_disks ]]; then fail "Number of NVMe drives (${#nvmes[@]}) is lower than number of requested disks for test ($max_disks)" fi if $distribute_cores; then # FIXME: this need to be handled entirely in common.sh source $testdir/autotest.config fi trap 'error_exit "${FUNCNAME}" "${LINENO}"' SIGTERM SIGABRT ERR vm_kill_all notice "running SPDK vhost" vhost_run 0 notice "..." trap 'clean_lvol_cfg; error_exit "${FUNCNAME}" "${LINENO}"' SIGTERM SIGABRT ERR lvol_stores=() lvol_bdevs=() nest_lvol_stores=() nest_lvol_bdevs=() used_vms="" # On each NVMe create one lvol store for (( i=0; i