[PATCH v4 3/7] nvme: make tests transport type agnostic

Logan Gunthorpe logang at deltatee.com
Fri Aug 14 12:24:26 EDT 2020



On 2020-08-14 12:18 a.m., Sagi Grimberg wrote:
>  _nvme_disconnect_ctrl() {
> @@ -112,20 +121,33 @@ _nvme_disconnect_subsys() {
>  _nvme_connect_subsys() {
>  	local trtype="$1"
>  	local subsysnqn="$2"
> +	local traddr="${3:-$def_traddr}"
> +	local trsvcid="${4:-$def_trsvcid}"
>  
>  	cmd="nvme connect -t ${trtype} -n ${subsysnqn}"
> +	if [[ "${trtype}" != "loop" ]]; then
> +		cmd=$cmd" -a ${traddr} -s ${trsvcid}"
> +	fi
>  	eval $cmd
>  }

I think this pattern would be done better with a bash array instead of
an eval, which will get the quoting correct:

ARGS=(-t "${trtype}" -n "${subsysnqn}")
if [[ "${trtype}" != "loop" ]]; then
    ARGS+=(-a "${traddr}" -s "${trsvcid}")
fi
nvme connect "${ARGS[@]}"




More information about the Linux-nvme mailing list