From 856a96a7a9d8bb5b71f86d4f2b053742ae172db9 Mon Sep 17 00:00:00 2001 From: Pawel Wodkowski Date: Fri, 23 Feb 2018 19:18:42 +0100 Subject: [PATCH] bdev/malloc: add JSON config dump Change-Id: I309cc48d95a7a47fbdddc1980662937fb295cf9a Signed-off-by: Pawel Wodkowski Reviewed-on: https://review.gerrithub.io/401219 Reviewed-by: Shuhei Matsumoto Reviewed-by: Daniel Verkamp Reviewed-by: Jim Harris Tested-by: SPDK Automated Test System --- lib/bdev/malloc/bdev_malloc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/bdev/malloc/bdev_malloc.c b/lib/bdev/malloc/bdev_malloc.c index 561136a84..c7a1aabed 100644 --- a/lib/bdev/malloc/bdev_malloc.c +++ b/lib/bdev/malloc/bdev_malloc.c @@ -40,6 +40,7 @@ #include "spdk/endian.h" #include "spdk/env.h" #include "spdk/copy_engine.h" +#include "spdk/json.h" #include "spdk/io_channel.h" #include "spdk/queue.h" #include "spdk/string.h" @@ -346,11 +347,28 @@ bdev_malloc_get_io_channel(void *ctx) return spdk_copy_engine_get_io_channel(); } +static void +bdev_malloc_write_json_config(struct spdk_bdev *bdev, struct spdk_json_write_ctx *w) +{ + spdk_json_write_object_begin(w); + + spdk_json_write_named_string(w, "method", "construct_malloc_bdev"); + + spdk_json_write_named_object_begin(w, "params"); + spdk_json_write_named_string(w, "name", bdev->name); + spdk_json_write_named_uint64(w, "num_blocks", bdev->blockcnt); + spdk_json_write_named_uint32(w, "block_size", bdev->blocklen); + spdk_json_write_object_end(w); + + spdk_json_write_object_end(w); +} + static const struct spdk_bdev_fn_table malloc_fn_table = { .destruct = bdev_malloc_destruct, .submit_request = bdev_malloc_submit_request, .io_type_supported = bdev_malloc_io_type_supported, .get_io_channel = bdev_malloc_get_io_channel, + .write_config_json = bdev_malloc_write_json_config, }; struct spdk_bdev *create_malloc_disk(const char *name, const struct spdk_uuid *uuid,