libnvmf_host_get_ids(9)

πŸ“¦ version 3.2, in arch rolling

πŸ’… libnvmf_host_get_ids(9) β€” your girl's guide to the libnvme API manual

okay so bestie, welcome to libnvmf_host_get_ids, a page from the libnvme API manual, and honestly it's giving "who am I and where do I come from" but for host IDs. let's go πŸŽ€


✨ 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
);

like literally just copy that exactly, no cap 🫢


✨ ARGUMENTS ✨

  • ctx β€” your struct libnvme_global_ctx object, the main character of this whole function ngl πŸ‘‘
  • hostnqn_arg β€” the input hostnqn (command line) argument, aka the one you typed in ✍️
  • hostid_arg β€” the input hostid (command line) argument, same vibe, different id πŸ’…
  • hostnqn β€” output hostnqn; and listen, it may be NULL if the caller doesn't need it πŸ™ˆ
  • hostid β€” output hostid; also may be NULL if the caller doesn't need it, so no pressure πŸ“

✨ DESCRIPTION ✨

so libnvmf_host_get_ids figures out which hostnqn/hostid is to be used. there are several sources where this information can be retrieved, and it checks them in order, like a little priority queue of identity 🧚

the order is:

  • start with the 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, and logs a debug warning if they don't. the Linux NVMe implementation expects a 1:1 matching between the IDs β€” so yeah, they gotta be a matched set, periodt ✨

bestie be aware: mismatched IDs aren't an error here, you just get that debug warning logged. it's giving "we're not mad, we're just disappointed" 😭

✨ RETURN ✨

0 on success β€” and when it succeeds, hostnqn and hostid contain valid strings which the caller needs to free, don't forget, that's your responsibility now 🫢 β€” or a negative error code otherwise 🌈


and that's the whole page, bestie, you ate πŸ’…

sign-off: this iconic little number lives in the libnvme API manual, dated October 2026, and it says libnvmf_host_get_ids at the bottom too, so you literally can't forget the name πŸŽ€πŸ’– see you in the next manpage, mwah πŸ¦‹

πŸ“¦ where this page comes from