nbd: add JSON config dump
Change-Id: Ib3c97c6d9152a3f61a56d640c875151bdab40278 Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com> Reviewed-on: https://review.gerrithub.io/408320 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
a77cd3f75c
commit
5b424282c1
@ -44,6 +44,8 @@ extern "C" {
|
||||
|
||||
struct spdk_bdev;
|
||||
struct spdk_nbd_disk;
|
||||
struct spdk_json_write_ctx;
|
||||
struct spdk_event;
|
||||
|
||||
/**
|
||||
* Initialize the network block device layer.
|
||||
@ -75,6 +77,14 @@ struct spdk_nbd_disk *spdk_nbd_start(const char *bdev_name, const char *nbd_path
|
||||
*/
|
||||
void spdk_nbd_stop(struct spdk_nbd_disk *nbd);
|
||||
|
||||
/**
|
||||
* Write NBD subsystem configuration into provided JSON context.
|
||||
*
|
||||
* \param w JSON write context
|
||||
* \param done_ev call this event when done.
|
||||
*/
|
||||
void spdk_nbd_write_config_json(struct spdk_json_write_ctx *w, struct spdk_event *done_ev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -59,6 +59,7 @@ static struct spdk_subsystem g_spdk_subsystem_nbd = {
|
||||
.init = spdk_nbd_subsystem_init,
|
||||
.fini = spdk_nbd_subsystem_fini,
|
||||
.config = NULL,
|
||||
.write_config_json = spdk_nbd_write_config_json,
|
||||
};
|
||||
|
||||
SPDK_SUBSYSTEM_REGISTER(g_spdk_subsystem_nbd);
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include "spdk/log.h"
|
||||
#include "spdk/util.h"
|
||||
#include "spdk/io_channel.h"
|
||||
#include "spdk/event.h"
|
||||
|
||||
#include "spdk_internal/log.h"
|
||||
#include "spdk/queue.h"
|
||||
@ -211,6 +212,27 @@ spdk_nbd_disk_get_bdev_name(struct spdk_nbd_disk *nbd)
|
||||
return spdk_bdev_get_name(nbd->bdev);
|
||||
}
|
||||
|
||||
void
|
||||
spdk_nbd_write_config_json(struct spdk_json_write_ctx *w, struct spdk_event *done_ev)
|
||||
{
|
||||
struct spdk_nbd_disk *nbd;
|
||||
|
||||
TAILQ_FOREACH(nbd, &g_spdk_nbd.disk_head, tailq) {
|
||||
spdk_json_write_object_begin(w);
|
||||
|
||||
spdk_json_write_named_string(w, "method", "start_nbd_disk");
|
||||
|
||||
spdk_json_write_named_object_begin(w, "params");
|
||||
spdk_json_write_named_string(w, "nbd_device", spdk_nbd_disk_get_nbd_path(nbd));
|
||||
spdk_json_write_named_string(w, "bdev_name", spdk_nbd_disk_get_bdev_name(nbd));
|
||||
spdk_json_write_object_end(w);
|
||||
|
||||
spdk_json_write_object_end(w);
|
||||
}
|
||||
|
||||
spdk_event_call(done_ev);
|
||||
}
|
||||
|
||||
void
|
||||
nbd_disconnect(struct spdk_nbd_disk *nbd)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user