nvme/example: add the call to spdk_nvme_connect()

In this identify example, added a call to the newly introduced
public spdk_nvme_connect() API so that other related change can
refer to this one as an example.

Change-Id: Iba97b6e52810a66d4c781bb563985e84ffb86708
Signed-off-by: GangCao <gang.cao@intel.com>
Reviewed-on: https://review.gerrithub.io/382070
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
GangCao 2017-10-10 12:19:21 -04:00 committed by Jim Harris
parent e46404f9cb
commit 13d4f08480

View File

@ -1070,6 +1070,7 @@ int main(int argc, char **argv)
{
int rc;
struct spdk_env_opts opts;
struct spdk_nvme_ctrlr *ctrlr;
rc = parse_args(argc, argv);
if (rc != 0) {
@ -1088,7 +1089,18 @@ int main(int argc, char **argv)
}
spdk_env_init(&opts);
if (spdk_nvme_probe(&g_trid, NULL, probe_cb, attach_cb, NULL) != 0) {
/* A specific trid is required. */
if (strlen(g_trid.traddr) != 0) {
ctrlr = spdk_nvme_connect(&g_trid, NULL, 0);
if (!ctrlr) {
fprintf(stderr, "spdk_nvme_connect() failed\n");
return 1;
}
g_controllers_found++;
print_controller(ctrlr, &g_trid);
spdk_nvme_detach(ctrlr);
} else if (spdk_nvme_probe(&g_trid, NULL, probe_cb, attach_cb, NULL) != 0) {
fprintf(stderr, "spdk_nvme_probe() failed\n");
return 1;
}