2019-04-12 15:43:47 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
testdir=$(readlink -f $(dirname $0))
|
|
|
|
rootdir=$testdir/../../..
|
|
|
|
source $rootdir/test/common/autotest_common.sh
|
|
|
|
source $rootdir/test/nvmf/common.sh
|
2019-06-06 14:25:52 +00:00
|
|
|
|
|
|
|
if [ ! -d "/usr/local/qemu/spdk-3.0.0" ]; then
|
|
|
|
echo "Qemu not installed on this machine. It may be a VM. Skipping nvmf_vhost test."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-05-21 16:22:22 +00:00
|
|
|
source $rootdir/test/vhost/common.sh
|
2019-04-12 15:43:47 +00:00
|
|
|
|
|
|
|
MALLOC_BDEV_SIZE=128
|
|
|
|
MALLOC_BLOCK_SIZE=512
|
|
|
|
NVMF_SOCK="/tmp/nvmf_rpc.sock"
|
|
|
|
NVMF_RPC="$rootdir/scripts/rpc.py -s $NVMF_SOCK"
|
|
|
|
|
|
|
|
VHOST_SOCK="/tmp/vhost_rpc.sock"
|
2020-02-20 10:24:53 +00:00
|
|
|
VHOST_APP+=(-p 0 -r "$VHOST_SOCK" -u)
|
2019-04-12 15:43:47 +00:00
|
|
|
VHOST_RPC="$rootdir/scripts/rpc.py -s $VHOST_SOCK"
|
|
|
|
|
2019-06-03 16:37:06 +00:00
|
|
|
nvmftestinit
|
|
|
|
|
2019-04-12 15:43:47 +00:00
|
|
|
# Start Apps
|
2020-02-20 10:24:53 +00:00
|
|
|
"${NVMF_APP[@]}" -r $NVMF_SOCK &
|
2019-04-12 15:43:47 +00:00
|
|
|
nvmfpid=$!
|
|
|
|
waitforlisten $nvmfpid $NVMF_SOCK
|
|
|
|
|
2019-08-09 08:46:01 +00:00
|
|
|
trap 'process_shm --id $NVMF_APP_SHM_ID; nvmftestfini; exit 1' SIGINT SIGTERM EXIT
|
2019-04-12 15:43:47 +00:00
|
|
|
|
|
|
|
mkdir -p "$(get_vhost_dir 3)"
|
|
|
|
|
2020-02-20 10:24:53 +00:00
|
|
|
"${VHOST_APP[@]}" -S "$(get_vhost_dir 3)" &
|
2019-04-12 15:43:47 +00:00
|
|
|
vhostpid=$!
|
|
|
|
waitforlisten $vhostpid $NVMF_SOCK
|
|
|
|
|
2019-08-09 08:46:01 +00:00
|
|
|
trap 'process_shm --id $NVMF_APP_SHM_ID; killprocess $vhostpid nvmftestfini; exit 1' SIGINT SIGTERM EXIT
|
2019-04-12 15:43:47 +00:00
|
|
|
|
|
|
|
# Configure NVMF tgt on host machine
|
2019-08-09 11:15:35 +00:00
|
|
|
malloc_bdev="$($NVMF_RPC bdev_malloc_create $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE)"
|
2019-04-12 15:43:47 +00:00
|
|
|
|
2019-07-15 04:42:41 +00:00
|
|
|
$NVMF_RPC nvmf_create_transport $NVMF_TRANSPORT_OPTS -u 8192 -p 4
|
2019-09-20 10:22:44 +00:00
|
|
|
$NVMF_RPC nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001
|
2019-04-12 15:43:47 +00:00
|
|
|
$NVMF_RPC nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 "$malloc_bdev"
|
2019-06-03 16:34:31 +00:00
|
|
|
$NVMF_RPC nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT
|
2019-04-12 15:43:47 +00:00
|
|
|
|
|
|
|
# Configure VHost on host machine
|
2019-08-23 13:50:51 +00:00
|
|
|
$VHOST_RPC bdev_nvme_attach_controller -b Nvme0 -t $TEST_TRANSPORT -f ipv4 -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT -n nqn.2016-06.io.spdk:cnode1
|
2019-09-24 14:29:10 +00:00
|
|
|
$VHOST_RPC vhost_create_scsi_controller naa.VhostScsi0.3
|
2019-09-27 20:53:41 +00:00
|
|
|
$VHOST_RPC vhost_scsi_controller_add_target naa.VhostScsi0.3 0 "Nvme0n1"
|
2019-04-12 15:43:47 +00:00
|
|
|
|
|
|
|
# start qemu based VM.
|
2020-05-07 11:27:06 +00:00
|
|
|
vm_setup --os="$VM_IMAGE" --disk-type=spdk_vhost_scsi --disks="VhostScsi0" --force=3 --vhost-name=3
|
2019-04-12 15:43:47 +00:00
|
|
|
|
|
|
|
vm_run 3
|
|
|
|
|
|
|
|
vm_wait_for_boot 300 3
|
|
|
|
|
|
|
|
# Run the fio workload remotely
|
|
|
|
vm_scp 3 $testdir/nvmf_vhost_fio.job 127.0.0.1:/root/nvmf_vhost_fio.job
|
2019-06-04 22:00:09 +00:00
|
|
|
vm_exec 3 "fio /root/nvmf_vhost_fio.job"
|
2019-04-12 15:43:47 +00:00
|
|
|
vm_shutdown_all
|
|
|
|
|
|
|
|
trap - SIGINT SIGTERM EXIT
|
|
|
|
|
|
|
|
killprocess $vhostpid
|
2019-06-03 16:37:06 +00:00
|
|
|
nvmftestfini
|