#!/usr/bin/env bash
-set -e
testdir=$(readlink -f $(dirname $0))
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"
vm_image="/home/sys_sgsw/windows_server.qcow2"
-function usage()
-{
- [[ ! -z $2 ]] && ( echo "$2"; echo ""; )
+function usage() {
+ [[ -n $2 ]] && (
+ echo "$2"
+ echo ""
+ )
echo "Windows Server automated test"
echo "Usage: $(basename $1) [OPTIONS]"
echo "--vm-ssh-pass=PASSWORD Text password for the VM"
while getopts 'xh-:' optchar; do
case "$optchar" in
-)
- case "$OPTARG" in
- help) usage $0 ;;
- vm-ssh-pass=*) ssh_pass="${OPTARG#*=}" ;;
- vm-image=*) vm_image="${OPTARG#*=}" ;;
- ctrl-type=*) ctrl_type="${OPTARG#*=}" ;;
- esac
- ;;
- h) usage $0 ;;
- x) set -x
- x="-x" ;;
- *) usage $0 "Invalid argument '$OPTARG'"
+ case "$OPTARG" in
+ help) usage $0 ;;
+ vm-ssh-pass=*) ssh_pass="${OPTARG#*=}" ;;
+ vm-image=*) vm_image="${OPTARG#*=}" ;;
+ ctrl-type=*) ctrl_type="${OPTARG#*=}" ;;
+ esac
+ ;;
+ h) usage $0 ;;
+ x)
+ set -x
+ x="-x"
+ ;;
+ *) usage $0 "Invalid argument '$OPTARG'" ;;
esac
done
# But they apply to rather old Windows distributions.
# Potentially using Windows Server 2016 and newer may solve the issue
# due to OpenSSH being available directly from Windows Store.
-function vm_sshpass()
-{
+function vm_sshpass() {
vm_num_is_valid $1 || return 1
- local ssh_cmd="sshpass -p $2 ssh \
+ local ssh_cmd
+ ssh_cmd="sshpass -p $2 ssh \
-o UserKnownHostsFile=/dev/null \
-o StrictHostKeyChecking=no \
-o User=root \
# Violating this rule doesn't cause any issues for SPDK vhost,
# but triggers an assert, so we can only run Windows VMs with non-debug SPDK builds.
notice "running SPDK vhost"
-vhost_run
+vhost_run 0
notice "..."
# Prepare bdevs for later vhost controllers use
# Using various sizes to better identify bdevs if no name in BLK
# is available
# TODO: use a param for blocksize for AIO and Malloc bdevs
-aio_file="$testdir/aio_disk"
+aio_file="$SPDK_TEST_STORAGE/aio_disk"
dd if=/dev/zero of=$aio_file bs=1M count=512
-$rpc_py construct_aio_bdev $aio_file Aio0 512
-$rpc_py construct_malloc_bdev -b Malloc0 256 512
-$rpc_py get_bdevs
+$rpc_py bdev_aio_create $aio_file Aio0 512
+$rpc_py bdev_malloc_create -b Malloc0 256 512
+$rpc_py bdev_get_bdevs
-# Construct vhost controllers
+# Create vhost controllers
# Prepare VM setup command
setup_cmd="vm_setup --force=0 --memory=8192"
setup_cmd+=" --os=$vm_image"
if [[ "$ctrl_type" == "spdk_vhost_scsi" ]]; then
- $rpc_py construct_vhost_scsi_controller naa.0.0
- $rpc_py add_vhost_scsi_lun naa.0.0 0 Nvme0n1
- $rpc_py add_vhost_scsi_lun naa.0.0 1 Malloc0
- $rpc_py add_vhost_scsi_lun naa.0.0 2 Aio0
+ $rpc_py vhost_create_scsi_controller naa.0.0
+ $rpc_py vhost_scsi_controller_add_target naa.0.0 0 Nvme0n1
+ $rpc_py vhost_scsi_controller_add_target naa.0.0 1 Malloc0
+ $rpc_py vhost_scsi_controller_add_target naa.0.0 2 Aio0
setup_cmd+=" --disk-type=spdk_vhost_scsi --disks=0"
elif [[ "$ctrl_type" == "spdk_vhost_blk" ]]; then
- $rpc_py construct_vhost_blk_controller naa.0.0 Nvme0n1
- $rpc_py construct_vhost_blk_controller naa.1.0 Malloc0
- $rpc_py construct_vhost_blk_controller naa.2.0 Aio0
+ $rpc_py vhost_create_blk_controller naa.0.0 Nvme0n1
+ $rpc_py vhost_create_blk_controller naa.1.0 Malloc0
+ $rpc_py vhost_create_blk_controller naa.2.0 Aio0
setup_cmd+=" --disk-type=spdk_vhost_blk --disks=0:1:2"
fi
-$rpc_py get_vhost_controllers
+$rpc_py vhost_get_controllers
$setup_cmd
# Spin up VM
vm_kill $vm_num
notice "Shutting down SPDK vhost app..."
-vhost_kill
+vhost_kill 0
rm -f $aio_file