libnvmf\_host\_get\_ids(9) libnvme API manual libnvmf\_host\_get\_ids(9)

# [NAME](#NAME)

libnvmf\_host\_get\_ids - Retrieve host ids from various sources

# [SYNOPSIS](#SYNOPSIS)

**int libnvmf\_host\_get\_ids** **(struct libnvme\_global\_ctx \*ctx ,** **const char \*hostnqn\_arg ,** **const char \*hostid\_arg ,** **char \*\*hostnqn ,** **char \*\*hostid );**

# [ARGUMENTS](#ARGUMENTS)

[ctx](#ctx)

struct libnvme\_global\_ctx object

[hostnqn\_arg](#hostnqn_arg)

Input hostnqn (command line) argument

[hostid\_arg](#hostid_arg)

Input hostid (command line) argument

[hostnqn](#hostnqn)

Output hostnqn; may be NULL if the caller does not need it

[hostid](#hostid)

Output hostid; may be NULL if the caller does not need it

# [DESCRIPTION](#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](#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 September 2026

---

Document: libnvmf_host_get_ids-libnvme3(2) from nvme-cli 3.1-r1 (Chainguard OS)
Source: https://github.com/linux-nvme/nvme-cli
