From 139e4c078310061c953d79d3dde96db40179233e Mon Sep 17 00:00:00 2001 From: Pawel Kaminski Date: Mon, 19 Aug 2019 08:14:37 -0400 Subject: [PATCH] lib/rpc: Add include_aliases flag to rpc_get_methods implementation. When getting the list of available RPCs from a tool like rpc.py, aliases often should be hidden. However, when getting the list of RPCs available for loading from a JSON config file, aliases should be included. Change-Id: Ie22d8b0ec2515d37dbfadf01b5cb709c160beb3e Signed-off-by: Pawel Kaminski Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/465656 Tested-by: SPDK CI Jenkins Reviewed-by: Paul Luse Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto --- lib/rpc/rpc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/rpc/rpc.c b/lib/rpc/rpc.c index 743cc2702..2f323eddc 100644 --- a/lib/rpc/rpc.c +++ b/lib/rpc/rpc.c @@ -291,6 +291,7 @@ spdk_rpc_register_alias_deprecated(const char *method, const char *alias) m->is_alias_of = base; m->is_deprecated = true; + m->state_mask = base->state_mask; /* TODO: use a hash table or sorted list */ SLIST_INSERT_HEAD(&g_rpc_methods, m, slist); @@ -342,10 +343,12 @@ spdk_rpc_close(void) struct rpc_get_methods { bool current; + bool include_aliases; }; static const struct spdk_json_object_decoder rpc_get_methods_decoders[] = { {"current", offsetof(struct rpc_get_methods, current), spdk_json_decode_bool, true}, + {"include_aliases", offsetof(struct rpc_get_methods, include_aliases), spdk_json_decode_bool, true}, }; static void @@ -368,6 +371,9 @@ spdk_rpc_get_methods(struct spdk_jsonrpc_request *request, const struct spdk_jso w = spdk_jsonrpc_begin_result(request); spdk_json_write_array_begin(w); SLIST_FOREACH(m, &g_rpc_methods, slist) { + if (m->is_alias_of != NULL && !req.include_aliases) { + continue; + } if (req.current && ((m->state_mask & g_rpc_state) != g_rpc_state)) { continue; }