init.h File Reference

SPDK Initialization Helper. More...

Data Structures

struct  spdk_rpc_opts
 Structure with optional parameters for the JSON-RPC server initialization. More...
 

Macros

#define SPDK_DEFAULT_RPC_ADDR   "/var/tmp/spdk.sock"
 

Typedefs

typedef void(* spdk_subsystem_init_fn) (int rc, void *ctx)
 
typedef void(* spdk_subsystem_fini_fn) (void *ctx)
 

Functions

 SPDK_STATIC_ASSERT (sizeof(struct spdk_rpc_opts)==24, "Incorrect size")
 
int spdk_rpc_initialize (const char *listen_addr, const struct spdk_rpc_opts *opts)
 Create SPDK JSON-RPC server listening at provided address and start polling it for connections. More...
 
void spdk_rpc_finish (void)
 Stop SPDK JSON-RPC servers and stop polling for new connections on all addresses.
 
void spdk_rpc_server_finish (const char *listen_addr)
 Stop SPDK JSON-RPC server and stop polling for new connections on provided address. More...
 
void spdk_subsystem_init (spdk_subsystem_init_fn cb_fn, void *cb_arg)
 Begin the initialization process for all SPDK subsystems. More...
 
void spdk_subsystem_init_from_json_config (const char *json_config_file, const char *rpc_addr, spdk_subsystem_init_fn cb_fn, void *cb_arg, bool stop_on_error)
 Like spdk_subsystem_init, but additionally configure each subsystem using the provided JSON config file. More...
 
void spdk_subsystem_load_config (void *json, ssize_t json_size, spdk_subsystem_init_fn cb_fn, void *cb_arg, bool stop_on_error)
 Loads RPC configuration from provided JSON for current RPC state. More...
 
void spdk_subsystem_fini (spdk_subsystem_fini_fn cb_fn, void *cb_arg)
 Tear down all of the subsystems in the correct order. More...
 
bool spdk_subsystem_exists (const char *name)
 Check if the specified subsystem exists in the application. More...
 
void spdk_rpc_server_pause (const char *listen_addr)
 Pause polling RPC server with given address. More...
 
void spdk_rpc_server_resume (const char *listen_addr)
 Resume polling RPC server with given address. More...
 

Detailed Description

SPDK Initialization Helper.

Function Documentation

◆ spdk_rpc_initialize()

int spdk_rpc_initialize ( const char *  listen_addr,
const struct spdk_rpc_opts opts 
)

Create SPDK JSON-RPC server listening at provided address and start polling it for connections.

The RPC server is optional and is independent of subsystem initialization. The RPC server can be started and stopped at any time.

Parameters
listen_addrPath to a unix domain socket to listen on
optsOptions for JSON-RPC server initialization. If NULL, default values are used.
Returns
Negated errno on failure. 0 on success.

◆ spdk_rpc_server_finish()

void spdk_rpc_server_finish ( const char *  listen_addr)

Stop SPDK JSON-RPC server and stop polling for new connections on provided address.

Parameters
listen_addrPath to a unix domain socket.

◆ spdk_rpc_server_pause()

void spdk_rpc_server_pause ( const char *  listen_addr)

Pause polling RPC server with given address.

Parameters
listen_addrAddress, on which RPC server listens for connections.

◆ spdk_rpc_server_resume()

void spdk_rpc_server_resume ( const char *  listen_addr)

Resume polling RPC server with given address.

Parameters
listen_addrAddress, on which RPC server listens for connections.

◆ spdk_subsystem_exists()

bool spdk_subsystem_exists ( const char *  name)

Check if the specified subsystem exists in the application.

Parameters
nameName of the subsystem to look for
Returns
true if it exists, false if not

◆ spdk_subsystem_fini()

void spdk_subsystem_fini ( spdk_subsystem_fini_fn  cb_fn,
void *  cb_arg 
)

Tear down all of the subsystems in the correct order.

Parameters
cb_fnFunction called when the process is complete.
cb_argUser context passed to cb_fn

◆ spdk_subsystem_init()

void spdk_subsystem_init ( spdk_subsystem_init_fn  cb_fn,
void *  cb_arg 
)

Begin the initialization process for all SPDK subsystems.

SPDK is divided into subsystems at a macro-level and each subsystem automatically registers itself with this library at start up using a C constructor. Further, each subsystem can declare other subsystems that it depends on. Calling this function will correctly initialize all subsystems that are present, in the required order.

Parameters
cb_fnFunction called when the process is complete.
cb_argUser context passed to cb_fn.

◆ spdk_subsystem_init_from_json_config()

void spdk_subsystem_init_from_json_config ( const char *  json_config_file,
const char *  rpc_addr,
spdk_subsystem_init_fn  cb_fn,
void *  cb_arg,
bool  stop_on_error 
)

Like spdk_subsystem_init, but additionally configure each subsystem using the provided JSON config file.

This will automatically start a JSON RPC server and then stop it.

Deprecated - will be removed in 24.09 SPDK release. Please use spdk_subsystem_load_config.

Parameters
json_config_filePath to a JSON config file.
rpc_addrPath to a unix domain socket to send configuration RPCs to.
cb_fnFunction called when the process is complete.
cb_argUser context passed to cb_fn.
stop_on_errorWhether to stop initialization if one of the JSON RPCs fails.

◆ spdk_subsystem_load_config()

void spdk_subsystem_load_config ( void *  json,
ssize_t  json_size,
spdk_subsystem_init_fn  cb_fn,
void *  cb_arg,
bool  stop_on_error 
)

Loads RPC configuration from provided JSON for current RPC state.

The function will automatically start a JSON RPC server for configuration purposes and then stop it. JSON data will be copied, so parsing will not disturb the original memory.

Parameters
jsonRaw JSON data.
json_sizeSize of JSON data.
cb_fnFunction called when the process is complete.
cb_argUser context passed to cb_fn.
stop_on_errorWhether to stop initialization if one of the JSON RPCs fails.