Skip to content

varlink,qemu: Use CmdFds API for fd passing #248

Merged
gursewak1997 merged 2 commits intobootc-dev:mainfrom
cgwalters:cap-std-ext-bump
Apr 15, 2026
Merged

varlink,qemu: Use CmdFds API for fd passing #248
gursewak1997 merged 2 commits intobootc-dev:mainfrom
cgwalters:cap-std-ext-bump

Conversation

@cgwalters
Copy link
Copy Markdown
Collaborator

No description provided.

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>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread crates/bcvk-qemu/src/qemu.rs
Copy link
Copy Markdown
Collaborator

@gursewak1997 gursewak1997 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@gursewak1997 gursewak1997 merged commit 6cbff42 into bootc-dev:main Apr 15, 2026
17 checks passed
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