lib/nvmf: add the nvmf_get_targets rpc.

Also update the changelog for the previous few changes.

Change-Id: I79ac330b4992ccc3e41fd1643b09128c6de6c86d
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/468391
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Seth Howell 2019-09-13 15:37:07 -07:00 committed by Jim Harris
parent b7fce0a3d4
commit 208e089a21
3 changed files with 51 additions and 0 deletions

View File

@ -21,6 +21,17 @@ a null name parameter and will return the only available target.
The majority of the NVMe-oF RPCs now accept an optional tgt_name parameter. This will
allow those RPCs to work with applications that create more than one target.
Three new NVMe-oF RPCs have been added `nvmf_create_target`, `nvmf_delete_target`, and
`nvmf_get_targets`. These new RPCs provide a basic interface for managing multiple target
objects. In SPDK the target object defines a unique discovery service. As of this release,
these RPCs are not intended to be used with the in-tree SPDK target applications, spdk_tgt and
nvmf_tgt, which use a single, global target structure. As such, they are not included in scripts/rpc.py
Three new header functions have also been added to help deal with multiple targets.
`spdk_nvmf_tgt_get_name` takes a target pointer as an argument and returns its human readable name.
`spdk_nvmf_get_first_target` takes no arguments and returns the first target in the global list.
`spdk_nvmf_get_next_tgt` takes a target pointer as an argument and returns the next one in the global list.
### bdev
A new spdk_bdev_open_ext function has been added and spdk_bdev_open function has been deprecated.

View File

@ -1501,6 +1501,36 @@ spdk_rpc_nvmf_delete_target(struct spdk_jsonrpc_request *request,
}
SPDK_RPC_REGISTER("nvmf_delete_target", spdk_rpc_nvmf_delete_target, SPDK_RPC_RUNTIME);
static void
spdk_rpc_nvmf_get_targets(struct spdk_jsonrpc_request *request,
const struct spdk_json_val *params)
{
struct spdk_json_write_ctx *w;
struct spdk_nvmf_tgt *tgt;
const char *name;
if (params != NULL) {
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
"nvmf_get_targets has no parameters.");
return;
}
w = spdk_jsonrpc_begin_result(request);
spdk_json_write_array_begin(w);
tgt = spdk_nvmf_get_first_tgt();
while (tgt != NULL) {
name = spdk_nvmf_tgt_get_name(tgt);
spdk_json_write_string(w, name);
tgt = spdk_nvmf_get_next_tgt(tgt);
}
spdk_json_write_array_end(w);
spdk_jsonrpc_end_result(request, w);
}
SPDK_RPC_REGISTER("nvmf_get_targets", spdk_rpc_nvmf_get_targets, SPDK_RPC_RUNTIME);
struct nvmf_rpc_create_transport_ctx {
char *trtype;
char *tgt_name;

View File

@ -75,6 +75,16 @@ def nvmf_delete_target(client,
return client.call("nvmf_delete_target", params)
def nvmf_get_targets(client):
"""Get a list of all the NVMe-oF targets in this application
Returns:
An array of target names.
"""
return client.call("nvmf_get_targets")
def nvmf_create_transport(client,
trtype,
tgt_name=None,