[PATCH v4 2/7] nvme: consolidate some nvme-cli utility functions

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



On 2020-08-14 12:18 a.m., Sagi Grimberg wrote:
> diff --git a/tests/nvme/004 b/tests/nvme/004
> index b841a8d4cd87..7ea539fda55e 100755
> --- a/tests/nvme/004
> +++ b/tests/nvme/004
> @@ -33,14 +33,14 @@ test() {
>  		"91fdba0d-f87b-4c25-b80f-db7be1418b9e"
>  	_add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1"
>  
> -	nvme connect -t loop -n blktests-subsystem-1
> +	_nvme_connect_subsys "loop" "blktests-subsystem-1"

A bit of a nit, but the quotes around "loop" are unnecessary here and in
a bunch of other places.

> @@ -97,6 +97,33 @@ _setup_nvmet() {
>  	modprobe nvme-loop
>  }
>  
> +_nvme_disconnect_ctrl() {
> +	local ctrl="$1"
> +
> +	nvme disconnect -d ${ctrl}> +}
> +
> +_nvme_disconnect_subsys() {
> +	local subsysnqn="$1"
> +
> +	nvme disconnect -n ${subsysnqn}
> +}

Missing quotes around ctrl and subsysnqn.

> +
> +_nvme_connect_subsys() {
> +	local trtype="$1"
> +	local subsysnqn="$2"
> +
> +	cmd="nvme connect -t ${trtype} -n ${subsysnqn}"
> +	eval $cmd
> +}

I still don't understand why we are using eval here.  There are no
quotes round trtpe and subsysnqn and because of eval they need to be
doubled...



More information about the Linux-nvme mailing list