event/vmd: write_config_json support
This patch adds support for saving VMD subsystem's configuration to a JSON formatted file. It allows saving and then loading configuration with VMD enabled without having to send the `enable_vmd` RPC. Change-Id: I59b380ec1e1f25f60f45d2363724ed7ac78c365c Signed-off-by: Konrad Sztyber <konrad.sztyber@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/473405 Community-CI: Broadcom SPDK FC-NVMe CI <spdk-ci.pdl@broadcom.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
6f3ca0804e
commit
933bf632d6
@ -42,6 +42,7 @@
|
|||||||
#include "event_vmd.h"
|
#include "event_vmd.h"
|
||||||
|
|
||||||
static struct spdk_poller *g_hotplug_poller;
|
static struct spdk_poller *g_hotplug_poller;
|
||||||
|
static bool g_enabled;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
vmd_hotplug_monitor(void *ctx)
|
vmd_hotplug_monitor(void *ctx)
|
||||||
@ -54,8 +55,7 @@ vmd_subsystem_init(void)
|
|||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
/* If the poller is registered, the initialization already took place */
|
if (g_enabled) {
|
||||||
if (g_hotplug_poller != NULL) {
|
|
||||||
SPDK_ERRLOG("The initialization has already been performed\n");
|
SPDK_ERRLOG("The initialization has already been performed\n");
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
@ -66,12 +66,16 @@ vmd_subsystem_init(void)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert(g_hotplug_poller == NULL);
|
||||||
|
|
||||||
g_hotplug_poller = spdk_poller_register(vmd_hotplug_monitor, NULL, 1000000ULL);
|
g_hotplug_poller = spdk_poller_register(vmd_hotplug_monitor, NULL, 1000000ULL);
|
||||||
if (g_hotplug_poller == NULL) {
|
if (g_hotplug_poller == NULL) {
|
||||||
SPDK_ERRLOG("Failed to register hotplug monitor poller\n");
|
SPDK_ERRLOG("Failed to register hotplug monitor poller\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_enabled = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,12 +103,28 @@ spdk_vmd_subsystem_fini(void)
|
|||||||
spdk_subsystem_fini_next();
|
spdk_subsystem_fini_next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
spdk_vmd_write_config_json(struct spdk_json_write_ctx *w)
|
||||||
|
{
|
||||||
|
spdk_json_write_array_begin(w);
|
||||||
|
|
||||||
|
if (g_enabled) {
|
||||||
|
spdk_json_write_object_begin(w);
|
||||||
|
spdk_json_write_named_string(w, "method", "enable_vmd");
|
||||||
|
spdk_json_write_named_object_begin(w, "params");
|
||||||
|
spdk_json_write_object_end(w);
|
||||||
|
spdk_json_write_object_end(w);
|
||||||
|
}
|
||||||
|
|
||||||
|
spdk_json_write_array_end(w);
|
||||||
|
}
|
||||||
|
|
||||||
static struct spdk_subsystem g_spdk_subsystem_vmd = {
|
static struct spdk_subsystem g_spdk_subsystem_vmd = {
|
||||||
.name = "vmd",
|
.name = "vmd",
|
||||||
.init = spdk_vmd_subsystem_init,
|
.init = spdk_vmd_subsystem_init,
|
||||||
.fini = spdk_vmd_subsystem_fini,
|
.fini = spdk_vmd_subsystem_fini,
|
||||||
.config = NULL,
|
.config = NULL,
|
||||||
.write_config_json = NULL,
|
.write_config_json = spdk_vmd_write_config_json,
|
||||||
};
|
};
|
||||||
|
|
||||||
SPDK_SUBSYSTEM_REGISTER(g_spdk_subsystem_vmd);
|
SPDK_SUBSYSTEM_REGISTER(g_spdk_subsystem_vmd);
|
||||||
|
@ -153,6 +153,10 @@ def clear_vhost_subsystem(args, vhost_config):
|
|||||||
args.client.call("vhost_delete_controller", {'ctrlr': vhost['params']['ctrlr']})
|
args.client.call("vhost_delete_controller", {'ctrlr': vhost['params']['ctrlr']})
|
||||||
|
|
||||||
|
|
||||||
|
def clear_vmd_subsystem(args, vmd_config):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def call_test_cmd(func):
|
def call_test_cmd(func):
|
||||||
def rpc_test_cmd(*args, **kwargs):
|
def rpc_test_cmd(*args, **kwargs):
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user