xref: /spdk/test/vhost/windows/windows_scsi_compliance.sh (revision b3bec07939ebe2ea2e0c43931705d32aa9e06719)
1#!/usr/bin/env bash
2#  SPDX-License-Identifier: BSD-3-Clause
3#  Copyright (C) 2019 Intel Corporation
4#  All rights reserved.
5#
6testdir=$(readlink -f $(dirname $0))
7rootdir=$(readlink -f $testdir/../../..)
8source $rootdir/test/common/autotest_common.sh
9source $rootdir/test/vhost/common.sh
10
11# Tested with windows vm with OS Name: Microsoft Windows Server 2012 R2 Datacenter
12# and OS Version: 6.3.9600 N/A Build 9600
13# In order to run this test with windows vm
14# windows virtio scsi driver must be installed
15WINDOWS_IMG="$DEPENDENCY_DIR/storage/windows_scsi_compliance/windows_vm_image.qcow2"
16aio_file="$SPDK_TEST_STORAGE/aio_disk"
17ssh_pass=""
18vm_num=1
19keep_results_dir=false
20rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
21
22function usage() {
23	[[ -n $2 ]] && (
24		echo "$2"
25		echo ""
26	)
27	echo "Windows Server scsi compliance test"
28	echo "Usage: $(basename $1) [OPTIONS]"
29	echo "  --vm-ssh-pass=PASSWORD    Text password for the VM"
30	echo "  --vm-image-path           Path of windows image"
31	echo "  --keep_results            Do not delete dir with results"
32
33	exit 0
34}
35
36while getopts 'h-:' optchar; do
37	case "$optchar" in
38		-)
39			case "$OPTARG" in
40				help) usage $0 ;;
41				vm-ssh-pass=*) ssh_pass="${OPTARG#*=}" ;;
42				vm-image-path=*) WINDOWS_IMG="${OPTARG#*=}" ;;
43				keep_results*) keep_results_dir=true ;;
44			esac
45			;;
46		h) usage $0 ;;
47		*) usage $0 "Invalid argument '$OPTARG'" ;;
48	esac
49done
50
51trap 'rm -f $aio_file; rm -rf $testdir/results; error_exit' SIGINT SIGTERM ERR
52
53VM_PASSWORD="$ssh_pass"
54mkdir -p $testdir/results
55dd if=/dev/zero of=$aio_file bs=1M count=512
56
57timing_enter vhost_run
58vhost_run -n 0
59$rpc_py bdev_nvme_set_hotplug -e
60$rpc_py bdev_malloc_create 256 4096 -b Malloc0
61$rpc_py bdev_aio_create $aio_file Aio0 512
62$rpc_py bdev_get_bdevs
63$rpc_py vhost_create_scsi_controller naa.vhost.1
64$rpc_py vhost_scsi_controller_add_target naa.vhost.1 0 Nvme0n1
65$rpc_py vhost_scsi_controller_add_target naa.vhost.1 1 Malloc0
66# TODO: Currently there is bug for aio device. Disable this test
67# $rpc_py vhost_scsi_controller_add_target naa.vhost.1 2 Aio0
68timing_exit vhost_run
69
70timing_enter start_vm
71vm_setup --force=1 --disk-type=spdk_vhost_scsi --os=$WINDOWS_IMG --disks=vhost --memory=4096
72vm_run "1"
73# Wait until VM goes up
74vm_wait_for_boot "300" "$vm_num"
75timing_exit start_vm
76
77vm_scp "$vm_num" $testdir/windows_scsi_compliance.ps1 127.0.0.1:/cygdrive/c/SCSI/
78vm_sshpass "$vm_num" "$ssh_pass" "cd /cygdrive/c/SCSI; powershell.exe -file windows_scsi_compliance.ps1"
79vm_scp "$vm_num" 127.0.0.1:/cygdrive/c/SCSI/WIN_SCSI_* $testdir/results/
80dos2unix $testdir/results/WIN_SCSI_*.log
81
82notice "Kill vm 1"
83vm_kill "$vm_num"
84notice "Kill spdk"
85vhost_kill 0
86notice "Remove $aio_file"
87rm -f $aio_file
88
89python3 $testdir/windows_scsi_compliance.py
90if ! $keep_results_dir; then
91	rm -rf $testdir/results
92fi
93