1#!/usr/bin/env bash 2 3testdir=$(readlink -f $(dirname $0)) 4rootdir=$(readlink -f $testdir/../..) 5source $rootdir/test/common/autotest_common.sh 6source $rootdir/test/spdkcli/common.sh 7 8MATCH_FILE="spdkcli_vhost.test" 9SPDKCLI_BRANCH="/" 10 11sample_aio=$SPDK_TEST_STORAGE/sample_aio 12sample_aio2=$SPDK_TEST_STORAGE/sample_aio2 13 14trap 'on_error_exit' ERR 15timing_enter run_vhost_tgt 16run_vhost_tgt 17timing_exit run_vhost_tgt 18 19timing_enter spdkcli_create_bdevs_config 20$spdkcli_job "'/bdevs/malloc create 40 512 Malloc0' 'Malloc0' True 21'/bdevs/malloc create 32 512 Malloc1' 'Malloc1' True 22'/bdevs/malloc create 32 512 Malloc2' 'Malloc2' True 23'/bdevs/malloc create 32 4096 Malloc3' 'Malloc3' True 24'/bdevs/malloc create 32 4096 Malloc4' 'Malloc4' True 25'/bdevs/malloc create 32 4096 Malloc5' 'Malloc5' True 26'/bdevs/error create Malloc1' 'EE_Malloc1' True 27'/bdevs/error create Malloc4' 'EE_Malloc4' True 28'/bdevs/null create null_bdev0 32 512' 'null_bdev0' True 29'/bdevs/null create null_bdev1 32 512' 'null_bdev1' True 30" 31dd if=/dev/zero of="$sample_aio" bs=2048 count=5000 32dd if=/dev/zero of="$sample_aio2" bs=2048 count=5000 33$spdkcli_job "'/bdevs/aio create sample0 $sample_aio 512' 'sample0' True 34'/bdevs/aio create sample1 $sample_aio2 512' 'sample1' True 35" 36trtype=$($rootdir/scripts/gen_nvme.sh | jq -r '.config[].params | select(.name=="Nvme0").trtype') 37traddr=$($rootdir/scripts/gen_nvme.sh | jq -r '.config[].params | select(.name=="Nvme0").traddr') 38$spdkcli_job "'/bdevs/nvme create Nvme0 $trtype $traddr' 'Nvme0' True 39'/bdevs/split_disk bdev_split_create Nvme0n1 4' 'Nvme0n1p0' True 40" 41timing_exit spdkcli_create_bdevs_config 42 43timing_enter spdkcli_create_lvols_config 44$spdkcli_job "'/lvol_stores create lvs0 Malloc0' 'lvs0' True 45'/lvol_stores create lvs1 Malloc5' 'lvs1' True 46'/bdevs/logical_volume create lvol0 16 lvs0' 'lvs0/lvol0' True 47'/bdevs/logical_volume create lvol1 16 lvs0' 'lvs0/lvol1' True 48" 49timing_exit spdkcli_create_lvols_config 50 51timing_enter spdkcli_check_match_details 52$rootdir/scripts/spdkcli.py /lvol_stores/lvs0 show_details | jq -r -S '.' > $testdir/match_files/spdkcli_details_lvs.test 53$rootdir/test/app/match/match $testdir/match_files/spdkcli_details_lvs.test.match 54rm -f $testdir/match_files/spdkcli_details_lvs.test 55timing_exit spdkcli_check_match_details 56 57timing_enter spdkcli_create_vhosts_config 58$spdkcli_job "'vhost/block create vhost_blk1 Nvme0n1p0' 'Nvme0n1p0' True 59'vhost/block create vhost_blk2 Nvme0n1p1 0x1 readonly' 'Nvme0n1p1' True 60'vhost/scsi create vhost_scsi1' 'vhost_scsi1' True 61'vhost/scsi create vhost_scsi2' 'vhost_scsi2' True 62'vhost/scsi/vhost_scsi1 add_lun 0 Malloc2' 'Malloc2' True 63'vhost/scsi/vhost_scsi2 add_lun 0 Malloc3' 'Malloc3' True 64'vhost/scsi/vhost_scsi2 add_lun 1 Nvme0n1p2' 'Nvme0n1p2' True 65'vhost/scsi/vhost_scsi2 add_lun 2 Nvme0n1p3' 'Nvme0n1p3' True 66'vhost/scsi/vhost_scsi1 set_coalescing 20 1000000' '' True 67" 68timing_exit spdkcli_create_vhosts_config 69 70timing_enter spdkcli_check_match 71check_match 72timing_exit spdkcli_check_match 73 74timing_enter spdkcli_save_config 75$spdkcli_job "'save_config $testdir/config.json' 76'save_subsystem_config $testdir/config_bdev.json bdev' 77'save_subsystem_config $testdir/config_vhost.json vhost' 78" 79timing_exit spdkcli_save_config 80 81timing_enter spdkcli_check_match_details 82$rootdir/scripts/spdkcli.py vhost/scsi/vhost_scsi1/Target_0 show_details | jq -r -S '.' > $testdir/match_files/spdkcli_details_vhost_target.test 83$rootdir/test/app/match/match $testdir/match_files/spdkcli_details_vhost_target.test.match 84rm -f $testdir/match_files/spdkcli_details_vhost_target.test 85 86$rootdir/scripts/spdkcli.py bdevs/split_disk/Nvme0n1p0 show_details | jq -r -S '.' > $testdir/match_files/spdkcli_details_vhost.test 87$rootdir/test/app/match/match $testdir/match_files/spdkcli_details_vhost.test.match 88rm -f $testdir/match_files/spdkcli_details_vhost.test 89 90$rootdir/scripts/spdkcli.py vhost/scsi/vhost_scsi1 show_details | jq -r -S '.' > $testdir/match_files/spdkcli_details_vhost_ctrl.test 91$rootdir/test/app/match/match $testdir/match_files/spdkcli_details_vhost_ctrl.test.match 92rm -f $testdir/match_files/spdkcli_details_vhost_ctrl.test 93timing_exit spdkcli_check_match_details 94 95timing_enter spdkcli_clear_config 96$spdkcli_job "'vhost/scsi/vhost_scsi2 remove_target 2' 'Nvme0n1p3' 97'vhost/scsi/vhost_scsi2 remove_target 1' 'Nvme0n1p2' 98'vhost/scsi/vhost_scsi2 remove_target 0' 'Malloc3' 99'vhost/scsi/vhost_scsi1 remove_target 0' 'Malloc2' 100'vhost/scsi delete vhost_scsi2' 'vhost_scsi2' 101'vhost/scsi delete vhost_scsi1' 'vhost_scsi1' 102'vhost/block delete vhost_blk2' 'vhost_blk2' 103'vhost/block delete vhost_blk1' 'vhost_blk1' 104'/bdevs/split_disk bdev_split_delete Nvme0n1' 'Nvme0n1p0' 105'/bdevs/aio delete sample0' 'sample0' 106'/bdevs/aio delete_all' 'sample1' 107'/bdevs/nvme delete Nvme0' 'Nvme0' 108'/bdevs/null delete null_bdev0' 'null_bdev0' 109'/bdevs/null delete_all' 'null_bdev1' 110'/bdevs/logical_volume delete lvs0/lvol0' 'lvs0/lvol0' 111'/bdevs/logical_volume delete_all' 'lvs0/lvol1' 112'/lvol_stores delete lvs0' 'lvs0' 113'/lvol_stores delete_all' 'lvs1' 114'/bdevs/error delete EE_Malloc1' 'EE_Malloc1' 115'/bdevs/error delete_all' 'EE_Malloc4' 116'/bdevs/malloc delete Malloc0' 'Malloc0' 117'/bdevs/malloc delete_all' 'Malloc1' 118" 119timing_exit spdkcli_clear_config 120 121timing_enter spdkcli_load_config 122$spdkcli_job "'load_config $testdir/config.json' 123'/lvol_stores create lvs0 Malloc0' 'lvs0' True 124'/lvol_stores create lvs1 Malloc5' 'lvs1' True 125'/bdevs/logical_volume create lvol0 16 lvs0' 'lvs0/lvol0' True 126'/bdevs/logical_volume create lvol1 16 lvs0' 'lvs0/lvol1' True 127" 128check_match 129$spdk_clear_config_py clear_config 130# FIXME: remove this sleep when NVMe driver will be fixed to wait for reset to complete 131sleep 2 132$spdkcli_job "'load_subsystem_config $testdir/config_bdev.json' 133'load_subsystem_config $testdir/config_vhost.json' 134'/lvol_stores create lvs0 Malloc0' 'lvs0' True 135'/lvol_stores create lvs1 Malloc5' 'lvs1' True 136'/bdevs/logical_volume create lvol0 16 lvs0' 'lvs0/lvol0' True 137'/bdevs/logical_volume create lvol1 16 lvs0' 'lvs0/lvol1' True 138" 139check_match 140$spdk_clear_config_py clear_config 141rm -f $testdir/config.json 142rm -f $testdir/config_bdev.json 143rm -f $testdir/config_vhost.json 144rm -f "$sample_aio" "$sample_aio2" 145timing_exit spdkcli_load_config 146 147killprocess $vhost_tgt_pid 148