libnvme/config: add an INI-format NVMe-oF config parser#3566
libnvme/config: add an INI-format NVMe-oF config parser#3566martin-belanger wants to merge 8 commits into
Conversation
|
Generally, I really like this. It's a big PR but that was to be expected. And it's good to see the whole picture. Also the diagnostic part is a nice feature to have. The public API is not that big after realizing what is exposed and what not. Good job! The main points from my first review pass is mostly nitpicking (function signatures and not using ccan list) My big question is about config.json: is this correctly modeled? From my current understanding it is not... and the other question is: do we want to keep |
hostnqn/hostid — before answering "keep or drop the |
Generally, I'd say yes. Though there is a lot of complexity currently backed into |
Like the util-function idea — makes sense to promote Plan, as a separate PR (not part of this one): nvme-stas actually built its own version of this exact lookup years ago; would have reused this if it had existed then. |
Ah, the term "bag" is from compiler terminology. It's been a while. I suppose it can stay then, I just forgot about compiler building, something other people do :) |
|
I let chatgpt translate the commit message for |
|
|
|
0a9f214 to
970fe0c
Compare
|
@igaw -- Think I've addressed everything from this round, including the Pushed. Let me know if I missed anything. |
Describe the INI-format connection configuration intended to replace /etc/nvme/config.json: the file layout (a main nvme-fabrics.conf plus an optional nvme-fabrics.conf.d/ drop-in directory), the single- and multi-personality models, the precedence/merge rules with file-scoped defaults, the TLS and DH-CHAP security parameters, and the validation tiers. The format is parsed by libnvme so that nvme-cli, nvme-discoverd, and nvme-stas can all share one dependency-free parser. libnvme itself never reads config.json: conversion is a one-shot, nvme-cli-side job (nvme config convert), not a runtime fallback -- matching the "no third-party dependency" rationale this document already gives for choosing INI in the first place. Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Tokenize [Section] / "key = value" / # comment files and report events
through a callback; all meaning stays with the consumer. An empty
value ("key =") is distinct from an absent key, and a malformed
section header clears the current section so the lines below it are
never misattributed.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Connection parameters need to distinguish between inheriting a value, resetting to the kernel default, and setting an explicit value. Keep these states separate so the configuration precedence rules can be represented without ambiguity. Define each supported configuration key in a single key table. The table captures the value type and the configuration class that controls where the key is valid (tunable, security, [Host] identity, or endpoint). Do not carry forward the legacy numeric --tls_key option. Use the hyphenated fast-io-fail-tmo spelling introduced with the 3.0 rename. Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Store sections and entries from a configuration file without applying precedence or inheritance rules. The cascade resolver consumes these records later, allowing parsing and policy decisions to remain separate. Global and per-type default sections are merged with a warning when duplicated. Host sections are singletons, while endpoint sections may be repeated. Controller entries keep the raw addressing strings and separate per-path tunable overrides. Unknown keys and security options on path entries are rejected. Syntax and structural errors fail parsing with a file:line diagnostic. Non-fatal policy issues produce warnings and allow parsing to continue. Keep addressing values as raw strings instead of converting them to TIDs. Configuration files are a user-facing interface and may contain hostnames in traddr or host-traddr fields. TID creation has stricter requirements and belongs to the consumer that interprets the parsed configuration. Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Resolve the configuration hierarchy into the flat connection list consumed by users of the API. Load the main configuration file and its sorted drop-ins, then apply the precedence rules to produce the final set of (role, addressing, identity, params) connections. Keep default parameter scopes attached to resolved discovery controllers. This ensures controllers discovered through a DC (such as referrals or DLP entries) inherit the correct DC and IOC defaults. mDNS-discovered DCs use the top-level scope. Enforce relational validation rules during resolution. Reject drop-in personas without a name, duplicate host IDs assigned to different personas, and host NQNs associated with multiple host IDs. Keep addressing and identity fields as raw strings. traddr may still contain a hostname at this stage because parsing does not perform resolution. TID construction happens later in the consumer after address resolution. Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Expose the resolved configuration through a public API. The API provides configuration load, validation, and destruction, iteration over the resolved connection list, per-connection accessors, and lookup of the default parameters for controllers discovered at runtime (for example through DLP, AEN, or mDNS). Keep the parser and configuration hierarchy internal. Consumers see only the resolved connection list, where each entry provides its role, addressing, identity, and connection parameters. Expose addressing and identity through per-field accessors rather than as a TID. Address fields may still require name resolution, so TID construction is left to the caller. Publish the read-only connection parameter API because resolved connections reference shared parameter sets instead of copying individual values. Link the test against the installed shared library instead of the internal test library to verify the exported symbols defined by the version script. Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Emit an NVMe connect argument list from a resolved (TID, parameters) pair. The resolved configuration model provides the information needed to generate the arguments for a single "nvme connect" invocation, which can be used by consumers creating transient connections or displaying reproducible commands. Emit addressing and identity fields first, followed by connection parameters. Parameters with unset or reset values are omitted so the kernel defaults remain in effect. Boolean parameters are emitted as flags. Accept a TID and parameter set instead of a resolved connection object. This allows the emitter to be used for both configured connections and runtime-discovered controllers, where the caller constructs the TID and obtains the parameters separately. Signed-off-by: Martin Belanger <martin.belanger@dell.com>
A copy-paste error left host_iface sourced from trsvcid in the fctx built for libnvmf_ctrl_find(), so an interface-scoped lookup against an existing subsystem never matched on host_iface. Signed-off-by: Martin Belanger <martin.belanger@dell.com>
970fe0c to
e5113fd
Compare
Hi Daniel,
Here's the big PR I promised — ~4,400 lines total, but only ~1,400 of that is actual code and another ~1,400 tests; the rest is kdoc/comments, blank lines, and the design doc. It's self-contained: nothing calls into it yet, so no regression risk today. It's this size because it does two things the JSON blob didn't: real validation with
file:linediagnostics, and a drop-in file layout.Suggested order:
CONFIG.mdfirst (the design contract),config.h(the whole public surface),3.1 tokenizer: libnvme/config: add an internal INI reader
3.2 param bag: libnvme/config: add the parameter bag and key table
3.3 raw parser: libnvme/config: parse a config file into its raw model
3.4 cascade resolver: libnvme/config: resolve the cascade into the flat connection list
3.5 public API: libnvme/config: publish the resolved configuration
3.6 arg emitter: libnvme/config: add the connect argument emitter
host_iface/trsvcidcopy-paste mixup inlibnvmf_add_ctrl(), fixed while I was in the area.A second (much smaller) PR (write side +
nvme config convert) follows once this one lands.