Commit e0516095 authored by Tomasz Zawadzki's avatar Tomasz Zawadzki
Browse files

event/vhost: separate vhost subsystem to scsi and blk



Separate out SCSI and BLK vhost subsystems to later add
virtio_blk transport abstraction.

This allows for further changes to the vhost_blk, not
affecting vhost_scsi.

Signed-off-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Id1ecfeafeb936809a479a43c321e13f75cb3d5ad
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9539


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
parent 59af87d4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ endif
ifeq ($(OS),Linux)
SPDK_LIB_LIST += event_nbd
ifeq ($(CONFIG_VHOST),y)
SPDK_LIB_LIST += event_vhost
SPDK_LIB_LIST += event_vhost_blk event_vhost_scsi
endif
endif

+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ APP = vhost

C_SRCS := vhost.c

SPDK_LIB_LIST = $(ALL_MODULES_LIST) event event_vhost event_nbd
SPDK_LIB_LIST = $(ALL_MODULES_LIST) event event_vhost_blk event_vhost_scsi event_nbd

ifeq ($(SPDK_ROOT_DIR)/lib/env_dpdk,$(CONFIG_ENV))
SPDK_LIB_LIST += env_dpdk_rpc
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ C_SRCS := interrupt_tgt.c
SPDK_LIB_LIST = $(INTR_BLOCKDEV_MODULES_LIST) event event_bdev conf

SPDK_LIB_LIST += event_nbd
SPDK_LIB_LIST += event_vhost
SPDK_LIB_LIST += event_vhost_blk event_vhost_scsi

ifeq ($(SPDK_ROOT_DIR)/lib/env_dpdk,$(CONFIG_ENV))
SPDK_LIB_LIST += env_dpdk_rpc
+23 −3
Original line number Diff line number Diff line
@@ -75,22 +75,42 @@ int spdk_vhost_set_socket_path(const char *basename);
 *
 * \param init_cb Function to be called when the initialization is complete.
 */
void spdk_vhost_init(spdk_vhost_init_cb init_cb);
void spdk_vhost_scsi_init(spdk_vhost_init_cb init_cb);

/**
 * Clean up the environment of vhost.
 *
 * \param fini_cb Function to be called when the cleanup is complete.
 */
void spdk_vhost_fini(spdk_vhost_fini_cb fini_cb);
void spdk_vhost_scsi_fini(spdk_vhost_fini_cb fini_cb);

/**
 * Write vhost subsystem configuration into provided JSON context.
 *
 * \param w JSON write context
 */
void spdk_vhost_scsi_config_json(struct spdk_json_write_ctx *w);

/**
 * Init vhost environment.
 *
 * \param init_cb Function to be called when the initialization is complete.
 */
void spdk_vhost_blk_init(spdk_vhost_init_cb init_cb);

/**
 * Clean up the environment of vhost.
 *
 * \param fini_cb Function to be called when the cleanup is complete.
 */
void spdk_vhost_blk_fini(spdk_vhost_fini_cb fini_cb);

/**
 * Write vhost subsystem configuration into provided JSON context.
 *
 * \param w JSON write context
 */
void spdk_vhost_config_json(struct spdk_json_write_ctx *w);
void spdk_vhost_blk_config_json(struct spdk_json_write_ctx *w);

/**
 * Deinit vhost application. This is called once by SPDK app layer.
+12 −5
Original line number Diff line number Diff line
@@ -1839,12 +1839,19 @@ vhost_user_init(void)
	return 0;
}

static void
vhost_user_session_shutdown_on_init(void *vhost_cb)
{
	spdk_vhost_fini_cb fn = vhost_cb;

	fn();
}

static void *
vhost_user_session_shutdown(void *arg)
vhost_user_session_shutdown(void *vhost_cb)
{
	struct spdk_vhost_dev *vdev = NULL;
	struct spdk_vhost_session *vsession;
	vhost_fini_cb vhost_cb = arg;

	for (vdev = spdk_vhost_dev_next(NULL); vdev != NULL;
	     vdev = spdk_vhost_dev_next(vdev)) {
@@ -1860,18 +1867,18 @@ vhost_user_session_shutdown(void *arg)
	}

	SPDK_INFOLOG(vhost, "Exiting\n");
	spdk_thread_send_msg(g_vhost_user_init_thread, vhost_cb, NULL);
	spdk_thread_send_msg(g_vhost_user_init_thread, vhost_user_session_shutdown_on_init, vhost_cb);
	return NULL;
}

void
vhost_user_fini(vhost_fini_cb vhost_cb)
vhost_user_fini(spdk_vhost_fini_cb vhost_cb)
{
	pthread_t tid;
	int rc;

	if (!g_vhost_user_started) {
		vhost_cb(NULL);
		vhost_cb();
		return;
	}

Loading