event: Add return code to spdk_rpc_initialize
This is an internal API used in several places. The call can fail, so make sure it can report that correctly. Change-Id: Iac0ed2c8299c9dd3d2556070278a2224c3807b7b Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6640 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: <dongx.yi@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
0731c2273d
commit
f046750c32
@ -711,7 +711,13 @@ static void
|
||||
nvmf_subsystem_init_done(int rc, void *cb_arg)
|
||||
{
|
||||
fprintf(stdout, "bdev subsystem init successfully\n");
|
||||
spdk_rpc_initialize(g_rpc_addr);
|
||||
|
||||
rc = spdk_rpc_initialize(g_rpc_addr);
|
||||
if (rc) {
|
||||
spdk_app_stop(rc);
|
||||
return;
|
||||
}
|
||||
|
||||
spdk_rpc_set_state(SPDK_RPC_RUNTIME);
|
||||
|
||||
g_target_state = NVMF_INIT_TARGET;
|
||||
|
@ -214,7 +214,7 @@ void spdk_app_json_config_load(const char *json_config_file, const char *rpc_add
|
||||
*/
|
||||
void spdk_subsystem_config_json(struct spdk_json_write_ctx *w, struct spdk_subsystem *subsystem);
|
||||
|
||||
void spdk_rpc_initialize(const char *listen_addr);
|
||||
int spdk_rpc_initialize(const char *listen_addr);
|
||||
void spdk_rpc_finish(void);
|
||||
|
||||
struct spdk_governor_capabilities {
|
||||
|
@ -278,7 +278,12 @@ app_start_rpc(int rc, void *arg1)
|
||||
return;
|
||||
}
|
||||
|
||||
spdk_rpc_initialize(g_spdk_app.rpc_addr);
|
||||
rc = spdk_rpc_initialize(g_spdk_app.rpc_addr);
|
||||
if (rc) {
|
||||
spdk_app_stop(rc);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!g_delay_subsystem_init) {
|
||||
spdk_rpc_set_state(SPDK_RPC_RUNTIME);
|
||||
app_start_application();
|
||||
@ -393,6 +398,8 @@ app_setup_trace(struct spdk_app_opts *opts)
|
||||
static void
|
||||
bootstrap_fn(void *arg1)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (g_spdk_app.json_config_file) {
|
||||
g_delay_subsystem_init = false;
|
||||
spdk_app_json_config_load(g_spdk_app.json_config_file, g_spdk_app.rpc_addr, app_start_rpc,
|
||||
@ -401,7 +408,11 @@ bootstrap_fn(void *arg1)
|
||||
if (!g_delay_subsystem_init) {
|
||||
spdk_subsystem_init(app_start_rpc, NULL);
|
||||
} else {
|
||||
spdk_rpc_initialize(g_spdk_app.rpc_addr);
|
||||
rc = spdk_rpc_initialize(g_spdk_app.rpc_addr);
|
||||
if (rc) {
|
||||
spdk_app_stop(rc);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -614,8 +614,11 @@ spdk_app_json_config_load(const char *json_config_file, const char *rpc_addr,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* FIXME: spdk_rpc_initialize() function should return error code. */
|
||||
spdk_rpc_initialize(ctx->rpc_socket_path_temp);
|
||||
rc = spdk_rpc_initialize(ctx->rpc_socket_path_temp);
|
||||
if (rc) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ctx->client_conn = spdk_jsonrpc_client_connect(ctx->rpc_socket_path_temp, AF_UNIX);
|
||||
if (ctx->client_conn == NULL) {
|
||||
SPDK_ERRLOG("Failed to connect to '%s'\n", ctx->rpc_socket_path_temp);
|
||||
|
@ -51,31 +51,35 @@ rpc_subsystem_poll(void *arg)
|
||||
return SPDK_POLLER_BUSY;
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
spdk_rpc_initialize(const char *listen_addr)
|
||||
{
|
||||
int rc;
|
||||
|
||||
if (listen_addr == NULL) {
|
||||
return;
|
||||
/* Not treated as an error */
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!spdk_rpc_verify_methods()) {
|
||||
spdk_app_stop(-EINVAL);
|
||||
return;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Listen on the requested address */
|
||||
rc = spdk_rpc_listen(listen_addr);
|
||||
if (rc != 0) {
|
||||
SPDK_ERRLOG("Unable to start RPC service at %s\n", listen_addr);
|
||||
return;
|
||||
/* TODO: Eventually, treat this as an error. But it historically has not
|
||||
* been and many tests rely on this gracefully failing. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
spdk_rpc_set_state(SPDK_RPC_STARTUP);
|
||||
|
||||
/* Register a poller to periodically check for RPCs */
|
||||
g_rpc_poller = SPDK_POLLER_REGISTER(rpc_subsystem_poll, NULL, RPC_SELECT_INTERVAL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -49,7 +49,7 @@ DEFINE_STUB_V(spdk_rpc_register_method, (const char *method, spdk_rpc_method_han
|
||||
DEFINE_STUB_V(spdk_rpc_register_alias_deprecated, (const char *method, const char *alias));
|
||||
DEFINE_STUB_V(spdk_rpc_set_state, (uint32_t state));
|
||||
DEFINE_STUB(spdk_rpc_get_state, uint32_t, (void), SPDK_RPC_RUNTIME);
|
||||
DEFINE_STUB_V(spdk_rpc_initialize, (const char *listen_addr));
|
||||
DEFINE_STUB(spdk_rpc_initialize, int, (const char *listen_addr), 0);
|
||||
DEFINE_STUB_V(spdk_rpc_finish, (void));
|
||||
DEFINE_STUB_V(spdk_app_json_config_load, (const char *json_config_file, const char *rpc_addr,
|
||||
spdk_subsystem_init_fn cb_fn, void *cb_arg, bool stop_on_error));
|
||||
|
Loading…
Reference in New Issue
Block a user