From d60c81e250da200a5c07aa1ed7e1c7f51a351858 Mon Sep 17 00:00:00 2001 From: Pawel Niedzwiecki Date: Tue, 23 Jan 2018 19:19:23 +0100 Subject: [PATCH] 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 Reviewed-on: https://review.gerrithub.io/395980 Reviewed-by: Karol Latecki Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: --- test/vhost/common/common.sh | 13 +++++++--- test/vhost/common/vm_setup.sh | 48 ++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/test/vhost/common/common.sh b/test/vhost/common/common.sh index f025fb2db..0ac671759 100644 --- a/test/vhost/common/common.sh +++ b/test/vhost/common/common.sh @@ -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" diff --git a/test/vhost/common/vm_setup.sh b/test/vhost/common/vm_setup.sh index 8dffb2340..ec3740c13 100755 --- a/test/vhost/common/vm_setup.sh +++ b/test/vhost/common/vm_setup.sh @@ -10,29 +10,31 @@ 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 " --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:" - echo " virtio - test host virtio-scsi-pci using file as disk image" - echo " kernel_vhost - use kernel driver vhost-scsi" - echo " spdk_vhost_scsi - use spdk vhost scsi" - 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 " 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 " --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" - echo " copy - copy provided image and use a copy" - echo " orginal - use file directly. Will modify the provided file" - echo " --incoming=VM_NUM Use VM_NUM as source migration VM." - echo " --migrate-to=VM_NUM Use VM_NUM as target migration VM." - echo "-x Turn on script debug (set -x)" - echo "-v Be more verbose" + 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:" + echo " virtio - test host virtio-scsi-pci using file as disk image" + echo " kernel_vhost - use kernel driver vhost-scsi" + echo " spdk_vhost_scsi - use spdk vhost scsi" + 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_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" + echo " copy - copy provided image and use a copy" + echo " orginal - use file directly. Will modify the provided file" + echo " --incoming=VM_NUM Use VM_NUM as source migration VM." + echo " --migrate-to=VM_NUM Use VM_NUM as target migration VM." + echo "-x Turn on script debug (set -x)" + echo "-v Be more verbose" exit 0 }