Repository navigation
nvx: refuse a cold run's command line over budget without shares - #2305
Queued
Pedro Henrique Penna (ppenna) wants to merge 1 commit into
Queued
Pedro Henrique Penna (ppenna) wants to merge 1 commit into
Pedro Henrique Penna (ppenna) wants to merge 1 commit into
Conversation
Contributor
This pull request changes existing testsIt modifies or removes 1 existing test asset(s), listed below. Review each with care: a change to a test can hide a regression that the test caught. See doc/contribute.md#changes-to-existing-tests. Test code
Relocated unchanged: 0; added: 1. Compared the merge base |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the cold-run command-line budget enforcement change.
No open issues 🎉
What changed in this PR
Fixes #2303 by enforcing the 1024-byte kernel command-line budget for cold nvx run boots without shares, matching runs with shares and nvx sandbox. Restore behavior and library validation remain unchanged.
Changes:
- Checks every cold run, including
--dry-run, and derives the reported limit fromCOMMAND_LINE_BUDGET. - Adds exact-boundary unit coverage and integration cases for rejection before side effects.
- Documents the budget and which tokens count toward it.
| File | Description |
|---|---|
nvx/tests/cli/validation.rs |
Adds oversized no-share command-line refusal cases for dry runs and launches. |
nvx/src/host/cli/run/tests.rs |
Tests acceptance at the byte limit and rejection one byte over. |
nvx/src/host/cli/run.rs |
Enforces the budget with or without shares and selects the appropriate error message. |
nvx/README.md |
Explains cold-run budget enforcement and byte accounting. |
doc/usage.md |
Updates --cmdline documentation with the enforced limit. |
Review effort: Balanced
A cold `nvx run` without --mount accepted a --cmdline of any length, --dry-run included, and each launch whose kernel command line then passed OpenVMM's 2047-byte limit failed in OpenVMM: a 2,402-byte --cmdline exited 1 with "microVM kernel command line is 2505 bytes; the limit is 2047 bytes plus the terminating NUL", while the same run with one --mount was refused at once by the 1024-byte budget that OpenVMM leaves to the caller's tokens. cold_vm_config checked COMMAND_LINE_BUDGET only when the run had an export, so nothing bounded the kernel command line of a run without shares: VmConfig::check refuses tokens by name alone, and VmConfig::check_command_line measures OpenVMM's Windows process command line. The sandbox's check_command_line holds every launch to the budget, counting no bootstrap tokens without an export. Check the budget for every cold run, as the sandbox does: the rendered line, the bootstrap tokens that OpenVMM appends for the export when there is one, and a NUL. With shares, the refusal reads as before; without them, "--cmdline exceeds the 1024-byte budget of the kernel command line; use shorter kernel parameters". Both now take the budget from COMMAND_LINE_BUDGET. A run without shares whose line lies between the budget and OpenVMM's limit, which launched before, is refused too, as one with shares and a sandbox's are. The README's run section and the --cmdline row of doc/usage.md say so. Evidence, with the artifacts of release v0.1.0-dev.b269fea351a8, on this Windows workstation with WHP and in its default WSL 2 distribution with KVM, the fallbacks for the unreachable configured profiles: at the base revision b269fea, the 2,402-byte --cmdline dry run exited 0 and its launch exited 1 with OpenVMM's error; with the fix, both exit 1 with the budget refusal, and OpenVMM never starts. A cold run with a short --cmdline still dry-runs and boots on WHP. No MSHV host was reachable. Tests: a unit test pins the budget of a cold run without shares to the byte, and validation_errors_exit_1_before_any_side_effect gains a dry run and a launch of a 1,100-byte --cmdline without shares, which must exit 1 before any side effect. Both fail at the base revision, where the line fits the run and the dry run exits 0, and pass with the fix. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pedro Henrique Penna (ppenna)
force-pushed
the
agents/issue-2303-cold-run-cmdline-budget
branch
from
November 28, 2026 16:20
3a238be to
4fd50f4
Compare
Pedro Henrique Penna (ppenna)
added this pull request to the merge queue
Nov 28, 2026
Any commits made after this event will not be merged.
This branch has not been deployed
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 #2303
What does this pull request change?
A cold
nvx runnow holds its kernel command line toCOMMAND_LINE_BUDGET,the 1024 bytes that OpenVMM leaves to NVX's tokens and
--cmdline, whether ornot it has
--mountshares, asnvx sandboxalready does. Before, a cold runwithout shares accepted a
--cmdlineof any length,--dry-runincluded, andOpenVMM refused each launch whose effective line passed its 2047-byte limit.
cold_vm_configinnvx/src/host/cli/run.rs, where a reviewer shouldstart, checks every cold run: the line that the run renders, the bootstrap
tokens that OpenVMM appends for the export when there is one, and a NUL.
With shares, the refusal reads exactly as before; without them, it reads
error[unsupported]: --cmdline exceeds the 1024-byte budget of the kernel command line; use shorter kernel parameters. Both messages now take thenumber from
COMMAND_LINE_BUDGET.cold_preflightrunscold_vm_configbefore anything else, so therefusal comes before an artifact download, a VM directory, or an OpenVMM
process, as the other cold-boot refusals do.
nvx/README.mdand the--cmdlinerow ofdoc/usage.mdsay so.Behavior change: a cold run without shares whose kernel command line lies
between the 1024-byte budget and OpenVMM's 2047-byte limit, which launched
before, is now refused, as the same run with one
--mount, and a sandbox'sstart, already are. A restore is unchanged, since it refuses
--cmdline, andso is the library:
VmConfigstill leaves the budget to its callers.Overlap: #2292, for #2291, rewrites the same lines of the shares message in
cold_vm_configto formatCOMMAND_LINE_BUDGET, and the sandbox's message instart.rs. Whichever lands second conflicts inrun.rs; the resolution keepsthis change's
cold_vm_config, which already formats the constant with theshares message byte for byte, and #2292's
start.rs.Why is this change needed?
nvx run --dry-run --cmdline <2,402 bytes>exited 0, and the same run without--dry-runcreated its VM directory, launched OpenVMM, and exited 1 withfatal error: microVM kernel command line is 2505 bytes; the limit is 2047 bytes plus the terminating NUL, on every attempt. With one--mount, thesame
--cmdlinewas refused at once with the budget message, andnvx sandboxrefuses it for every start.Root cause:
cold_vm_configchecked the budget only insideif let Some(export) = &config.filesystem, as since 4ca0741, which addedthe check with the cold blockless lifecycle. Nothing else bounds the length
of a run's kernel command line:
VmConfig::checkrefuses tokens by namealone, and
VmConfig::check_command_linemeasures OpenVMM's Windows processcommand line, not the kernel's. The sandbox's
check_command_lineholds everystart to the budget and counts no bootstrap tokens without an export, which
this change reproduces.
Alternatives rejected:
instead: NVX would have to model the tokens that OpenVMM's machine profile
appends, such as
console=,nr_cpus=, and the network bootstrap, which itleaves to OpenVMM on purpose, and the run would accept lines that the same
run with a share, or a sandbox, refuses.
a run that can never launch, and every launch would first create a VM
directory and start OpenVMM.
How was this change validated?
Checks and results:
python scripts\local_gates.py --base origin/dev --runon Windows 11, withGit's
usr\binonPATHandNVXset to the release build of the fix:passed, all nine selected gates (
test-changes,markdown-links,test-layout,nvx-format,nvx-lint,nvx-test,nvx-doc,nvx-msrv,and
nvx-cli), in 1,177 s.python3 scripts/local_gates.py --base origin/dev --runin a clone of thefix in WSL 2 (Ubuntu 26.04), with a
pythonlink topython3onPATH:twelve of the thirteen selected gates passed (
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, andnvx-guest-binaries-build).nvx-clistopped at its first command,
python3 -m pip install --requirement scripts/setup/azure/requirements.txt, which the distribution's externallymanaged Python refuses (PEP 668) before running any test. That Python
already has the pinned PyYAML 6.0.3, so the step's remaining commands, run
from the action with the gate's environment and
NVXset to the releasebuild of the fix, passed: 2,326 unit tests (41 skipped), the 84 adversarial
tests, and the
--helpchecks.python scripts\nvx.py test-microvm --backend whp --scenario filesystem-comma-pathson Windows 11, withNVXset to the release buildof the fix: passed, with three cold
nvx runboots with shares through thechanged check.
cargo test --locked --all-features --lib --test cli -- cold_command_lines_without_shares cold_share_command_lines_fit validation_errors_exit_1_before_any_side_effectinnvx/: with the fix,passed; with the new tests on the base revision's
run.rs, failed, theunit test at its refusal assertion and the integration test at its case
run: long command line without shares, whose dry run exited 0 where 1 wasexpected.
Runs before and after the fix, with the release artifacts of
v0.1.0-dev.b269fea351a8thatnvx downloadinstalled. The reproduction of#2303 is a dry run and a launch of a 2,402-byte
--cmdline, and the same dryrun with one
--mount; the smoke boot runsnvx run --cmdline 'quiet loglevel=3'and enters
/sbin/nvx-exit 0in the guest's shell:b269fea351a8microVM kernel command line is 2505 bytes; the limit is 2047 bytes plus the terminating NUL; with--mount, exit 1 with the budget refusal3a238be3194--cmdline exceeds the 1024-byte budget ...before OpenVMM starts; with--mount, the refusal as before; no VM directory leftNVX-GUEST-BOOT-OK: alpine, exit 0b269fea351a8[E_PROFILE_UNSUPPORTED] failed to launch vm worker3a238be3194E_PROFILE_UNSUPPORTEDas at the base with the default CPU profile; with--cpu-profile host,NVX-GUEST-BOOT-OK: alpine, the guest powered off with status 0, exit 0The default CPU profile's
E_PROFILE_UNSUPPORTEDin WSL happens at the baserevision too, before the launch reaches anything that this change touches.
No OpenVMM process or
nvx-run-*directory was left after any run.Backend, host OS, host type, and guest:
local fallback with no recorded host type, default Alpine guest.
on the same workstation, a WSL fallback with no recorded host type, default
Alpine guest.
nvx_hosts.py select BACKEND --host-type virtual-machineplaced no backend,and
select BACKENDreached none of the configured profiles:azure-intel-kvm-1to-5,-7, andazure-amd-kvm-1to-4for KVM;azure-intel-whp-1to-7,-11,-12, andazure-amd-whp-1to-4forWHP; and
azure-intel-mshv-1to-5,-8, andazure-amd-mshv-1to-4for MSHV.
Left to CI, and its result: run 46102305741
of
3a238be3194passed, with the platform jobs and the microVM tests onLinux/KVM, Linux/MSHV, and Windows/WHP virtual machines, the packages, the
performance regression gate, and
Required status check:cold-boot
nvx run, the egress-policy scenarios andfilesystem-comma-paths, pass--cmdline 'quiet loglevel=0', andcommand-line-limitboots OpenVMM directly.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.
Changes to existing tests
check_test_changes.pylists one:run_refusalsinnvx/tests/cli/validation.rs, the table ofrunrefusals thatvalidation_errors_exit_1_before_any_side_effectchecks, gains two cases, adry run and a launch of a 1,100-byte
--cmdlinewithout shares, which mustexit 1 with
--cmdline exceeds the 1024-byte budgetbefore any side effect.Its existing cases are unchanged, and the test still checks each of them as
before. At the base revision, the test fails at the first new case, whose dry
run exits 0.