From 29ca9d63b80da396f8cf84690831a2129c939848 Mon Sep 17 00:00:00 2001 From: Pawel Kaminski Date: Wed, 3 Apr 2019 08:28:18 -0400 Subject: [PATCH] test/vhost: Remove ramdisk and vhost disk from targetcli if script fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #694 Change-Id: I8c3a34923ece8e11f1f3fefc3e642a00dd83a735 Signed-off-by: Pawel Kaminski Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/450022 Tested-by: SPDK CI Jenkins Reviewed-by: Karol Latecki Reviewed-by: Paweł Niedźwiecki Reviewed-by: Darek Stojaczyk Reviewed-by: Shuhei Matsumoto Reviewed-by: Ben Walker --- test/vhost/initiator/blockdev.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/vhost/initiator/blockdev.sh b/test/vhost/initiator/blockdev.sh index cba90b53a..3d812602a 100755 --- a/test/vhost/initiator/blockdev.sh +++ b/test/vhost/initiator/blockdev.sh @@ -64,12 +64,16 @@ fi function remove_kernel_vhost() { - targetcli "/vhost delete $kernel_vhost_disk" - targetcli "/backstores/$targetcli_rd_name delete ramdisk" + if targetcli "/vhost/$kernel_vhost_disk ls"; then + targetcli "/vhost delete $kernel_vhost_disk" + fi + if targetcli "/backstores/$targetcli_rd_name/ramdisk ls"; then + targetcli "/backstores/$targetcli_rd_name delete ramdisk" + fi } trap 'rm -f *.state $ROOT_DIR/spdk.tar.gz $ROOT_DIR/fio.tar.gz $(get_vhost_dir)/Virtio0;\ - error_exit "${FUNCNAME}""${LINENO}"' ERR SIGTERM SIGABRT + remove_kernel_vhost; error_exit "${FUNCNAME}""${LINENO}"' ERR SIGTERM SIGABRT function run_spdk_fio() { LD_PRELOAD=$PLUGIN_DIR/fio_plugin $FIO_PATH/fio --ioengine=spdk_bdev\ "$@" --spdk_mem=1024 --spdk_single_seg=1