]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/test/vhost/fiotest/vm_setup.sh
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / spdk / test / vhost / fiotest / vm_setup.sh
1 #!/usr/bin/env bash
2
3 BASE_DIR=$(readlink -f $(dirname $0))
4 [[ -z "$TEST_DIR" ]] && TEST_DIR="$(cd $BASE_DIR/../../../../ && pwd)"
5
6 function usage()
7 {
8 [[ ! -z $2 ]] && ( echo "$2"; echo ""; )
9 echo "Shortcut script for setting up VMs for tests"
10 echo "Usage: $(basename $1) [OPTIONS] VM_NUM"
11 echo
12 echo "-h, --help print help and exit"
13 echo "-f VM_NUM Force VM_NUM reconfiguration if already exist"
14 echo " --work-dir=WORK_DIR Where to find build file. Must exit. (default: $TEST_DIR)"
15 echo " --test-type=TYPE Perform specified test:"
16 echo " virtio - test host virtio-scsi-pci using file as disk image"
17 echo " kernel_vhost - use kernel driver vhost-scsi"
18 echo " spdk_vhost - use spdk vhost"
19 echo " ---cache=CACHE Use CACHE for virtio test: "
20 echo " writethrough, writeback, none, unsafe or directsyns"
21 echo " Default is writethrough"
22 echo " --disk=PATH Disk to use in test. test specific meaning:"
23 echo " virtio - disk path (file or block device ex: /dev/nvme0n1)"
24 echo " kernel_vhost - the WWN number to be used"
25 echo " spdk_vhost - the socket path. Default is WORK_DIR/vhost/usvhost"
26 echo " --os=OS_QCOW2 Custom OS qcow2 image file"
27 echo " --os-mode=MODE MODE how to use provided image: default: backing"
28 echo " backing - create new image but use provided backing file"
29 echo " copy - copy provided image and use a copy"
30 echo " orginal - use file directly. Will modify the provided file"
31 echo "-x Turn on script debug (set -x)"
32 exit 0
33 }
34 disk=""
35 raw_cache=""
36 img_mode=""
37 os=""
38 while getopts 'xf:h-:' optchar; do
39 case "$optchar" in
40 -)
41 case "$OPTARG" in
42 help) usage $0 ;;
43 work-dir=*) TEST_DIR="${OPTARG#*=}" ;;
44 raw-cache=*) raw_cache="--raw-cache=${OPTARG#*=}" ;;
45 test-type=*) test_type="${OPTARG#*=}" ;;
46 disk=*) disk="${OPTARG#*=}" ;;
47 os=*) os="${OPTARG#*=}"
48 if [[ ! -r "$os" ]]; then
49 echo "ERROR: can't read '$os'"
50 usage $0
51 fi
52 os="$(readlink -f $os)"
53 ;;
54 os-mode=*) os_mode="--os-mode=${OPTARG#*=}" ;;
55 *) usage $0 "Invalid argument '$OPTARG'" ;;
56 esac
57 ;;
58 h) usage $0 ;;
59 x) set -x ;;
60 f) force_vm_num="--force=${OPTARG#*=}" ;;
61 *) usage $0 "Invalid argument '$OPTARG'" ;;
62 esac
63 done
64
65 . $BASE_DIR/common.sh
66
67 [[ -z "$os" ]] && os="$TEST_DIR/debian.qcow2"
68 [[ $test_type == "spdk_vhost" ]] && [[ -z "$disk" ]] && disk="$SPDK_VHOST_SCSI_TEST_DIR/usvhost"
69 if [[ $test_type == "kernel_vhost" ]] && [[ -z "$disk" ]]; then
70 echo "ERROR: for $test_type '--disk=WWN' is mandatory"
71 exit 1
72 fi
73
74 vm_setup \
75 --os=$os \
76 --disk-type=$test_type \
77 --disks=$disk \
78 $wwn $raw_cache $force_vm_num $os_mode