Skip to content

nvx: move InheritedHandle into its own vm submodule - #2329

Merged
Pedro Henrique Penna (ppenna) merged 1 commit into
devfrom
issue-2328-inherited-handle-module
Nov 28, 2026
Merged

Pedro Henrique Penna (ppenna) merged 1 commit into
devfrom
issue-2328-inherited-handle-module

Conversation

@ppenna

Copy link
Copy Markdown
Contributor

Fixes #2328

What does this pull request change?

It moves the Owned platform alias and the public InheritedHandle type, with its From, AsFd, and AsHandle impls, unchanged from nvx/src/host/vm.rs into a new private submodule, nvx/src/host/vm/handle.rs, which vm re-exports with pub use handle::InheritedHandle;, so nvx::host::vm::InheritedHandle keeps its path. The two conversion tests and the inherited_file test helper move unchanged into nvx/src/host/vm/handle/tests.rs, and vm/tests.rs imports the helper, as it imports vm_directory::tests::vm_dir. The only addition is the new module's //! doc line, which clippy::missing_docs_in_private_items requires.

Start at nvx/src/host/vm/handle.rs. Behavior, doc comments, error messages, and the public API are unchanged.

Why is this change needed?

vm.rs (1,308 lines) mixed a self-contained platform handle-ownership wrapper into the VM launch flow, between the attach helpers and LaunchCommand; nothing else in vm.rs touches its internals. Splitting it out, as vm/connection.rs already splits out connections, shortens vm.rs by 70 lines and keeps platform cfg impls together with their tests.

How was this change validated?

Checks and results:

  • python scripts/local_gates.py --base origin/dev --run --keep-going (Windows 11, with Git's usr\bin on PATH, XDG_CACHE_HOME unset): test-changes, markdown-links, test-layout, nvx-format, nvx-test, nvx-doc, nvx-msrv, nvx-cli passed; nvx-lint failed on the missing module doc, fixed in this commit, then --only nvx-lint nvx-doc nvx-format test-layout passed.
  • python scripts/public_api.py: passed, no snapshot change.
  • cargo test --locked --lib -- host::vm:: (NVX_BUNDLE=skip): Windows 62 passed, as at origin/dev (62 passed), including host::vm::handle::tests::an_owned_windows_handle_moves_into_and_out_of_an_inherited_handle; Linux (WSL) 66 passed, including host::vm::handle::tests::an_owned_descriptor_moves_into_and_out_of_an_inherited_handle.
  • cargo clippy --locked --all-targets --all-features -- -D warnings on Linux (WSL): passed.

Backend, host OS, host type, and guest: no microVM run; the change is a source move with no runtime effect.
Left to CI: the microVM scenarios that local_gates.py lists for all backends, and macOS lint.

Checklist

  • Tests cover the new or fixed behavior, in the layout that
    python3 scripts/check_test_layout.py checks.
  • python3 scripts/check_test_changes.py --base origin/dev lists no change
    to an existing test, or a Changes to existing tests section below
    explains each one.
  • The documentation that the change affects is updated, including
    .github/copilot-instructions.md and the skills when a convention or
    workflow changes.
  • A change to the public API of nvx updates nvx/public-api/ with
    python3 scripts/public_api.py --update.
  • Snapshots, protocols, and on-disk formats stay compatible, or the
    description says how the change versions or migrates them.

Changes to existing tests

check_test_changes.py reports 0 changes to existing tests; it lists the two conversion tests and the inherited_file helper as relocated unchanged from nvx/src/host/vm/tests.rs to nvx/src/host/vm/handle/tests.rs.

vm.rs defined the Owned platform alias and the public InheritedHandle
type with its platform conversions inline, between the attach helpers
and LaunchCommand. Move them unchanged into host/vm/handle.rs, which vm
re-exports so nvx::host::vm::InheritedHandle keeps its path, and move
their conversion tests and the inherited_file helper into
host/vm/handle/tests.rs, which vm's tests reuse.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 28, 2026 10:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the refactor separating handle ownership from VM launch logic.

No open issues 🎉

What changed in this PR

Addresses #2328 by separating platform handle ownership from VM launch logic. The refactor preserves nvx::host::vm::InheritedHandle, its behavior, and its public documentation.

Changes:

  • Moves Owned, InheritedHandle, and platform conversion implementations into a private handle submodule.
  • Re-exports InheritedHandle from vm to preserve its public path.
  • Relocates the two conversion tests and shares their inherited_file helper with the VM tests.
File Description
nvx/​src/​host/​vm/​tests.rs Imports the relocated helper and removes the moved conversion tests.
nvx/​src/​host/​vm/​handle/​tests.rs Houses the unchanged conversion tests and shared helper.
nvx/​src/​host/​vm/​handle.rs Contains the extracted ownership wrapper, platform implementations, and module documentation.
nvx/​src/​host/​vm.rs Declares the private submodule and re-exports InheritedHandle, replacing its inline definition.

Review effort: Balanced

@ppenna
Pedro Henrique Penna (ppenna) added this pull request to the merge queue Nov 28, 2026
Merged via the queue into dev with commit 2c662b6 Nov 28, 2026
56 checks passed
@ppenna
Pedro Henrique Penna (ppenna) deleted the issue-2328-inherited-handle-module branch November 28, 2026 17:30
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.

nvx: move InheritedHandle into its own vm submodule

2 participants