Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions libnvme/src/nvme/fabrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,26 @@ __public int nvmf_context_set_connection(struct nvmf_context *fctx,
return 0;
}

static const char *hostid_from_hostnqn(const char *hostnqn)
{
const char *match;

if (!hostnqn)
return NULL;

match = strstr(hostnqn, "uuid:");
if (!match)
return NULL;

return match + strlen("uuid:");
}

__public int nvmf_context_set_hostnqn(struct nvmf_context *fctx,
const char *hostnqn, const char *hostid)
{
fctx->hostnqn = hostnqn;
if (!hostid)
hostid = hostid_from_hostnqn(hostnqn);
fctx->hostid = hostid;

return 0;
Expand Down
2 changes: 2 additions & 0 deletions libnvme/src/nvme/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,8 @@ static int nvme_create_host(struct nvme_global_ctx *ctx, const char *hostnqn,
return -ENOMEM;

h->hostnqn = strdup(hostnqn);
if (!hostid)
hostid = nvme_hostid_from_hostnqn(hostnqn);
if (hostid)
h->hostid = strdup(hostid);
list_head_init(&h->subsystems);
Expand Down
Loading