virtio_blk: add dump opts

Currently we do not have a way to dump opts
for virtio_blk transports. This patch introduces
necessary changes to let us save and load those
via JOSN config.

Change-Id: I7ee4f31062f3d4a264f322e66a67ba3d075f1d75
Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15248
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Krzysztof Karas 2022-11-03 11:33:25 +00:00 committed by Tomasz Zawadzki
parent b9f7ba0d09
commit 87c59b28a3
4 changed files with 35 additions and 1 deletions

View File

@ -380,6 +380,26 @@ spdk_vhost_scsi_config_json(struct spdk_json_write_ctx *w)
spdk_json_write_array_end(w);
}
static void
vhost_blk_dump_config_json(struct spdk_json_write_ctx *w)
{
struct spdk_virtio_blk_transport *transport;
/* Write vhost transports */
TAILQ_FOREACH(transport, &g_virtio_blk_transports, tailq) {
/* Since vhost_user_blk is always added on SPDK startup,
* do not emit virtio_blk_create_transport RPC. */
if (strcasecmp(transport->ops->name, "vhost_user_blk") != 0) {
spdk_json_write_object_begin(w);
spdk_json_write_named_string(w, "method", "virtio_blk_create_transport");
spdk_json_write_named_object_begin(w, "params");
transport->ops->dump_opts(transport, w);
spdk_json_write_object_end(w);
spdk_json_write_object_end(w);
}
}
}
void
spdk_vhost_blk_config_json(struct spdk_json_write_ctx *w)
{
@ -396,6 +416,8 @@ spdk_vhost_blk_config_json(struct spdk_json_write_ctx *w)
}
spdk_vhost_unlock();
vhost_blk_dump_config_json(w);
spdk_json_write_array_end(w);
}

View File

@ -13,6 +13,7 @@
#include "spdk/string.h"
#include "spdk/util.h"
#include "spdk/vhost.h"
#include "spdk/json.h"
#include "vhost_internal.h"
#include <rte_version.h>
@ -1785,10 +1786,18 @@ vhost_user_blk_destroy_ctrlr(struct spdk_vhost_dev *vdev)
return vhost_user_dev_unregister(vdev);
}
static void
vhost_user_blk_dump_opts(struct spdk_virtio_blk_transport *transport, struct spdk_json_write_ctx *w)
{
assert(w != NULL);
spdk_json_write_named_string(w, "name", transport->ops->name);
}
static const struct spdk_virtio_blk_transport_ops vhost_user_blk = {
.name = "vhost_user_blk",
.dump_opts = NULL,
.dump_opts = vhost_user_blk_dump_opts,
.create = vhost_user_blk_create,
.destroy = vhost_user_blk_destroy,

View File

@ -45,6 +45,7 @@ def filter_methods(do_remove_global_rpcs):
'accel_assign_opc',
'dpdk_cryptodev_scan_accel_module',
'dpdk_cryptodev_set_driver',
'virtio_blk_create_transport',
]
data = json.loads(sys.stdin.read())

View File

@ -60,3 +60,5 @@ DEFINE_STUB(spdk_json_write_named_array_begin, int, (struct spdk_json_write_ctx
const char *name), 0);
DEFINE_STUB(spdk_json_write_named_object_begin, int, (struct spdk_json_write_ctx *w,
const char *name), 0);
DEFINE_STUB(spdk_json_number_to_uint64, int, (const struct spdk_json_val *val, uint64_t *num), 0);