vhost: add API to set socket path
This lets us drop the basename parameter from spdk_vhost_startup(), which is a step toward making vhost initialization happen as part of the event subsystem instead of in the spdk_app_start() callback. Change-Id: I4fe18c4c3f12b706e73ae74500be58f1582110fd Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-on: https://review.gerrithub.io/403225 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
245e2e9855
commit
fc0a23627e
@ -44,7 +44,6 @@
|
|||||||
#define SPDK_VHOST_DEFAULT_ENABLE_COREDUMP true
|
#define SPDK_VHOST_DEFAULT_ENABLE_COREDUMP true
|
||||||
#define SPDK_VHOST_DEFAULT_MEM_SIZE 1024
|
#define SPDK_VHOST_DEFAULT_MEM_SIZE 1024
|
||||||
|
|
||||||
static const char *g_socket_path = NULL;
|
|
||||||
static const char *g_pid_path = NULL;
|
static const char *g_pid_path = NULL;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -86,7 +85,7 @@ vhost_parse_arg(int ch, char *arg)
|
|||||||
g_pid_path = arg;
|
g_pid_path = arg;
|
||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
g_socket_path = arg;
|
spdk_vhost_set_socket_path(arg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,7 +109,7 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Blocks until the application is exiting */
|
/* Blocks until the application is exiting */
|
||||||
rc = spdk_app_start(&opts, spdk_vhost_startup, (void *)g_socket_path, NULL);
|
rc = spdk_app_start(&opts, spdk_vhost_startup, NULL, NULL);
|
||||||
|
|
||||||
spdk_app_fini();
|
spdk_app_fini();
|
||||||
|
|
||||||
|
@ -52,6 +52,17 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
typedef void (*spdk_vhost_fini_cb)(void);
|
typedef void (*spdk_vhost_fini_cb)(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the path to the directory where vhost sockets will be created.
|
||||||
|
*
|
||||||
|
* This function must be called before spdk_vhost_init().
|
||||||
|
*
|
||||||
|
* \param basename Path to vhost socket directory
|
||||||
|
*
|
||||||
|
* \return 0 on success, negative errno on error.
|
||||||
|
*/
|
||||||
|
int spdk_vhost_set_socket_path(const char *basename);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init vhost environment.
|
* Init vhost environment.
|
||||||
*
|
*
|
||||||
@ -69,7 +80,7 @@ void spdk_vhost_fini(spdk_vhost_fini_cb fini_cb);
|
|||||||
/**
|
/**
|
||||||
* Init vhost application. This is called once by SPDK app layer.
|
* Init vhost application. This is called once by SPDK app layer.
|
||||||
*
|
*
|
||||||
* \param arg1 optional path to directory where sockets will be created.
|
* \param arg1 unused.
|
||||||
* \param arg2 unused.
|
* \param arg2 unused.
|
||||||
*/
|
*/
|
||||||
void spdk_vhost_startup(void *arg1, void *arg2);
|
void spdk_vhost_startup(void *arg1, void *arg2);
|
||||||
|
@ -1097,17 +1097,16 @@ out:
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
spdk_vhost_startup(void *arg1, void *arg2)
|
spdk_vhost_set_socket_path(const char *basename)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
const char *basename = arg1;
|
|
||||||
|
|
||||||
if (basename && strlen(basename) > 0) {
|
if (basename && strlen(basename) > 0) {
|
||||||
ret = snprintf(dev_dirname, sizeof(dev_dirname) - 2, "%s", basename);
|
ret = snprintf(dev_dirname, sizeof(dev_dirname) - 2, "%s", basename);
|
||||||
if ((size_t)ret >= sizeof(dev_dirname) - 2) {
|
if ((size_t)ret >= sizeof(dev_dirname) - 2) {
|
||||||
SPDK_ERRLOG("Char dev dir path length %d is too long\n", ret);
|
SPDK_ERRLOG("Char dev dir path length %d is too long\n", ret);
|
||||||
goto out;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev_dirname[ret - 1] != '/') {
|
if (dev_dirname[ret - 1] != '/') {
|
||||||
@ -1116,6 +1115,14 @@ spdk_vhost_startup(void *arg1, void *arg2)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
spdk_vhost_startup(void *arg1, void *arg2)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
ret = spdk_vhost_scsi_controller_construct();
|
ret = spdk_vhost_scsi_controller_construct();
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
SPDK_ERRLOG("Cannot construct vhost controllers\n");
|
SPDK_ERRLOG("Cannot construct vhost controllers\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user