From 5f6f7eddcce5f4134e271387110a58441b285606 Mon Sep 17 00:00:00 2001 From: Pawel Kaminski Date: Thu, 3 Oct 2019 21:56:32 +0000 Subject: [PATCH] rpc: Rename add_vhost_nvme_ns to vhost_nvme_controller_add_ns Signed-off-by: Pawel Kaminski Change-Id: I769271d0f8043ce4bdaf9a1c4799537e99e3876b Signed-off-by: Pawel Kaminski Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/470399 Reviewed-by: Tomasz Zawadzki Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto Tested-by: SPDK CI Jenkins --- doc/jsonrpc.md | 4 ++-- doc/vhost.md | 2 +- lib/vhost/vhost_nvme.c | 2 +- lib/vhost/vhost_rpc.c | 22 ++++++++++++---------- scripts/config_converter.py | 2 +- scripts/rpc.py | 13 +++++++------ scripts/rpc/vhost.py | 5 +++-- test/config_converter/spdk_config.json | 4 ++-- test/json_config/json_config.sh | 2 +- 9 files changed, 30 insertions(+), 26 deletions(-) diff --git a/doc/jsonrpc.md b/doc/jsonrpc.md index 637da21e7f..e2b946779e 100644 --- a/doc/jsonrpc.md +++ b/doc/jsonrpc.md @@ -4542,7 +4542,7 @@ Example response: } ~~~ -## add_vhost_nvme_ns {#rpc_add_vhost_nvme_ns} +## vhost_nvme_controller_add_ns {#rpc_vhost_nvme_controller_add_ns} Add namespace backed by `bdev_name` @@ -4565,7 +4565,7 @@ Example request: "ctrlr": "VhostNvme0" }, "jsonrpc": "2.0", - "method": "add_vhost_nvme_ns", + "method": "vhost_nvme_controller_add_ns", "id": 1 } ~~~ diff --git a/doc/vhost.md b/doc/vhost.md index e7c988399c..9a4ae0af68 100644 --- a/doc/vhost.md +++ b/doc/vhost.md @@ -181,7 +181,7 @@ controller, at least 1 Namespace is required for each controller. ~~~{.sh} $rpc_py vhost_create_nvme_controller --cpumask 0x1 vhost.2 16 -$rpc_py add_vhost_nvme_ns vhost.2 Malloc0 +$rpc_py vhost_nvme_controller_add_ns vhost.2 Malloc0 ~~~ Users can use the following command to remove the controller, all the block diff --git a/lib/vhost/vhost_nvme.c b/lib/vhost/vhost_nvme.c index ae97468218..8a6c2642ee 100644 --- a/lib/vhost/vhost_nvme.c +++ b/lib/vhost/vhost_nvme.c @@ -1269,7 +1269,7 @@ spdk_vhost_nvme_write_config_json(struct spdk_vhost_dev *vdev, struct spdk_json_ } spdk_json_write_object_begin(w); - spdk_json_write_named_string(w, "method", "add_vhost_nvme_ns"); + spdk_json_write_named_string(w, "method", "vhost_nvme_controller_add_ns"); spdk_json_write_named_object_begin(w, "params"); spdk_json_write_named_string(w, "ctrlr", nvme->vdev.name); diff --git a/lib/vhost/vhost_rpc.c b/lib/vhost/vhost_rpc.c index 555ebe92e9..b7c7a1738a 100644 --- a/lib/vhost/vhost_rpc.c +++ b/lib/vhost/vhost_rpc.c @@ -578,28 +578,28 @@ SPDK_RPC_REGISTER("vhost_create_nvme_controller", spdk_rpc_vhost_create_nvme_con SPDK_RPC_RUNTIME) SPDK_RPC_REGISTER_ALIAS_DEPRECATED(vhost_create_nvme_controller, construct_vhost_nvme_controller) -struct rpc_add_vhost_nvme_ctrlr_ns { +struct rpc_vhost_nvme_ctrlr_add_ns { char *ctrlr; char *bdev_name; }; static void -free_rpc_add_vhost_nvme_ctrlr_ns(struct rpc_add_vhost_nvme_ctrlr_ns *req) +free_rpc_vhost_nvme_ctrlr_add_ns(struct rpc_vhost_nvme_ctrlr_add_ns *req) { free(req->ctrlr); free(req->bdev_name); } static const struct spdk_json_object_decoder rpc_vhost_nvme_add_ns[] = { - {"ctrlr", offsetof(struct rpc_add_vhost_nvme_ctrlr_ns, ctrlr), spdk_json_decode_string }, - {"bdev_name", offsetof(struct rpc_add_vhost_nvme_ctrlr_ns, bdev_name), spdk_json_decode_string }, + {"ctrlr", offsetof(struct rpc_vhost_nvme_ctrlr_add_ns, ctrlr), spdk_json_decode_string }, + {"bdev_name", offsetof(struct rpc_vhost_nvme_ctrlr_add_ns, bdev_name), spdk_json_decode_string }, }; static void -spdk_rpc_add_vhost_nvme_ns(struct spdk_jsonrpc_request *request, - const struct spdk_json_val *params) +spdk_rpc_vhost_nvme_controller_add_ns(struct spdk_jsonrpc_request *request, + const struct spdk_json_val *params) { - struct rpc_add_vhost_nvme_ctrlr_ns req = {0}; + struct rpc_vhost_nvme_ctrlr_add_ns req = {0}; struct spdk_json_write_ctx *w; struct spdk_vhost_dev *vdev; int rc; @@ -625,7 +625,7 @@ spdk_rpc_add_vhost_nvme_ns(struct spdk_jsonrpc_request *request, if (rc < 0) { goto invalid; } - free_rpc_add_vhost_nvme_ctrlr_ns(&req); + free_rpc_vhost_nvme_ctrlr_add_ns(&req); w = spdk_jsonrpc_begin_result(request); spdk_json_write_bool(w, true); @@ -633,11 +633,13 @@ spdk_rpc_add_vhost_nvme_ns(struct spdk_jsonrpc_request *request, return; invalid: - free_rpc_add_vhost_nvme_ctrlr_ns(&req); + free_rpc_vhost_nvme_ctrlradd__ns(&req); spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, spdk_strerror(-rc)); } -SPDK_RPC_REGISTER("add_vhost_nvme_ns", spdk_rpc_add_vhost_nvme_ns, SPDK_RPC_RUNTIME) +SPDK_RPC_REGISTER("vhost_nvme_controller_add_ns", spdk_rpc_vhost_nvme_controller_add_ns, + SPDK_RPC_RUNTIME) +SPDK_RPC_REGISTER_ALIAS_DEPRECATED(vhost_nvme_controller_add_ns, add_vhost_nvme_ns) #endif /* SPDK_CONFIG_VHOST_INTERNAL_LIB */ diff --git a/scripts/config_converter.py b/scripts/config_converter.py index eeaa3cafee..a8e97b0f57 100755 --- a/scripts/config_converter.py +++ b/scripts/config_converter.py @@ -460,7 +460,7 @@ def get_vhost_nvme_json(config, section): "ctrlr": params[0][3], "bdev_name": namespace, }, - "method": "add_vhost_nvme_ns" + "method": "vhost_nvme_controller_add_ns" }) return vhost_nvme_json diff --git a/scripts/rpc.py b/scripts/rpc.py index 3c9f1305c1..533bb6ff5d 100755 --- a/scripts/rpc.py +++ b/scripts/rpc.py @@ -1927,15 +1927,16 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse p.add_argument('--cpumask', help='cpu mask for this controller') p.set_defaults(func=vhost_create_nvme_controller) - def add_vhost_nvme_ns(args): - rpc.vhost.add_vhost_nvme_ns(args.client, - ctrlr=args.ctrlr, - bdev_name=args.bdev_name) + def vhost_nvme_controller_add_ns(args): + rpc.vhost.vhost_nvme_controller_add_ns(args.client, + ctrlr=args.ctrlr, + bdev_name=args.bdev_name) - p = subparsers.add_parser('add_vhost_nvme_ns', help='Add a Namespace to vhost controller') + p = subparsers.add_parser('vhost_nvme_controller_add_ns', aliases=['add_vhost_nvme_ns'], + help='Add a Namespace to vhost controller') p.add_argument('ctrlr', help='conntroller name where add a Namespace') p.add_argument('bdev_name', help='block device name for a new Namespace') - p.set_defaults(func=add_vhost_nvme_ns) + p.set_defaults(func=vhost_nvme_controller_add_ns) def get_vhost_controllers(args): print_dict(rpc.vhost.get_vhost_controllers(args.client, args.name)) diff --git a/scripts/rpc/vhost.py b/scripts/rpc/vhost.py index 3bd8d4e24b..c8fe482e03 100644 --- a/scripts/rpc/vhost.py +++ b/scripts/rpc/vhost.py @@ -81,7 +81,8 @@ def vhost_create_nvme_controller(client, ctrlr, io_queues, cpumask=None): return client.call('vhost_create_nvme_controller', params) -def add_vhost_nvme_ns(client, ctrlr, bdev_name): +@deprecated_alias('add_vhost_nvme_ns') +def vhost_nvme_controller_add_ns(client, ctrlr, bdev_name): """Add namespace to vhost nvme controller. Args: ctrlr: controller name where to add a namespace @@ -92,7 +93,7 @@ def add_vhost_nvme_ns(client, ctrlr, bdev_name): 'bdev_name': bdev_name, } - return client.call('add_vhost_nvme_ns', params) + return client.call('vhost_nvme_controller_add_ns', params) def construct_vhost_blk_controller(client, ctrlr, dev_name, cpumask=None, readonly=None): diff --git a/test/config_converter/spdk_config.json b/test/config_converter/spdk_config.json index 34a3f270c5..223c368257 100644 --- a/test/config_converter/spdk_config.json +++ b/test/config_converter/spdk_config.json @@ -390,14 +390,14 @@ "bdev_name": "Nvme0n1p0", "ctrlr": "naa.vhost.3" }, - "method": "add_vhost_nvme_ns" + "method": "vhost_nvme_controller_add_ns" }, { "params": { "bdev_name": "Nvme0n1p1", "ctrlr": "naa.vhost.3" }, - "method": "add_vhost_nvme_ns" + "method": "vhost_nvme_controller_add_ns" } ] }, diff --git a/test/json_config/json_config.sh b/test/json_config/json_config.sh index 20d55e13ec..ea5e2eb34c 100755 --- a/test/json_config/json_config.sh +++ b/test/json_config/json_config.sh @@ -290,7 +290,7 @@ function create_vhost_subsystem_config() { # FIXME: enable after vhost-nvme is properly implemented against the latest rte_vhost (DPDK 19.05+) # tgt_rpc vhost_create_nvme_controller VhostNvmeCtrlr0 16 -# tgt_rpc add_vhost_nvme_ns VhostNvmeCtrlr0 MallocForVhost0p6 +# tgt_rpc vhost_nvme_controller_add_ns VhostNvmeCtrlr0 MallocForVhost0p6 timing_exit $FUNCNAME }