From aacd61d54a795230bab40ff87f4f247360547b4d Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Wed, 14 Jun 2017 16:23:52 -0700 Subject: [PATCH] vhost: Move subsystem initialization to event_vhost This removes one dependency on the event framework. Change-Id: Ib9c8160b1704a15b662a35d5ad1f32c0b745485c Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/365729 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Daniel Verkamp --- include/spdk/vhost.h | 4 ++-- lib/event/subsystems/vhost/vhost.c | 16 ++++++++++++++++ lib/vhost/task.c | 12 +++++------- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/include/spdk/vhost.h b/include/spdk/vhost.h index cb2507e14f..0539d70863 100644 --- a/include/spdk/vhost.h +++ b/include/spdk/vhost.h @@ -43,8 +43,8 @@ #include "spdk/event.h" -void spdk_vhost_subsystem_init(void); -int spdk_vhost_subsystem_fini(void); +int spdk_vhost_init(void); +int spdk_vhost_fini(void); /** * \param event event object. event arg1 is optional path to vhost socket. diff --git a/lib/event/subsystems/vhost/vhost.c b/lib/event/subsystems/vhost/vhost.c index aede5904dd..f34d8589eb 100644 --- a/lib/event/subsystems/vhost/vhost.c +++ b/lib/event/subsystems/vhost/vhost.c @@ -37,5 +37,21 @@ #include "spdk_internal/event.h" +static void +spdk_vhost_subsystem_init(void) +{ + int rc = 0; + + rc = spdk_vhost_init(); + + spdk_subsystem_init_next(rc); +} + +static int +spdk_vhost_subsystem_fini(void) +{ + return spdk_vhost_fini(); +} + SPDK_SUBSYSTEM_REGISTER(vhost, spdk_vhost_subsystem_init, spdk_vhost_subsystem_fini, NULL) SPDK_SUBSYSTEM_DEPEND(vhost, scsi) diff --git a/lib/vhost/task.c b/lib/vhost/task.c index c601b0d5f7..59695283f5 100644 --- a/lib/vhost/task.c +++ b/lib/vhost/task.c @@ -85,23 +85,21 @@ spdk_vhost_task_get(struct spdk_vhost_scsi_dev *vdev) return task; } -void -spdk_vhost_subsystem_init(void) +int +spdk_vhost_init(void) { - int rc = 0; - g_task_pool = rte_mempool_create("vhost task pool", 16384, sizeof(struct spdk_vhost_task), 128, 0, NULL, NULL, NULL, NULL, SOCKET_ID_ANY, 0); if (!g_task_pool) { SPDK_ERRLOG("create task pool failed\n"); - rc = -1; + return -1; } - spdk_subsystem_init_next(rc); + return 0; } int -spdk_vhost_subsystem_fini(void) +spdk_vhost_fini(void) { return 0; }