From 7cefe7f62d636ddb307bfc678085b63dc60b07aa Mon Sep 17 00:00:00 2001 From: Sebastian Brzezinka Date: Thu, 11 Aug 2022 15:55:56 +0200 Subject: [PATCH] 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: Sebastian Brzezinka Change-Id: I9abed43f3df803870af11d7f28601f5f9390474c Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13997 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Konrad Sztyber Reviewed-by: Jim Harris --- test/sma/vfiouser_qemu.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/test/sma/vfiouser_qemu.sh b/test/sma/vfiouser_qemu.sh index de94d9705..13ec48725 100755 --- a/test/sma/vfiouser_qemu.sh +++ b/test/sma/vfiouser_qemu.sh @@ -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