subsystem: add per module configuration dump
Change-Id: I5c4e51cd9cd97b05ab9a95cbe084ff2741f6ef58 Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com> Reviewed-on: https://review.gerrithub.io/402323 Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
15ce326251
commit
bd4ecea505
@ -37,6 +37,7 @@
|
|||||||
#include "spdk/stdinc.h"
|
#include "spdk/stdinc.h"
|
||||||
|
|
||||||
#include "spdk/event.h"
|
#include "spdk/event.h"
|
||||||
|
#include "spdk/json.h"
|
||||||
|
|
||||||
struct spdk_event {
|
struct spdk_event {
|
||||||
uint32_t lcore;
|
uint32_t lcore;
|
||||||
@ -57,12 +58,15 @@ struct spdk_subsystem {
|
|||||||
void (*init)(void);
|
void (*init)(void);
|
||||||
void (*fini)(void);
|
void (*fini)(void);
|
||||||
void (*config)(FILE *fp);
|
void (*config)(FILE *fp);
|
||||||
|
int (*write_config_json)(struct spdk_json_write_ctx *w);
|
||||||
TAILQ_ENTRY(spdk_subsystem) tailq;
|
TAILQ_ENTRY(spdk_subsystem) tailq;
|
||||||
};
|
};
|
||||||
|
|
||||||
TAILQ_HEAD(spdk_subsystem_list, spdk_subsystem);
|
TAILQ_HEAD(spdk_subsystem_list, spdk_subsystem);
|
||||||
extern struct spdk_subsystem_list g_subsystems;
|
extern struct spdk_subsystem_list g_subsystems;
|
||||||
|
|
||||||
|
struct spdk_subsystem *spdk_subsystem_find(struct spdk_subsystem_list *list, const char *name);
|
||||||
|
|
||||||
struct spdk_subsystem_depend {
|
struct spdk_subsystem_depend {
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *depends_on;
|
const char *depends_on;
|
||||||
@ -81,6 +85,15 @@ void spdk_subsystem_init_next(int rc);
|
|||||||
void spdk_subsystem_fini_next(void);
|
void spdk_subsystem_fini_next(void);
|
||||||
void spdk_subsystem_config(FILE *fp);
|
void spdk_subsystem_config(FILE *fp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save pointed subsystem configuration to the JSON write context. In case of
|
||||||
|
* error \c null is written to the JSON context.
|
||||||
|
*
|
||||||
|
* \param w JSON write context
|
||||||
|
* \param subsystem the subsystem to query
|
||||||
|
*/
|
||||||
|
void spdk_subsystem_config_json(struct spdk_json_write_ctx *w, struct spdk_subsystem *subsystem);
|
||||||
|
|
||||||
void spdk_rpc_initialize(const char *listen_addr);
|
void spdk_rpc_initialize(const char *listen_addr);
|
||||||
void spdk_rpc_finish(void);
|
void spdk_rpc_finish(void);
|
||||||
|
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
#include "spdk_internal/event.h"
|
#include "spdk_internal/event.h"
|
||||||
#include "spdk/rpc.h"
|
#include "spdk/rpc.h"
|
||||||
|
#include "spdk/string.h"
|
||||||
|
#include "spdk/util.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spdk_rpc_get_subsystems(struct spdk_jsonrpc_request *request,
|
spdk_rpc_get_subsystems(struct spdk_jsonrpc_request *request,
|
||||||
@ -73,3 +75,44 @@ spdk_rpc_get_subsystems(struct spdk_jsonrpc_request *request,
|
|||||||
}
|
}
|
||||||
|
|
||||||
SPDK_RPC_REGISTER("get_subsystems", spdk_rpc_get_subsystems)
|
SPDK_RPC_REGISTER("get_subsystems", spdk_rpc_get_subsystems)
|
||||||
|
|
||||||
|
struct rpc_get_subsystem_config {
|
||||||
|
char *name;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct spdk_json_object_decoder rpc_get_subsystem_config[] = {
|
||||||
|
{"name", offsetof(struct rpc_get_subsystem_config, name), spdk_json_decode_string},
|
||||||
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
spdk_rpc_get_subsystem_config(struct spdk_jsonrpc_request *request,
|
||||||
|
const struct spdk_json_val *params)
|
||||||
|
{
|
||||||
|
struct rpc_get_subsystem_config req = {};
|
||||||
|
struct spdk_json_write_ctx *w;
|
||||||
|
struct spdk_subsystem *subsystem;
|
||||||
|
|
||||||
|
if (spdk_json_decode_object(params, rpc_get_subsystem_config,
|
||||||
|
SPDK_COUNTOF(rpc_get_subsystem_config), &req)) {
|
||||||
|
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid arguments");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
subsystem = spdk_subsystem_find(&g_subsystems, req.name);
|
||||||
|
if (!subsystem) {
|
||||||
|
spdk_jsonrpc_send_error_response_fmt(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
|
||||||
|
"Subsystem '%s' not found", req.name);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
w = spdk_jsonrpc_begin_result(request);
|
||||||
|
if (w) {
|
||||||
|
spdk_subsystem_config_json(w, subsystem);
|
||||||
|
spdk_jsonrpc_end_result(request, w);
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
free(req.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
SPDK_RPC_REGISTER("get_subsystem_config", spdk_rpc_get_subsystem_config)
|
||||||
|
@ -58,7 +58,7 @@ spdk_add_subsystem_depend(struct spdk_subsystem_depend *depend)
|
|||||||
TAILQ_INSERT_TAIL(&g_subsystems_deps, depend, tailq);
|
TAILQ_INSERT_TAIL(&g_subsystems_deps, depend, tailq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct spdk_subsystem *
|
struct spdk_subsystem *
|
||||||
spdk_subsystem_find(struct spdk_subsystem_list *list, const char *name)
|
spdk_subsystem_find(struct spdk_subsystem_list *list, const char *name)
|
||||||
{
|
{
|
||||||
struct spdk_subsystem *iter;
|
struct spdk_subsystem *iter;
|
||||||
@ -242,3 +242,13 @@ spdk_subsystem_config(FILE *fp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
spdk_subsystem_config_json(struct spdk_json_write_ctx *w, struct spdk_subsystem *subsystem)
|
||||||
|
{
|
||||||
|
if (subsystem && subsystem->write_config_json) {
|
||||||
|
subsystem->write_config_json(w);
|
||||||
|
} else {
|
||||||
|
spdk_json_write_null(w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -437,6 +437,10 @@ if __name__ == "__main__":
|
|||||||
entry contain (unsorted) array of subsystems it depends on.""")
|
entry contain (unsorted) array of subsystems it depends on.""")
|
||||||
p.set_defaults(func=rpc.subsystem.get_subsystems)
|
p.set_defaults(func=rpc.subsystem.get_subsystems)
|
||||||
|
|
||||||
|
p = subparsers.add_parser('get_subsystem_config', help=""""Print subsystem configuration""")
|
||||||
|
p.add_argument('name', help='Name of subsystem to query')
|
||||||
|
p.set_defaults(func=rpc.subsystem.get_subsystem_config)
|
||||||
|
|
||||||
# vhost
|
# vhost
|
||||||
p = subparsers.add_parser('set_vhost_controller_coalescing', help='Set vhost controller coalescing')
|
p = subparsers.add_parser('set_vhost_controller_coalescing', help='Set vhost controller coalescing')
|
||||||
p.add_argument('ctrlr', help='controller name')
|
p.add_argument('ctrlr', help='controller name')
|
||||||
|
@ -3,3 +3,8 @@ from client import print_dict, print_array, int_arg
|
|||||||
|
|
||||||
def get_subsystems(args):
|
def get_subsystems(args):
|
||||||
print_dict(args.client.call('get_subsystems'))
|
print_dict(args.client.call('get_subsystems'))
|
||||||
|
|
||||||
|
|
||||||
|
def get_subsystem_config(args):
|
||||||
|
params = {'name': args.name}
|
||||||
|
print_dict(args.client.call('get_subsystem_config', params))
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#include "spdk_cunit.h"
|
#include "spdk_cunit.h"
|
||||||
|
|
||||||
|
#include "unit/lib/json_mock.c"
|
||||||
#include "event/subsystem.c"
|
#include "event/subsystem.c"
|
||||||
|
|
||||||
static struct spdk_subsystem g_ut_subsystems[8];
|
static struct spdk_subsystem g_ut_subsystems[8];
|
||||||
|
81
test/unit/lib/json_mock.c
Normal file
81
test/unit/lib/json_mock.c
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
/*-
|
||||||
|
* BSD LICENSE
|
||||||
|
*
|
||||||
|
* Copyright (c) Intel Corporation.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* * Neither the name of Intel Corporation nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "spdk/json.h"
|
||||||
|
#include "spdk_internal/mock.h"
|
||||||
|
|
||||||
|
DEFINE_STUB(spdk_json_write_begin, struct spdk_json_write_ctx *, (spdk_json_write_cb write_cb,
|
||||||
|
void *cb_ctx, uint32_t flags), NULL);
|
||||||
|
|
||||||
|
DEFINE_STUB(spdk_json_write_end, int, (struct spdk_json_write_ctx *w), 0);
|
||||||
|
DEFINE_STUB(spdk_json_write_null, int, (struct spdk_json_write_ctx *w), 0);
|
||||||
|
DEFINE_STUB(spdk_json_write_bool, int, (struct spdk_json_write_ctx *w, bool val), 0);
|
||||||
|
DEFINE_STUB(spdk_json_write_int32, int, (struct spdk_json_write_ctx *w, int32_t val), 0);
|
||||||
|
DEFINE_STUB(spdk_json_write_uint32, int, (struct spdk_json_write_ctx *w, uint32_t val), 0);
|
||||||
|
DEFINE_STUB(spdk_json_write_int64, int, (struct spdk_json_write_ctx *w, int64_t val), 0);
|
||||||
|
DEFINE_STUB(spdk_json_write_uint64, int, (struct spdk_json_write_ctx *w, uint64_t val), 0);
|
||||||
|
DEFINE_STUB(spdk_json_write_string, int, (struct spdk_json_write_ctx *w, const char *val), 0);
|
||||||
|
DEFINE_STUB(spdk_json_write_string_raw, int, (struct spdk_json_write_ctx *w, const char *val,
|
||||||
|
size_t len), 0);
|
||||||
|
|
||||||
|
DEFINE_STUB(spdk_json_write_array_begin, int, (struct spdk_json_write_ctx *w), 0);
|
||||||
|
DEFINE_STUB(spdk_json_write_array_end, int, (struct spdk_json_write_ctx *w), 0);
|
||||||
|
DEFINE_STUB(spdk_json_write_object_begin, int, (struct spdk_json_write_ctx *w), 0);
|
||||||
|
DEFINE_STUB(spdk_json_write_object_end, int, (struct spdk_json_write_ctx *w), 0);
|
||||||
|
DEFINE_STUB(spdk_json_write_name, int, (struct spdk_json_write_ctx *w, const char *name), 0);
|
||||||
|
DEFINE_STUB(spdk_json_write_name_raw, int, (struct spdk_json_write_ctx *w, const char *name,
|
||||||
|
size_t len), 0);
|
||||||
|
|
||||||
|
/* Utility functions */
|
||||||
|
DEFINE_STUB(spdk_json_write_named_null, int, (struct spdk_json_write_ctx *w, const char *name), 0);
|
||||||
|
DEFINE_STUB(spdk_json_write_named_bool, int, (struct spdk_json_write_ctx *w, const char *name,
|
||||||
|
bool val), 0);
|
||||||
|
DEFINE_STUB(spdk_json_write_named_int32, int, (struct spdk_json_write_ctx *w, const char *name,
|
||||||
|
int32_t val), 0);
|
||||||
|
DEFINE_STUB(spdk_json_write_named_uint32, int, (struct spdk_json_write_ctx *w, const char *name,
|
||||||
|
uint32_t val), 0);
|
||||||
|
DEFINE_STUB(spdk_json_write_named_uint64, int, (struct spdk_json_write_ctx *w, const char *name,
|
||||||
|
uint64_t val), 0);
|
||||||
|
DEFINE_STUB(spdk_json_write_named_int64, int, (struct spdk_json_write_ctx *w, const char *name,
|
||||||
|
int64_t val), 0);
|
||||||
|
DEFINE_STUB(spdk_json_write_named_string, int, (struct spdk_json_write_ctx *w, const char *name,
|
||||||
|
const char *val), 0);
|
||||||
|
DEFINE_STUB(spdk_json_write_named_string_fmt, int, (struct spdk_json_write_ctx *w, const char *name,
|
||||||
|
const char *fmt, ...), 0);
|
||||||
|
DEFINE_STUB(spdk_json_write_named_string_fmt_v, int, (struct spdk_json_write_ctx *w,
|
||||||
|
const char *name, const char *fmt, va_list args), 0);
|
||||||
|
|
||||||
|
DEFINE_STUB(spdk_json_write_named_array_begin, int, (struct spdk_json_write_ctx *w,
|
||||||
|
const char *name), 0);
|
||||||
|
DEFINE_STUB(spdk_json_write_named_object_begin, int, (struct spdk_json_write_ctx *w,
|
||||||
|
const char *name), 0);
|
Loading…
Reference in New Issue
Block a user