test: exercise crypto rpc calls
Most vbdevs have complete test suites that include rpc calls to set them up and teare them down. With crypto there's not a lot to do w/test other than make sure it's configured and run IO so right now that amounts to tools that use a config (ini) file. Adding create/delete calls here to get basic rpc coverage in CI. The fixes/udpates in the vbdev module and the .py files were fixes found in enabling testing of the rpc calls. Change-Id: I5d7d25e1c96dcf76e0055f23d27781b858e290b0 Signed-off-by: paul luse <paul.e.luse@intel.com> Reviewed-on: https://review.gerrithub.io/425875 Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
7a6c69283a
commit
cafd537c7d
@ -969,7 +969,7 @@ vbdev_crypto_dump_info_json(void *ctx, struct spdk_json_write_ctx *w)
|
|||||||
|
|
||||||
spdk_json_write_name(w, "crypto");
|
spdk_json_write_name(w, "crypto");
|
||||||
spdk_json_write_object_begin(w);
|
spdk_json_write_object_begin(w);
|
||||||
spdk_json_write_name(w, "crypto_bdev_name");
|
spdk_json_write_name(w, "name");
|
||||||
spdk_json_write_string(w, spdk_bdev_get_name(&crypto_bdev->crypto_bdev));
|
spdk_json_write_string(w, spdk_bdev_get_name(&crypto_bdev->crypto_bdev));
|
||||||
spdk_json_write_name(w, "base_bdev_name");
|
spdk_json_write_name(w, "base_bdev_name");
|
||||||
spdk_json_write_string(w, spdk_bdev_get_name(crypto_bdev->base_bdev));
|
spdk_json_write_string(w, spdk_bdev_get_name(crypto_bdev->base_bdev));
|
||||||
@ -991,7 +991,7 @@ vbdev_crypto_config_json(struct spdk_json_write_ctx *w)
|
|||||||
spdk_json_write_named_string(w, "method", "construct_crypto_bdev");
|
spdk_json_write_named_string(w, "method", "construct_crypto_bdev");
|
||||||
spdk_json_write_named_object_begin(w, "params");
|
spdk_json_write_named_object_begin(w, "params");
|
||||||
spdk_json_write_named_string(w, "base_bdev_name", spdk_bdev_get_name(crypto_bdev->base_bdev));
|
spdk_json_write_named_string(w, "base_bdev_name", spdk_bdev_get_name(crypto_bdev->base_bdev));
|
||||||
spdk_json_write_named_string(w, "crypto_bdev_name", spdk_bdev_get_name(&crypto_bdev->crypto_bdev));
|
spdk_json_write_named_string(w, "name", spdk_bdev_get_name(&crypto_bdev->crypto_bdev));
|
||||||
spdk_json_write_named_string(w, "crypto_pmd", crypto_bdev->drv_name);
|
spdk_json_write_named_string(w, "crypto_pmd", crypto_bdev->drv_name);
|
||||||
spdk_json_write_named_string(w, "key", crypto_bdev->key);
|
spdk_json_write_named_string(w, "key", crypto_bdev->key);
|
||||||
spdk_json_write_object_end(w);
|
spdk_json_write_object_end(w);
|
||||||
@ -1125,15 +1125,16 @@ create_crypto_disk(const char *bdev_name, const char *vbdev_name,
|
|||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
bdev = spdk_bdev_get_by_name(bdev_name);
|
bdev = spdk_bdev_get_by_name(bdev_name);
|
||||||
if (!bdev) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = vbdev_crypto_insert_name(bdev_name, vbdev_name, crypto_pmd, key);
|
rc = vbdev_crypto_insert_name(bdev_name, vbdev_name, crypto_pmd, key);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!bdev) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
vbdev_crypto_claim(bdev);
|
vbdev_crypto_claim(bdev);
|
||||||
|
|
||||||
rc = vbdev_crypto_init_crypto_drivers();
|
rc = vbdev_crypto_init_crypto_drivers();
|
||||||
@ -1430,6 +1431,7 @@ error_claim:
|
|||||||
error_open:
|
error_open:
|
||||||
TAILQ_REMOVE(&g_vbdev_crypto, vbdev, link);
|
TAILQ_REMOVE(&g_vbdev_crypto, vbdev, link);
|
||||||
spdk_io_device_unregister(vbdev, NULL);
|
spdk_io_device_unregister(vbdev, NULL);
|
||||||
|
free(vbdev->drv_name);
|
||||||
error_drv_name:
|
error_drv_name:
|
||||||
free(vbdev->key);
|
free(vbdev->key);
|
||||||
error_alloc_key:
|
error_alloc_key:
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
/* Structure to hold the parameters for this RPC method. */
|
/* Structure to hold the parameters for this RPC method. */
|
||||||
struct rpc_construct_crypto {
|
struct rpc_construct_crypto {
|
||||||
char *base_bdev_name;
|
char *base_bdev_name;
|
||||||
char *crypto_bdev_name;
|
char *name;
|
||||||
char *crypto_pmd;
|
char *crypto_pmd;
|
||||||
char *key;
|
char *key;
|
||||||
};
|
};
|
||||||
@ -46,7 +46,7 @@ static void
|
|||||||
free_rpc_construct_crypto(struct rpc_construct_crypto *r)
|
free_rpc_construct_crypto(struct rpc_construct_crypto *r)
|
||||||
{
|
{
|
||||||
free(r->base_bdev_name);
|
free(r->base_bdev_name);
|
||||||
free(r->crypto_bdev_name);
|
free(r->name);
|
||||||
free(r->crypto_pmd);
|
free(r->crypto_pmd);
|
||||||
free(r->key);
|
free(r->key);
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ free_rpc_construct_crypto(struct rpc_construct_crypto *r)
|
|||||||
/* Structure to decode the input parameters for this RPC method. */
|
/* Structure to decode the input parameters for this RPC method. */
|
||||||
static const struct spdk_json_object_decoder rpc_construct_crypto_decoders[] = {
|
static const struct spdk_json_object_decoder rpc_construct_crypto_decoders[] = {
|
||||||
{"base_bdev_name", offsetof(struct rpc_construct_crypto, base_bdev_name), spdk_json_decode_string},
|
{"base_bdev_name", offsetof(struct rpc_construct_crypto, base_bdev_name), spdk_json_decode_string},
|
||||||
{"crypto_bdev_name", offsetof(struct rpc_construct_crypto, crypto_bdev_name), spdk_json_decode_string},
|
{"name", offsetof(struct rpc_construct_crypto, name), spdk_json_decode_string},
|
||||||
{"crypto_pmd", offsetof(struct rpc_construct_crypto, crypto_pmd), spdk_json_decode_string},
|
{"crypto_pmd", offsetof(struct rpc_construct_crypto, crypto_pmd), spdk_json_decode_string},
|
||||||
{"key", offsetof(struct rpc_construct_crypto, key), spdk_json_decode_string},
|
{"key", offsetof(struct rpc_construct_crypto, key), spdk_json_decode_string},
|
||||||
};
|
};
|
||||||
@ -77,7 +77,7 @@ spdk_rpc_construct_crypto_bdev(struct spdk_jsonrpc_request *request,
|
|||||||
goto invalid;
|
goto invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = create_crypto_disk(req.base_bdev_name, req.crypto_bdev_name,
|
rc = create_crypto_disk(req.base_bdev_name, req.name,
|
||||||
req.crypto_pmd, req.key);
|
req.crypto_pmd, req.key);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
goto invalid;
|
goto invalid;
|
||||||
@ -89,7 +89,7 @@ spdk_rpc_construct_crypto_bdev(struct spdk_jsonrpc_request *request,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
spdk_json_write_string(w, req.crypto_bdev_name);
|
spdk_json_write_string(w, req.name);
|
||||||
spdk_jsonrpc_end_result(request, w);
|
spdk_jsonrpc_end_result(request, w);
|
||||||
free_rpc_construct_crypto(&req);
|
free_rpc_construct_crypto(&req);
|
||||||
return;
|
return;
|
||||||
|
@ -135,13 +135,13 @@ if __name__ == "__main__":
|
|||||||
def construct_crypto_bdev(args):
|
def construct_crypto_bdev(args):
|
||||||
print(rpc.bdev.construct_crypto_bdev(args.client,
|
print(rpc.bdev.construct_crypto_bdev(args.client,
|
||||||
base_bdev_name=args.base_bdev_name,
|
base_bdev_name=args.base_bdev_name,
|
||||||
crypto_bdev_name=args.crypto_bdev_name,
|
name=args.name,
|
||||||
crypto_pmd=args.crypto_pmd,
|
crypto_pmd=args.crypto_pmd,
|
||||||
key=args.key))
|
key=args.key))
|
||||||
p = subparsers.add_parser('construct_crypto_bdev',
|
p = subparsers.add_parser('construct_crypto_bdev',
|
||||||
help='Add a crypto vbdev')
|
help='Add a crypto vbdev')
|
||||||
p.add_argument('-b', '--base_bdev_name', help="Name of the base bdev")
|
p.add_argument('-b', '--base_bdev_name', help="Name of the base bdev")
|
||||||
p.add_argument('-c', '--crypto_bdev_name', help="Name of the crypto vbdev")
|
p.add_argument('-c', '--name', help="Name of the crypto vbdev")
|
||||||
p.add_argument('-d', '--crypto_pmd', help="Name of the crypto device driver")
|
p.add_argument('-d', '--crypto_pmd', help="Name of the crypto device driver")
|
||||||
p.add_argument('-k', '--key', help="Key")
|
p.add_argument('-k', '--key', help="Key")
|
||||||
p.set_defaults(func=construct_crypto_bdev)
|
p.set_defaults(func=construct_crypto_bdev)
|
||||||
|
8
scripts/rpc/bdev.py
Normal file → Executable file
8
scripts/rpc/bdev.py
Normal file → Executable file
@ -15,19 +15,19 @@ def set_bdev_options(client, bdev_io_pool_size=None, bdev_io_cache_size=None):
|
|||||||
return client.call('set_bdev_options', params)
|
return client.call('set_bdev_options', params)
|
||||||
|
|
||||||
|
|
||||||
def construct_crypto_bdev(client, base_bdev_name, crypto_bdev_name, crypto_pmd, key):
|
def construct_crypto_bdev(client, base_bdev_name, name, crypto_pmd, key):
|
||||||
"""Construct a crypto virtual block device.
|
"""Construct a crypto virtual block device.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
base_bdev_name: name of the underlying base bdev
|
base_bdev_name: name of the underlying base bdev
|
||||||
crypto_bdev_name: name for the crypto vbdev
|
name: name for the crypto vbdev
|
||||||
crypto_pmd: name of of the DPDK crypto driver to use
|
crypto_pmd: name of of the DPDK crypto driver to use
|
||||||
key: key
|
key: key
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Name of created virtual block device.
|
Name of created virtual block device.
|
||||||
"""
|
"""
|
||||||
params = {'base_bdev_name': base_bdev_name, 'crypto_bdev_name': crypto_bdev_name, 'crypto_pmd': crypto_pmd, 'key': key}
|
params = {'base_bdev_name': base_bdev_name, 'name': name, 'crypto_pmd': crypto_pmd, 'key': key}
|
||||||
|
|
||||||
return client.call('construct_crypto_bdev', params)
|
return client.call('construct_crypto_bdev', params)
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ def delete_crypto_bdev(client, name):
|
|||||||
"""Delete crypto virtual block device.
|
"""Delete crypto virtual block device.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
bdev_name: name of crypto vbdev to delete
|
name: name of crypto vbdev to delete
|
||||||
"""
|
"""
|
||||||
params = {'name': name}
|
params = {'name': name}
|
||||||
return client.call('delete_crypto_bdev', params)
|
return client.call('delete_crypto_bdev', params)
|
||||||
|
@ -12,7 +12,6 @@ def get_bdev_name_key(bdev):
|
|||||||
bdev_name_key = 'name'
|
bdev_name_key = 'name'
|
||||||
if 'method' in bdev and bdev['method'] == 'construct_split_vbdev':
|
if 'method' in bdev and bdev['method'] == 'construct_split_vbdev':
|
||||||
bdev_name_key = "base_bdev"
|
bdev_name_key = "base_bdev"
|
||||||
|
|
||||||
return bdev_name_key
|
return bdev_name_key
|
||||||
|
|
||||||
|
|
||||||
@ -27,7 +26,6 @@ def get_bdev_name(bdev):
|
|||||||
bdev_name = bdev['params']['base_bdev']
|
bdev_name = bdev['params']['base_bdev']
|
||||||
if 'method' in bdev and bdev['method'] == 'construct_error_bdev':
|
if 'method' in bdev and bdev['method'] == 'construct_error_bdev':
|
||||||
bdev_name = "EE_%s" % bdev_name
|
bdev_name = "EE_%s" % bdev_name
|
||||||
|
|
||||||
return bdev_name
|
return bdev_name
|
||||||
|
|
||||||
|
|
||||||
@ -54,7 +52,8 @@ def get_bdev_destroy_method(bdev):
|
|||||||
'construct_aio_bdev': "delete_aio_bdev",
|
'construct_aio_bdev': "delete_aio_bdev",
|
||||||
'construct_error_bdev': "delete_error_bdev",
|
'construct_error_bdev': "delete_error_bdev",
|
||||||
'construct_split_vbdev': "destruct_split_vbdev",
|
'construct_split_vbdev': "destruct_split_vbdev",
|
||||||
'construct_virtio_dev': "remove_virtio_bdev"
|
'construct_virtio_dev': "remove_virtio_bdev",
|
||||||
|
'construct_crypto_bdev': "delete_crypto_bdev"
|
||||||
}
|
}
|
||||||
destroy_method = None
|
destroy_method = None
|
||||||
if 'method' in bdev:
|
if 'method' in bdev:
|
||||||
|
4
test/json_config/common.sh
Normal file → Executable file
4
test/json_config/common.sh
Normal file → Executable file
@ -148,6 +148,10 @@ function create_bdev_subsystem_config() {
|
|||||||
$rpc_py construct_malloc_bdev 128 512 --name Malloc0
|
$rpc_py construct_malloc_bdev 128 512 --name Malloc0
|
||||||
$rpc_py construct_malloc_bdev 64 4096 --name Malloc1
|
$rpc_py construct_malloc_bdev 64 4096 --name Malloc1
|
||||||
$rpc_py construct_malloc_bdev 8 1024 --name Malloc2
|
$rpc_py construct_malloc_bdev 8 1024 --name Malloc2
|
||||||
|
if [ $SPDK_TEST_CRYPTO -eq 1 ]; then
|
||||||
|
$rpc_py construct_malloc_bdev 8 1024 --name Malloc3
|
||||||
|
$rpc_py construct_crypto_bdev -b Malloc3 -c CryMalloc3 -d crypto_aesni_mb -k 0123456789123456
|
||||||
|
fi
|
||||||
$rpc_py construct_error_bdev Malloc2
|
$rpc_py construct_error_bdev Malloc2
|
||||||
if [ $(uname -s) = Linux ]; then
|
if [ $(uname -s) = Linux ]; then
|
||||||
dd if=/dev/zero of=/tmp/sample_aio bs=2048 count=5000
|
dd if=/dev/zero of=/tmp/sample_aio bs=2048 count=5000
|
||||||
|
Loading…
Reference in New Issue
Block a user