From de0e2297b2f05ebc01c8682aabe5f3daf85c14d2 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Wed, 23 Sep 2020 20:53:21 +0000 Subject: [PATCH] log_rpc: move log_enable_timestamps definition This RPC was originally put into the app_rpc library, but the log_rpc library is a better home for it, since other log-related RPCs are already there. Signed-off-by: Jim Harris Change-Id: I7ba5ac6cdeb57fb4219244690590c8fabbc3f59a Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4361 Tested-by: SPDK CI Jenkins Reviewed-by: Aleksey Marchuk Reviewed-by: Changpeng Liu Reviewed-by: Ben Walker --- lib/log_rpc/log_rpc.c | 31 +++++++++++++++++++++++++++++++ module/event/rpc/app_rpc.c | 32 -------------------------------- 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/lib/log_rpc/log_rpc.c b/lib/log_rpc/log_rpc.c index 78b74c1f5..6d0d85900 100644 --- a/lib/log_rpc/log_rpc.c +++ b/lib/log_rpc/log_rpc.c @@ -337,4 +337,35 @@ rpc_log_get_flags(struct spdk_jsonrpc_request *request, SPDK_RPC_REGISTER("log_get_flags", rpc_log_get_flags, SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME) SPDK_RPC_REGISTER_ALIAS_DEPRECATED(log_get_flags, get_log_flags) +struct rpc_log_enable_timestamps { + bool enabled; +}; + +static const struct spdk_json_object_decoder rpc_log_enable_timestamps_decoders[] = { + {"enabled", offsetof(struct rpc_log_enable_timestamps, enabled), spdk_json_decode_bool}, +}; + +static void +rpc_log_enable_timestamps(struct spdk_jsonrpc_request *request, + const struct spdk_json_val *params) +{ + struct rpc_log_enable_timestamps req = {}; + struct spdk_json_write_ctx *w; + + if (spdk_json_decode_object(params, rpc_log_enable_timestamps_decoders, + SPDK_COUNTOF(rpc_log_enable_timestamps_decoders), + &req)) { + SPDK_ERRLOG("spdk_json_decode_object failed\n"); + spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, + "spdk_json_decode_object failed"); + return; + } + + spdk_log_enable_timestamps(req.enabled); + + w = spdk_jsonrpc_begin_result(request); + spdk_json_write_bool(w, true); + spdk_jsonrpc_end_result(request, w); +} +SPDK_RPC_REGISTER("log_enable_timestamps", rpc_log_enable_timestamps, SPDK_RPC_RUNTIME) SPDK_LOG_REGISTER_COMPONENT("log_rpc", SPDK_LOG_LOG_RPC) diff --git a/module/event/rpc/app_rpc.c b/module/event/rpc/app_rpc.c index ad6264d85..f223c1734 100644 --- a/module/event/rpc/app_rpc.c +++ b/module/event/rpc/app_rpc.c @@ -540,36 +540,4 @@ err: free(ctx); } SPDK_RPC_REGISTER("thread_set_cpumask", rpc_thread_set_cpumask, SPDK_RPC_RUNTIME) - -struct rpc_log_enable_timestamps { - bool enabled; -}; - -static const struct spdk_json_object_decoder rpc_log_enable_timestamps_decoders[] = { - {"enabled", offsetof(struct rpc_log_enable_timestamps, enabled), spdk_json_decode_bool}, -}; - -static void -rpc_log_enable_timestamps(struct spdk_jsonrpc_request *request, - const struct spdk_json_val *params) -{ - struct rpc_log_enable_timestamps req = {}; - struct spdk_json_write_ctx *w; - - if (spdk_json_decode_object(params, rpc_log_enable_timestamps_decoders, - SPDK_COUNTOF(rpc_log_enable_timestamps_decoders), - &req)) { - SPDK_ERRLOG("spdk_json_decode_object failed\n"); - spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, - "spdk_json_decode_object failed"); - return; - } - - spdk_log_enable_timestamps(req.enabled); - - w = spdk_jsonrpc_begin_result(request); - spdk_json_write_bool(w, true); - spdk_jsonrpc_end_result(request, w); -} -SPDK_RPC_REGISTER("log_enable_timestamps", rpc_log_enable_timestamps, SPDK_RPC_RUNTIME) SPDK_LOG_REGISTER_COMPONENT("APP_RPC", SPDK_LOG_APP_RPC)