3 testdir
=$
(readlink
-f $
(dirname $0))
4 rootdir
=$
(readlink
-f $testdir/..
/..
/..
)
5 source $rootdir/test
/common
/autotest_common.sh
6 source $rootdir/test
/nvmf
/common.sh
8 if [ -z "${DEPENDENCY_DIR}" ]; then
9 echo DEPENDENCY_DIR not defined
!
13 spdk_nvme_cli
="${DEPENDENCY_DIR}/nvme-cli"
18 rpc_py
="$rootdir/scripts/rpc.py"
22 # pass the parameter 'iso' to this script when running it in isolation to trigger rdma device initialization.
23 # e.g. sudo ./nvme_cli.sh iso
26 RDMA_IP_LIST
=$
(get_available_rdma_ips
)
27 NVMF_FIRST_TARGET_IP
=$
(echo "$RDMA_IP_LIST" |
head -n 1)
28 if [ -z $NVMF_FIRST_TARGET_IP ]; then
29 echo "no NIC for nvmf test"
34 timing_enter start_nvmf_tgt
38 trap "process_shm --id $NVMF_APP_SHM_ID; killprocess $nvmfpid; nvmftestfini $1; exit 1" SIGINT SIGTERM EXIT
40 waitforlisten
$nvmfpid
41 $rpc_py nvmf_create_transport
-t RDMA
-u 8192 -p 4
42 timing_exit start_nvmf_tgt
44 bdevs
="$($rpc_py construct_malloc_bdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE) "
45 bdevs
+="$($rpc_py construct_malloc_bdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE)"
49 $rpc_py nvmf_subsystem_create nqn
.2016-06.io.spdk
:cnode1
-a -s SPDK00000000000001
50 for bdev
in $bdevs; do
51 $rpc_py nvmf_subsystem_add_ns nqn
.2016-06.io.spdk
:cnode1
$bdev
53 $rpc_py nvmf_subsystem_add_listener nqn
.2016-06.io.spdk
:cnode1
-t rdma
-a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT
55 nvme connect
-t rdma
-n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"
62 for ctrl
in /dev
/nvme?
; do
67 for ns
in /dev
/nvme?n
*; do
71 nvme disconnect
-n "nqn.2016-06.io.spdk:cnode1" || true
72 nvme disconnect
-n "nqn.2016-06.io.spdk:cnode2" || true
74 if [ -d $spdk_nvme_cli ]; then
75 # Test spdk/nvme-cli NVMe-oF commands: discover, connect and disconnect
77 .
/nvme discover
-t rdma
-a $NVMF_FIRST_TARGET_IP -s "$NVMF_PORT"
78 nvme_num_before_connection
=$
(nvme list |
grep "/dev/nvme*"|
awk '{print $1}'|
wc -l)
79 .
/nvme connect
-t rdma
-n "nqn.2016-06.io.spdk:cnode1" -a "$NVMF_FIRST_TARGET_IP" -s "$NVMF_PORT"
81 nvme_num
=$
(nvme list |
grep "/dev/nvme*"|
awk '{print $1}'|
wc -l)
82 .
/nvme disconnect
-n "nqn.2016-06.io.spdk:cnode1"
83 if [ $nvme_num -le $nvme_num_before_connection ]; then
84 echo "spdk/nvme-cli connect target devices failed"
89 $rpc_py delete_nvmf_subsystem nqn
.2016-06.io.spdk
:cnode1
90 trap - SIGINT SIGTERM EXIT
95 report_test_completion
"nvmf_spdk_nvme_cli"