From f714562f5a80aeda97e4173cc42951cbb1f22d34 Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Wed, 12 Apr 2023 15:33:10 +0200 Subject: [PATCH] test/spdkcli: Wait long enough for the nvme ctrl to be gone Some nvmes need more time to attach|detach to|from, hence having a static sleep is not ideal depending on what type of the nvme was picked up for the test. Instead, simply wait until the list of nvme ctrls is empty after the cleanup. Change-Id: I2fc2630020436d0e1f6b01a5ce60aea56e7bf8ec Signed-off-by: Michal Berger Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17559 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Krzysztof Karas Reviewed-by: Konrad Sztyber --- test/spdkcli/common.sh | 4 ++++ test/spdkcli/vhost.sh | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/test/spdkcli/common.sh b/test/spdkcli/common.sh index aa54110fc..263d96bf9 100644 --- a/test/spdkcli/common.sh +++ b/test/spdkcli/common.sh @@ -45,3 +45,7 @@ function check_match() { $rootdir/test/app/match/match $testdir/match_files/${MATCH_FILE}.match rm -f $testdir/match_files/${MATCH_FILE} } + +function wait_for_all_nvme_ctrls_to_detach() { + while (($(rpc_cmd bdev_nvme_get_controllers | jq '.|length') != 0)); do :; done +} diff --git a/test/spdkcli/vhost.sh b/test/spdkcli/vhost.sh index 5507a9e6f..5901916ea 100755 --- a/test/spdkcli/vhost.sh +++ b/test/spdkcli/vhost.sh @@ -131,8 +131,11 @@ $spdkcli_job "'load_config $testdir/config.json' " check_match $spdk_clear_config_py clear_config -# FIXME: remove this sleep when NVMe driver will be fixed to wait for reset to complete -sleep 2 + +# Make sure we wait long enough for the nvme ctrl to disappear, otherwise +# we are at risk of hitting -EPERM while loading bdev configuration. +xtrace_disable_per_cmd wait_for_all_nvme_ctrls_to_detach + $spdkcli_job "'load_subsystem_config $testdir/config_bdev.json' 'load_subsystem_config $testdir/config_vhost_scsi.json' 'load_subsystem_config $testdir/config_vhost_blk.json'