test/vhost: Cleanup the way how nvmf_tgt is handled in migration test
Signed-off-by: Michal Berger <michalx.berger@intel.com> Change-Id: I7e739a4e085d150b0be73cd890f0cf85f05ab7fd Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7200 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Karol Latecki <karol.latecki@intel.com>
This commit is contained in:
parent
bfdb9de3f0
commit
c5cba2c16a
@ -1,43 +1,13 @@
|
|||||||
source $rootdir/test/nvmf/common.sh
|
source $rootdir/test/nvmf/common.sh
|
||||||
|
|
||||||
function migration_tc2_cleanup_nvmf_tgt() {
|
function migration_tc2_cleanup_nvmf_tgt() {
|
||||||
local i
|
process_shm --id $NVMF_APP_SHM_ID
|
||||||
|
nvmftestfini
|
||||||
if [[ ! -r "$nvmf_dir/nvmf_tgt.pid" ]]; then
|
|
||||||
warning "Pid file '$nvmf_dir/nvmf_tgt.pid' does not exist. "
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n "$1" ]]; then
|
|
||||||
trap 'error_exit "${FUNCNAME}" "${LINENO}"' INT ERR EXIT
|
|
||||||
pkill --signal $1 -F $nvmf_dir/nvmf_tgt.pid || true
|
|
||||||
sleep 5
|
|
||||||
if ! pkill -F $nvmf_dir/nvmf_tgt.pid; then
|
|
||||||
fail "failed to kill nvmf_tgt app"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
pkill --signal SIGTERM -F $nvmf_dir/nvmf_tgt.pid || true
|
|
||||||
for ((i = 0; i < 20; i++)); do
|
|
||||||
if ! pkill --signal 0 -F $nvmf_dir/nvmf_tgt.pid; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
sleep 0.5
|
|
||||||
done
|
|
||||||
|
|
||||||
if pkill --signal 0 -F $nvmf_dir/nvmf_tgt.pid; then
|
|
||||||
error "nvmf_tgt failed to shutdown"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm $nvmf_dir/nvmf_tgt.pid
|
|
||||||
unset -v nvmf_dir rpc_nvmf
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function migration_tc2_cleanup_vhost_config() {
|
function migration_tc2_cleanup_vhost_config() {
|
||||||
timing_enter migration_tc2_cleanup_vhost_config
|
timing_enter migration_tc2_cleanup_vhost_config
|
||||||
|
|
||||||
trap 'migration_tc2_cleanup_nvmf_tgt SIGKILL; error_exit "${FUNCNAME}" "${LINENO}"' INT ERR EXIT
|
|
||||||
|
|
||||||
notice "Shutting down all VMs"
|
notice "Shutting down all VMs"
|
||||||
vm_shutdown_all
|
vm_shutdown_all
|
||||||
|
|
||||||
@ -56,7 +26,6 @@ function migration_tc2_cleanup_vhost_config() {
|
|||||||
unset -v incoming_vm target_vm incoming_vm_ctrlr target_vm_ctrlr
|
unset -v incoming_vm target_vm incoming_vm_ctrlr target_vm_ctrlr
|
||||||
unset -v rpc_0 rpc_1
|
unset -v rpc_0 rpc_1
|
||||||
|
|
||||||
trap 'error_exit "${FUNCNAME}" "${LINENO}"' INT ERR EXIT
|
|
||||||
migration_tc2_cleanup_nvmf_tgt
|
migration_tc2_cleanup_nvmf_tgt
|
||||||
|
|
||||||
timing_exit migration_tc2_cleanup_vhost_config
|
timing_exit migration_tc2_cleanup_vhost_config
|
||||||
@ -65,22 +34,18 @@ function migration_tc2_cleanup_vhost_config() {
|
|||||||
function migration_tc2_configure_vhost() {
|
function migration_tc2_configure_vhost() {
|
||||||
timing_enter migration_tc2_configure_vhost
|
timing_enter migration_tc2_configure_vhost
|
||||||
|
|
||||||
|
TEST_TRANSPORT=rdma TEST_MODE=iso nvmftestinit
|
||||||
|
|
||||||
# Those are global intentionally - they will be unset in cleanup handler
|
# Those are global intentionally - they will be unset in cleanup handler
|
||||||
nvmf_dir="$VHOST_DIR/nvmf_tgt"
|
|
||||||
|
|
||||||
incoming_vm=1
|
incoming_vm=1
|
||||||
target_vm=2
|
target_vm=2
|
||||||
incoming_vm_ctrlr=naa.VhostScsi0.$incoming_vm
|
incoming_vm_ctrlr=naa.VhostScsi0.$incoming_vm
|
||||||
target_vm_ctrlr=naa.VhostScsi0.$target_vm
|
target_vm_ctrlr=naa.VhostScsi0.$target_vm
|
||||||
|
|
||||||
rpc_nvmf="$rootdir/scripts/rpc.py -s $nvmf_dir/rpc.sock"
|
|
||||||
rpc_0="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
|
rpc_0="$rootdir/scripts/rpc.py -s $(get_vhost_dir 0)/rpc.sock"
|
||||||
rpc_1="$rootdir/scripts/rpc.py -s $(get_vhost_dir 1)/rpc.sock"
|
rpc_1="$rootdir/scripts/rpc.py -s $(get_vhost_dir 1)/rpc.sock"
|
||||||
|
|
||||||
# Default cleanup/error handlers will not shutdown nvmf_tgt app so setup it
|
|
||||||
# here to teardown in cleanup function
|
|
||||||
trap 'migration_tc2_error_cleanup; error_exit "${FUNCNAME}" "${LINENO}"' INT ERR EXIT
|
|
||||||
|
|
||||||
# Run nvmf_tgt and two vhost instances:
|
# Run nvmf_tgt and two vhost instances:
|
||||||
# nvmf_tgt uses core id 2 (-m 0x4)
|
# nvmf_tgt uses core id 2 (-m 0x4)
|
||||||
# First uses core id 0
|
# First uses core id 0
|
||||||
@ -88,15 +53,13 @@ function migration_tc2_configure_vhost() {
|
|||||||
# This force to use VM 1 and 2.
|
# This force to use VM 1 and 2.
|
||||||
timing_enter start_nvmf_tgt
|
timing_enter start_nvmf_tgt
|
||||||
notice "Running nvmf_tgt..."
|
notice "Running nvmf_tgt..."
|
||||||
mkdir -p $nvmf_dir
|
nvmfappstart -s 512 -m 0x4 --wait-for-rpc
|
||||||
rm -f $nvmf_dir/*
|
# Override the trap set in place via nvmfappstart()
|
||||||
$SPDK_BIN_DIR/nvmf_tgt -s 512 -m 0x4 -r $nvmf_dir/rpc.sock --wait-for-rpc &
|
trap 'migration_tc2_error_cleanup; error_exit "${FUNCNAME}" "${LINENO}"' INT ERR EXIT
|
||||||
local nvmf_tgt_pid=$!
|
rpc_cmd framework_start_init
|
||||||
echo $nvmf_tgt_pid > $nvmf_dir/nvmf_tgt.pid
|
rpc_cmd nvmf_create_transport $NVMF_TRANSPORT_OPTS -u 8192
|
||||||
waitforlisten "$nvmf_tgt_pid" "$nvmf_dir/rpc.sock"
|
mapfile -t json < <("$rootdir/scripts/gen_nvme.sh")
|
||||||
$rpc_nvmf framework_start_init
|
rpc_cmd load_subsystem_config -j "'${json[*]}'"
|
||||||
$rpc_nvmf nvmf_create_transport -t RDMA -u 8192
|
|
||||||
$rootdir/scripts/gen_nvme.sh | $rpc_nvmf load_subsystem_config
|
|
||||||
timing_exit start_nvmf_tgt
|
timing_exit start_nvmf_tgt
|
||||||
|
|
||||||
vhost_run -n 0 -a "-m 0x1 -s 512 -u"
|
vhost_run -n 0 -a "-m 0x1 -s 512 -u"
|
||||||
@ -114,9 +77,9 @@ function migration_tc2_configure_vhost() {
|
|||||||
notice "Configuring nvmf_tgt, vhost devices & controllers via RPC ..."
|
notice "Configuring nvmf_tgt, vhost devices & controllers via RPC ..."
|
||||||
|
|
||||||
# Construct shared bdevs and controllers
|
# Construct shared bdevs and controllers
|
||||||
$rpc_nvmf nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001
|
rpc_cmd nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001
|
||||||
$rpc_nvmf nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Nvme0n1
|
rpc_cmd nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 Nvme0n1
|
||||||
$rpc_nvmf nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t rdma -a $nvmf_target_ip -s 4420
|
rpc_cmd nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t rdma -a $nvmf_target_ip -s 4420
|
||||||
|
|
||||||
$rpc_0 bdev_nvme_attach_controller -b Nvme0 -t rdma -f ipv4 -a $nvmf_target_ip -s 4420 -n "nqn.2016-06.io.spdk:cnode1"
|
$rpc_0 bdev_nvme_attach_controller -b Nvme0 -t rdma -f ipv4 -a $nvmf_target_ip -s 4420 -n "nqn.2016-06.io.spdk:cnode1"
|
||||||
$rpc_0 vhost_create_scsi_controller $incoming_vm_ctrlr
|
$rpc_0 vhost_create_scsi_controller $incoming_vm_ctrlr
|
||||||
@ -144,10 +107,8 @@ function migration_tc2_configure_vhost() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function migration_tc2_error_cleanup() {
|
function migration_tc2_error_cleanup() {
|
||||||
trap - SIGINT ERR EXIT
|
|
||||||
set -x
|
|
||||||
|
|
||||||
vm_kill_all
|
vm_kill_all
|
||||||
|
migration_tc2_cleanup_nvmf_tgt
|
||||||
migration_tc2_cleanup_vhost_config
|
migration_tc2_cleanup_vhost_config
|
||||||
notice "Migration TC2 FAILED"
|
notice "Migration TC2 FAILED"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user