Commit 7cefe7f6 authored by Sebastian Brzezinka's avatar Sebastian Brzezinka Committed by Ben Walker
Browse files

test/sma: vfiouser attach crypto bdev



The test uses bdev_crypto and vfiouser devices to verify that
volumes with crypto parameters are correctly attached

Signed-off-by: default avatarSebastian Brzezinka <sebastian.brzezinka@intel.com>
Change-Id: I9abed43f3df803870af11d7f28601f5f9390474c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13997


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent a70732c9
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -139,6 +139,10 @@ $rootdir/scripts/sma.py -c <(
		          count: 32
		      qmp_addr: 127.0.0.1
		      qmp_port: 10005
		crypto:
		  name: 'bdev_crypto'
		  params:
		    driver: 'crypto_aesni_mb'
	EOF
) &
smapid=$!
@@ -258,5 +262,38 @@ detach_volume "$device1" "$uuid0"
delete_device "$device0"
delete_device "$device1"

key0=1234567890abcdef1234567890abcdef
device0=$(create_device 0 0 | jq -r '.handle')
uuid0=$(rpc_cmd bdev_get_bdevs -b null0 | jq -r '.[].uuid')

# Now check vfio-user attach with bdev crypto
"$rootdir/scripts/sma-client.py" <<- ATTACH
	{
	  "method": "AttachVolume",
	  "params": {
	    "device_handle": "$device0",
	    "volume": {
	      "volume_id": "$(uuid2base64 $uuid0)",
	      "crypto": {
	        "cipher": "$(get_cipher AES_CBC)",
	        "key": "$(format_key $key0)"
	      }
	    }
	  }
	}
ATTACH

# Make sure that the namespace exposed in the subsystem is a crypto bdev
ns_bdev=$(rpc_cmd nvmf_get_subsystems nqn.2016-06.io.spdk:vfiouser-0 | jq -r '.[0].namespaces[0].name')
[[ $(rpc_cmd bdev_get_bdevs -b "$ns_bdev" | jq -r '.[0].product_name') == "crypto" ]]
crypto_bdev=$(rpc_cmd bdev_get_bdevs -b "$ns_bdev" | jq -r '.[] | select(.product_name == "crypto")')
[[ $(rpc_cmd bdev_get_bdevs | jq -r '[.[] | select(.product_name == "crypto")] | length') -eq 1 ]]

[[ $(jq -r '.driver_specific.crypto.key' <<< "$crypto_bdev") == "$key0" ]]

detach_volume "$device0" "$uuid0"
delete_device "$device0"
[[ $(rpc_cmd bdev_get_bdevs | jq -r '.[] | select(.product_name == "crypto")' | jq -r length) -eq 0 ]]

cleanup
trap - SIGINT SIGTERM EXIT