Scroll to navigation

libnvmf_host_get_ids(9) libnvme API manual libnvmf_host_get_ids(9)

NAME

libnvmf_host_get_ids - Retrieve host ids from various sources

SYNOPSIS

int libnvmf_host_get_ids (struct libnvme_global_ctx *ctx , const char *hostnqn_arg , const char *hostid_arg , char **hostnqn , char **hostid );

ARGUMENTS

struct libnvme_global_ctx object
Input hostnqn (command line) argument
Input hostid (command line) argument
Output hostnqn; may be NULL if the caller does not need it
Output hostid; may be NULL if the caller does not need it

DESCRIPTION

libnvmf_host_get_ids figures out which hostnqn/hostid is to be used. There are several sources where this information can be retrieved.

The order is:

- Start with hostnqn/hostid given on the command line (hostnqn_arg, hostid_arg), if any - Otherwise, use the first host already resolved in ctx's host list, if any - Otherwise, use ctx's own hostnqn/hostid default, or /etc/nvme/hostnqn and /etc/nvme/hostid if ctx has none - Otherwise, if hostnqn is known but hostid is not, and hostnqn has a "uuid:" component, derive hostid from it - As a last resort, derive a still-missing hostid from DMI or device-tree information (or generate a random one), then build a hostnqn from that hostid if one is still missing

The function also checks that hostnqn and hostid match, logging a debug warning if not. The Linux NVMe implementation expects a 1:1 matching between the IDs.

RETURN

0 on success (hostnqn and hostid contain valid strings which the caller needs to free), or negative error code otherwise.

libnvmf_host_get_ids July 2026