From f7f016d5ef08679b9eb69c8f164328d4caf2bada Mon Sep 17 00:00:00 2001 From: Karol Latecki Date: Fri, 24 Apr 2020 17:02:32 +0200 Subject: [PATCH] autotest_common: pass optional arguments to discover_bdevs Allow passing additional args to discover_bdevs function, primarily for use in bdev_svc app. This is needed mostly in case of virtio tests when host uses 2MB huge pages - "-g" option is then needed to run SPDK app. Need to make timeout value hardcoded while at it. Can't have 2 optional positional arguments. Timeout as an option is never used so this shouldn't be a problem. Signed-off-by: Karol Latecki Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2021/4 (master) This patch is a bit different than it's merged version in master branch (a3e5b5d0ec954433c9b19bcd1b331483fd4e0c12). This was done to allow running virtio tests with 2MB hugepages. (cherry-picked from 387fe9f44d80411013dada4f6d73fc49505bfaed) Change-Id: I2a455f9d23fafbf0746423f69379b74939ac2e9c Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2104 Reviewed-by: Ben Walker Reviewed-by: Darek Stojaczyk Reviewed-by: Tomasz Zawadzki Tested-by: SPDK CI Jenkins --- test/common/autotest_common.sh | 6 ++++-- test/vhost/initiator/blockdev.sh | 9 ++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/test/common/autotest_common.sh b/test/common/autotest_common.sh index 165531bec1..19dccd9126 100755 --- a/test/common/autotest_common.sh +++ b/test/common/autotest_common.sh @@ -827,7 +827,9 @@ function discover_bdevs() local rootdir=$1 local config_file=$2 local cfg_type=$3 - local wait_for_spdk_bdev=${4:-30} + shift 3 + local bdev_svc_opts=("$@") + local wait_for_spdk_bdev=30 local rpc_server=/var/tmp/spdk-discover-bdevs.sock if [ ! -e $config_file ]; then @@ -841,7 +843,7 @@ function discover_bdevs() # Start the bdev service to query for the list of available # bdevs. - $rootdir/test/app/bdev_svc/bdev_svc -r $rpc_server -i 0 \ + $rootdir/test/app/bdev_svc/bdev_svc -r $rpc_server -i 0 "${bdev_svc_opts[@]}" \ $cfg_type $config_file &>/dev/null & stubpid=$! while ! [ -e /var/run/spdk_bdev0 ]; do diff --git a/test/vhost/initiator/blockdev.sh b/test/vhost/initiator/blockdev.sh index 5ed02f502a..eecba973f2 100755 --- a/test/vhost/initiator/blockdev.sh +++ b/test/vhost/initiator/blockdev.sh @@ -58,6 +58,7 @@ function run_spdk_fio() { function create_bdev_config() { local vbdevs + local g_opt if [ -z "$($RPC_PY bdev_get_bdevs | jq '.[] | select(.name=="Nvme0n1")')" ]; then error "Nvme0n1 bdev not found!" @@ -82,7 +83,13 @@ function create_bdev_config() $RPC_PY vhost_create_scsi_controller naa.Malloc1.0 $RPC_PY vhost_scsi_controller_add_target naa.Malloc1.0 0 Malloc1 - vbdevs=$(discover_bdevs $rootdir $testdir/bdev.json "--json") + # Check default size of host hugepages. If it's 2MB then we have to use + # bdev_svc "-g" option for virtio devices. + if (( $(grep "Hugepagesize" /proc/meminfo | grep -Eo "[[:digit:]]+") == 2048 )); then + g_opt="-g" + fi + + vbdevs=$(discover_bdevs $rootdir $testdir/bdev.json "--json" $g_opt) virtio_bdevs=$(jq -r '[.[].name] | join(":")' <<< $vbdevs) virtio_with_unmap=$(jq -r '[.[] | select(.supported_io_types.unmap==true).name] | join(":")' <<< $vbdevs)