]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | #!/usr/bin/env bash |
11fdf7f2 TL |
2 | set -e |
3 | ||
9f95a23c TL |
4 | testdir=$(readlink -f $(dirname $0)) |
5 | rootdir=$(readlink -f $testdir/../../..) | |
6 | source $rootdir/test/common/autotest_common.sh | |
7 | source $rootdir/test/vhost/common.sh | |
8 | ||
11fdf7f2 TL |
9 | ctrl_type="spdk_vhost_scsi" |
10 | vm_fs="ext4" | |
11 | ||
12 | function usage() | |
13 | { | |
14 | [[ ! -z $2 ]] && ( echo "$2"; echo ""; ) | |
15 | echo "Shortcut script for doing automated test" | |
16 | echo "Usage: $(basename $1) [OPTIONS]" | |
17 | echo | |
18 | echo "-h, --help Print help and exit" | |
11fdf7f2 TL |
19 | echo " --ctrl-type=TYPE Controller type to use for test:" |
20 | echo " spdk_vhost_scsi - use spdk vhost scsi" | |
21 | echo " --fs=FS_LIST Filesystems to use for test in VM:" | |
22 | echo " Example: --fs=\"ext4 ntfs ext2\"" | |
23 | echo " Default: ext4" | |
24 | echo " spdk_vhost_blk - use spdk vhost block" | |
25 | echo "-x set -x for script debug" | |
26 | exit 0 | |
27 | } | |
7c673cae | 28 | |
11fdf7f2 TL |
29 | function clean_lvol_cfg() |
30 | { | |
31 | notice "Removing lvol bdev and lvol store" | |
32 | $rpc_py destroy_lvol_bdev lvol_store/lvol_bdev | |
33 | $rpc_py destroy_lvol_store -l lvol_store | |
34 | } | |
7c673cae | 35 | |
11fdf7f2 TL |
36 | while getopts 'xh-:' optchar; do |
37 | case "$optchar" in | |
38 | -) | |
39 | case "$OPTARG" in | |
40 | help) usage $0 ;; | |
41 | ctrl-type=*) ctrl_type="${OPTARG#*=}" ;; | |
42 | fs=*) vm_fs="${OPTARG#*=}" ;; | |
43 | *) usage $0 "Invalid argument '$OPTARG'" ;; | |
44 | esac | |
45 | ;; | |
46 | h) usage $0 ;; | |
47 | x) set -x | |
48 | x="-x" ;; | |
49 | *) usage $0 "Invalid argument '$OPTARG'" | |
50 | esac | |
51 | done | |
7c673cae | 52 | |
9f95a23c TL |
53 | vhosttestinit |
54 | ||
55 | . $(readlink -e "$(dirname $0)/../common.sh") || exit 1 | |
56 | rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir)/rpc.sock" | |
7c673cae | 57 | |
11fdf7f2 | 58 | trap 'error_exit "${FUNCNAME}" "${LINENO}"' SIGTERM SIGABRT ERR |
7c673cae | 59 | |
11fdf7f2 TL |
60 | # Try to kill if any VM remains from previous runs |
61 | vm_kill_all | |
7c673cae | 62 | |
11fdf7f2 | 63 | notice "Starting SPDK vhost" |
9f95a23c | 64 | vhost_run |
11fdf7f2 | 65 | notice "..." |
7c673cae | 66 | |
11fdf7f2 TL |
67 | # Set up lvols and vhost controllers |
68 | trap 'clean_lvol_cfg; error_exit "${FUNCNAME}" "${LINENO}"' SIGTERM SIGABRT ERR | |
69 | notice "Constructing lvol store and lvol bdev on top of Nvme0n1" | |
70 | lvs_uuid=$($rpc_py construct_lvol_store Nvme0n1 lvol_store) | |
71 | $rpc_py construct_lvol_bdev lvol_bdev 10000 -l lvol_store | |
7c673cae | 72 | |
11fdf7f2 TL |
73 | if [[ "$ctrl_type" == "spdk_vhost_scsi" ]]; then |
74 | $rpc_py construct_vhost_scsi_controller naa.Nvme0n1.0 | |
75 | $rpc_py add_vhost_scsi_lun naa.Nvme0n1.0 0 lvol_store/lvol_bdev | |
76 | elif [[ "$ctrl_type" == "spdk_vhost_blk" ]]; then | |
77 | $rpc_py construct_vhost_blk_controller naa.Nvme0n1.0 lvol_store/lvol_bdev | |
7c673cae FG |
78 | fi |
79 | ||
11fdf7f2 TL |
80 | # Set up and run VM |
81 | setup_cmd="vm_setup --disk-type=$ctrl_type --force=0" | |
82 | setup_cmd+=" --os=/home/sys_sgsw/vhost_vm_image.qcow2" | |
83 | setup_cmd+=" --disks=Nvme0n1" | |
84 | $setup_cmd | |
7c673cae | 85 | |
11fdf7f2 TL |
86 | # Run VM |
87 | vm_run 0 | |
9f95a23c | 88 | vm_wait_for_boot 300 0 |
7c673cae | 89 | |
11fdf7f2 | 90 | # Run tests on VM |
9f95a23c | 91 | vm_scp 0 $testdir/integrity_vm.sh root@127.0.0.1:/root/integrity_vm.sh |
11fdf7f2 TL |
92 | vm_ssh 0 "~/integrity_vm.sh $ctrl_type \"$vm_fs\"" |
93 | ||
94 | notice "Shutting down virtual machine..." | |
95 | vm_shutdown_all | |
96 | ||
97 | clean_lvol_cfg | |
98 | ||
99 | $rpc_py delete_nvme_controller Nvme0 | |
7c673cae | 100 | |
11fdf7f2 | 101 | notice "Shutting down SPDK vhost app..." |
9f95a23c TL |
102 | vhost_kill |
103 | ||
104 | vhosttestfini |