varlink,qemu: Use CmdFds API for fd passing #248
Merged
gursewak1997 merged 2 commits intobootc-dev:mainfrom Apr 15, 2026
Merged
varlink,qemu: Use CmdFds API for fd passing #248gursewak1997 merged 2 commits intobootc-dev:mainfrom
gursewak1997 merged 2 commits intobootc-dev:mainfrom
Conversation
The new release adds the CmdFds API for atomic fd passing and systemd socket-activation environment setup. Prep for migrating to that API. Assisted-by: OpenCode (Claude Opus 4) Signed-off-by: Colin Walters <walters@verbum.org>
Replace the deprecated per-fd `take_fd_n()` calls with the new `CmdFds` + `take_fds()` API from cap-std-ext 5.1.2. The new API handles all fd shuffling atomically in a single `pre_exec` hook, avoiding the race where separate hooks can clobber each other when a source fd number equals another mapping's target. For varlink socket activation in integration tests, this is a significant simplification: the entire unsafe `pre_exec` block with manual `libc::setenv` calls for LISTEN_PID/LISTEN_FDS/LISTEN_FDNAMES is replaced by `CmdFds::new_systemd_fds()`, which handles both the fd placement at fd 3 and the environment variable setup. This also drops the `libc` and `rustix` direct dependencies from the integration-tests crate. Assisted-by: OpenCode (Claude Opus 4) Signed-off-by: Colin Walters <walters@verbum.org>
There was a problem hiding this comment.
Code Review
This pull request updates the cap-std-ext dependency to version 5.1.2 and refactors file descriptor handling to utilize the CmdFds API. In bcvk-qemu, manual FD passing is replaced with a CmdFds collection, and in the integration tests, the manual pre_exec logic for systemd socket activation is replaced with CmdFds::new_systemd_fds. A review comment suggests wrapping the take_fds call in a conditional check to prevent the unintended closing of inherited file descriptors when the CmdFds collection is empty.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.