Skip to content

libnvme, python: pass global context to registry public APIs and fix python test issue#3460

Merged
igaw merged 2 commits into
linux-nvme:masterfrom
martin-belanger:add-ctx-to-registry-api
Jun 22, 2026
Merged

libnvme, python: pass global context to registry public APIs and fix python test issue#3460
igaw merged 2 commits into
linux-nvme:masterfrom
martin-belanger:add-ctx-to-registry-api

Conversation

@martin-belanger

@martin-belanger martin-belanger commented Jun 19, 2026

Copy link
Copy Markdown

@igaw - Per our discussion. I decided to bundle two commits into this PR.

  • Add global context to all registry public APIs.
  • Fix the python registry test. The problem was in the test fixture itself, not
    the python bindings (it relied on fork semantics, which broke under the
    spawn/forkserver default in Python 3.14).

I will wait on your decision for the fedora:latest CI workflow to catch python regressions early.

@martin-belanger martin-belanger changed the title libnvme: pass global context to registry public APIs libnvme, python: pass global context to registry public APIs and fix python test issue Jun 19, 2026
Comment thread .github/workflows/fedora-latest.yml Outdated
Comment thread .github/workflows/fedora-latest.yml Outdated
Comment thread plugins/registry/registry-nvme.c Outdated
Comment thread plugins/registry/registry-nvme.c Outdated
@igaw

igaw commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

btw, about the Assisted-by tag. I pondered on it a for a while and I think it doesn't make sense. The author has to know the code she/he submits and also 'own' it. We always use tools to write/modify code. Often we don't mention them, so I don't really see why we need to advertise those tools (it's more like an endorsement thing in my eyes). Since I didn't get any lawyers advice I don't need them. Would you mind to drop them in the future. I know it's not what the LF wants but this project is not part of LF in anyway.

Martin Belanger added 2 commits June 22, 2026 06:37
Make struct libnvme_global_ctx the first argument of every public
libnvmf_registry_* function. Most do not use it yet, but threading it in
now lets a future version log via libnvme_msg() or reach per-context
state without breaking the ABI again. Each public function rejects a
NULL context with -EINVAL; the internal *_instance helpers only forward
it and do not re-validate. Also forward-declare the struct in registry.h
so the public header is self-contained.

While here, fix disconnect_all_match() in fabrics.c to take the caller's
context instead of creating one per controller. It also returned -ENOMEM
from a function declared bool, which coerces to true and would have
disconnected controllers on an allocation failure.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
The python-registry parallel-writes test only passed under the "fork"
multiprocessing start method. Python 3.14 makes "forkserver" the default
on Linux, where the test failed two ways:

  - Each child re-imports the test module, which unconditionally created
    a fresh NVME_REGISTRY_DIR. The children then wrote to a directory the
    parent never reads, so the final value came back as the parent's
    initial write.

  - The libnvme context was passed as a Process argument. A SwigPyObject
    cannot be pickled for spawn/forkserver, and a context is not meant to
    be shared across processes anyway.

Reuse an inherited /tmp registry directory instead of always creating a
new one, and have each writer process create its own GlobalCtx. Verified
under fork, forkserver and spawn.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
@martin-belanger martin-belanger force-pushed the add-ctx-to-registry-api branch from b009fee to fb26991 Compare June 22, 2026 11:38
@martin-belanger

Copy link
Copy Markdown
Author

@igaw - I've pulled the CI workflow out of this PR so it doesn't hold up the rest. I'll bring it back as its own PR once we've settled the ci-containers direction (using the pre-built image, and whether the fedora image moves to fedora:latest + a scheduled rebuild so it still catches new-Python regressions early).

@igaw igaw merged commit 1095aa7 into linux-nvme:master Jun 22, 2026
29 of 30 checks passed
@igaw

igaw commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Thanks a lot!

@martin-belanger martin-belanger deleted the add-ctx-to-registry-api branch June 22, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants