]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/test/vhost/integrity/integrity_start.sh
import 15.2.0 Octopus source
[ceph.git] / ceph / src / spdk / test / vhost / integrity / integrity_start.sh
CommitLineData
7c673cae 1#!/usr/bin/env bash
11fdf7f2
TL
2set -e
3
9f95a23c
TL
4testdir=$(readlink -f $(dirname $0))
5rootdir=$(readlink -f $testdir/../../..)
6source $rootdir/test/common/autotest_common.sh
7source $rootdir/test/vhost/common.sh
8
11fdf7f2
TL
9ctrl_type="spdk_vhost_scsi"
10vm_fs="ext4"
11
12function 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
29function 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
36while 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
51done
7c673cae 52
9f95a23c
TL
53vhosttestinit
54
55. $(readlink -e "$(dirname $0)/../common.sh") || exit 1
56rpc_py="$rootdir/scripts/rpc.py -s $(get_vhost_dir)/rpc.sock"
7c673cae 57
11fdf7f2 58trap 'error_exit "${FUNCNAME}" "${LINENO}"' SIGTERM SIGABRT ERR
7c673cae 59
11fdf7f2
TL
60# Try to kill if any VM remains from previous runs
61vm_kill_all
7c673cae 62
11fdf7f2 63notice "Starting SPDK vhost"
9f95a23c 64vhost_run
11fdf7f2 65notice "..."
7c673cae 66
11fdf7f2
TL
67# Set up lvols and vhost controllers
68trap 'clean_lvol_cfg; error_exit "${FUNCNAME}" "${LINENO}"' SIGTERM SIGABRT ERR
69notice "Constructing lvol store and lvol bdev on top of Nvme0n1"
70lvs_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
73if [[ "$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
76elif [[ "$ctrl_type" == "spdk_vhost_blk" ]]; then
77 $rpc_py construct_vhost_blk_controller naa.Nvme0n1.0 lvol_store/lvol_bdev
7c673cae
FG
78fi
79
11fdf7f2
TL
80# Set up and run VM
81setup_cmd="vm_setup --disk-type=$ctrl_type --force=0"
82setup_cmd+=" --os=/home/sys_sgsw/vhost_vm_image.qcow2"
83setup_cmd+=" --disks=Nvme0n1"
84$setup_cmd
7c673cae 85
11fdf7f2
TL
86# Run VM
87vm_run 0
9f95a23c 88vm_wait_for_boot 300 0
7c673cae 89
11fdf7f2 90# Run tests on VM
9f95a23c 91vm_scp 0 $testdir/integrity_vm.sh root@127.0.0.1:/root/integrity_vm.sh
11fdf7f2
TL
92vm_ssh 0 "~/integrity_vm.sh $ctrl_type \"$vm_fs\""
93
94notice "Shutting down virtual machine..."
95vm_shutdown_all
96
97clean_lvol_cfg
98
99$rpc_py delete_nvme_controller Nvme0
7c673cae 100
11fdf7f2 101notice "Shutting down SPDK vhost app..."
9f95a23c
TL
102vhost_kill
103
104vhosttestfini