test/vhost: modify vm_setup() to create setup with mixed disk types

vm_setup was creating setup with only one disk type defined.
With this patch it can set disk type per disk by adding disk type
after disk name separated by coma
e.g.
vm_setup --disks="Nvme0n1,spdk_vhost_scsi"

Change-Id: Ib89f440210468f4c9082aadcf07ce461e34c4ff8
Signed-off-by: Pawel Niedzwiecki <pawelx.niedzwiecki@intel.com>
Reviewed-on: https://review.gerrithub.io/395980
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Pawel Niedzwiecki 2018-01-23 19:19:23 +01:00 committed by Jim Harris
parent face9eb258
commit d60c81e250
2 changed files with 35 additions and 26 deletions

View File

@ -420,7 +420,7 @@ function vm_setup()
local os=""
local os_mode=""
local qemu_args=""
local disk_type=NOT_DEFINED
local disk_type_g=NOT_DEFINED
local disks=""
local raw_cache=""
local vm_incoming=""
@ -435,7 +435,7 @@ function vm_setup()
os=*) local os="${OPTARG#*=}" ;;
os-mode=*) local os_mode="${OPTARG#*=}" ;;
qemu-args=*) local qemu_args="${qemu_args} ${OPTARG#*=}" ;;
disk-type=*) local disk_type="${OPTARG#*=}" ;;
disk-type=*) local disk_type_g="${OPTARG#*=}" ;;
disks=*) local disks="${OPTARG#*=}" ;;
raw-cache=*) local raw_cache=",cache${OPTARG#*=}" ;;
force=*) local force_vm=${OPTARG#*=} ;;
@ -574,11 +574,18 @@ function vm_setup()
cmd+="-drive file=$os,if=none,id=os_disk ${eol}"
cmd+="-device ide-hd,drive=os_disk,bootindex=0 ${eol}"
if ( [[ $disks == '' ]] && [[ $disk_type == virtio* ]] ); then
if ( [[ $disks == '' ]] && [[ $disk_type_g == virtio* ]] ); then
disks=1
fi
for disk in ${disks//:/ }; do
if [[ $disk = *","* ]]; then
disk_type=${disk#*,}
disk=${disk%,*}
else
disk_type=$disk_type_g
fi
case $disk_type in
virtio)
local raw_name="RAWSCSI"

View File

@ -10,7 +10,7 @@ function usage()
echo "Shortcut script for setting up VMs for tests"
echo "Usage: $(basename $1) [OPTIONS] VM_NUM"
echo
echo "-h, --help print help and exit"
echo "-h, --help Print help and exit"
echo " --work-dir=WORK_DIR Where to find build file. Must exit. (default: $TEST_DIR)"
echo " --force=VM_NUM Force VM_NUM reconfiguration if already exist"
echo " --disk-type=TYPE Perform specified test:"
@ -20,10 +20,12 @@ function usage()
echo " spdk_vhost_blk - use spdk vhost block"
echo " --raw-cache=CACHE Use CACHE for virtio test: "
echo " writethrough, writeback, none, unsafe or directsyns"
echo " --disk=PATH Disk to use in test. test specific meaning:"
echo " --disk=PATH[,disk_type] Disk to use in test. test specific meaning:"
echo " virtio - disk path (file or block device ex: /dev/nvme0n1)"
echo " kernel_vhost - the WWN number to be used"
echo " spdk_vhost_[scsi|blk] - the socket path."
echo " optional disk_type - set disk type for disk (overwrites test-type)"
echo " e.g. /dev/nvme0n1,spdk_vhost_scsi"
echo " --os=OS_QCOW2 Custom OS qcow2 image file"
echo " --os-mode=MODE MODE how to use provided image: default: backing"
echo " backing - create new image but use provided backing file"