init.h File Reference

SPDK Initialization Helper. 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

int spdk_rpc_initialize (const char *listen_addr)
 Create the SPDK JSON-RPC server and listen at the provided address. More...
 
void spdk_rpc_finish (void)
 Shut down the SPDK JSON-RPC target.
 
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_fini (spdk_subsystem_fini_fn cb_fn, void *cb_arg)
 Tear down all of the subsystems in the correct order. More...
 

Detailed Description

SPDK Initialization Helper.

Function Documentation

◆ spdk_rpc_initialize()

int spdk_rpc_initialize ( const char *  listen_addr)

Create the SPDK JSON-RPC server and listen at the provided address.

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
Returns
Negated errno on failure. 0 on success.

◆ 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.

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.