Commit 87c59b28 authored by Krzysztof Karas's avatar Krzysztof Karas Committed by Tomasz Zawadzki
Browse files

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: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15248


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent b9f7ba0d
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -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);
}

+10 −1
Original line number Diff line number Diff line
@@ -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,
+1 −0
Original line number Diff line number Diff line
@@ -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())
+2 −0
Original line number Diff line number Diff line
@@ -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);