Repository navigation
nvx: name the timing bounds of the run command's foreground - #2233
Merged
Pedro Henrique Penna (ppenna) merged 1 commit intoNov 27, 2026
Merged
Conversation
The foreground of a cold `nvx run` timed its waits with inline literals whose purpose its code did not state: a 10 ms idle poll five times, 250 ms for four different bounds, 60 s for three, a 10 s stop deadline, and an 8192-byte read buffer twice. A reader could not tell which bound a value set, and a change to one could miss its siblings or change an unrelated bound of the same value. Name each bound once, with a private constant in `run.rs` whose doc comment states the limit it bounds, and pass the existing `KILL_TIMEOUT`, which every other `vm::stop` caller already passes, for the stop deadline. Every constant keeps its literal's value and type; the managed attachment's `60.0` seconds is now `ATTACH_TIMEOUT.as_secs_f64()`, which is exactly 60.0. Tests: the `host::cli::run` and `host::cli::session` unit tests pass unchanged, as at the base revision 2e30219 (56 passed, 2 ignored on Windows). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the refactor that makes foreground run timing limits and buffer sizes explicit.
No open issues 🎉
What changed in this PR
This refactors the cold nvx run foreground path to make timing limits and buffer sizes explicit, addressing #2232 while preserving existing values and behavior.
Changes:
- Adds documented private constants for polling, console connections, managed attachment, shutdown grace periods, and transfer buffers.
- Reuses the existing
KILL_TIMEOUTfor the stop deadline, leaving session timeout APIs unchanged.
| File | Description |
|---|---|
nvx/src/host/cli/run.rs |
Replaces inline timing and buffer literals with named constants and the shared stop timeout. |
Review effort: Balanced
Pedro Henrique Penna (ppenna)
deleted the
agents/issue-2232-run-foreground-timing
branch
November 27, 2026 06:18
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.
Fixes #2232
What does this pull request change?
It replaces the inline timing literals and buffer sizes in the foreground of a cold
nvx run(nvx/src/host/cli/run.rs) with named private constants. Each constant's doc comment states the limit it sets:FOREGROUND_POLL(10 ms) andCONSOLE_ATTEMPT_TIMEOUT(250 ms, used everywhere except Linux)CONSOLE_TIMEOUT(60 s) andPEER_EXIT_WAIT(250 ms)ATTACH_TIMEOUT(60 s, applied to each attachment phase) andATTACH_CLOSED_GRACE(60 s)ATTACH_FAILURE_DRAIN(250 ms) andSTOP_GRACE(250 ms)TRANSFER_BUFFER_LEN(8192)The stop deadline now uses the existing
KILL_TIMEOUT(10 s), which every othervm::stopcaller already passes.Each constant keeps its literal's value and type, so behavior does not change. The managed attachment's
60.0is nowATTACH_TIMEOUT.as_secs_f64(), which is exactly 60.0. Review can start at the constant block afterRUN_DIRECTORY.This change leaves out
Session::connect_launched_cancellableandSession::stop, which still takef64seconds instead of aDuration. Changing them is a possible follow-up.Why is this change needed?
Several bounds share a value: 250 ms is used for four different bounds and 60 s for three. A reader could not tell which bound a literal set, and a change to one could miss its siblings or change an unrelated bound that happened to share the value.
How was this change validated?
Checks and results:
2e302197d90and at the head:cargo test --locked --all-features --lib -- host::cli::run host::cli::sessioninnvx/: 56 passed, 2 ignored, at both.python scripts/local_gates.py --base origin/dev --runpassed: test-changes, markdown-links, test-layout, nvx-format, nvx-lint, nvx-test, nvx-doc, nvx-msrv, nvx-cli.NVXset to a release build (cargo build --release --locked --features cli --manifest-path nvx/Cargo.toml):python -m unittest scripts.test_nvx_wrapperpassed, 21 tests run and none skipped. Thenvx-cligate had skipped these tests becauseNVXwas unset.python3 scripts/local_gates.py --base origin/dev --runpassed: test-changes, markdown-links, test-layout, nvx-format, nvx-lint, nvx-test, nvx-doc, nvx-public-api, nvx-msrv, nvx-macos, nvx-guest-binaries-lint, nvx-guest-binaries-build.nvx-clipassed on a rerun with--only nvx-cli, in a virtual environment and withNVXset. The first attempt failed only because PEP 668 blockedpipfrom installing into the system Python.python scripts/nvx.py test-microvm --backend whp --scenario console-exit,lifecycle, andmanaged-lifecyclepassed, using the release artifacts fromnvx download, since the OpenVMM pin is unchanged.python3 scripts/check_test_changes.py --base origin/dev: 0 changes to existing tests.Backend, host OS, host type, and guest:
Left to CI:
intel.alderlake.v1CPU profile (E_PROFILE_UNSUPPORTED).Checklist
python3 scripts/check_test_layout.pychecks.python3 scripts/check_test_changes.py --base origin/devlists no changeto an existing test, or a Changes to existing tests section below
explains each one.
.github/copilot-instructions.mdand the skills when a convention orworkflow changes.
nvxupdatesnvx/public-api/withpython3 scripts/public_api.py --update.description says how the change versions or migrates them.