---
name: "libnvmf_host_get_ids-libnvme3"
section: "2"
platform: "linux"
package: "nvme-cli"
version: "3.2-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libnvmf_host_get_ids-libnvme3"
---

# libnvmf\_host\_get\_ids-libnvme3(2)

Retrieve host ids from various sources

## 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

- ctx

  struct libnvme\_global\_ctx object

- hostnqn\_arg

  Input hostnqn (command line) argument

- hostid\_arg

  Input hostid (command line) argument

- hostnqn

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

- hostid

  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.
