Skip to content

nvx: refuse a cold run's command line over budget without shares - #2305

Queued
Pedro Henrique Penna (ppenna) wants to merge 1 commit into
devfrom
agents/issue-2303-cold-run-cmdline-budget
Queued

Pedro Henrique Penna (ppenna) wants to merge 1 commit into
devfrom
agents/issue-2303-cold-run-cmdline-budget

Conversation

@ppenna

@ppenna Pedro Henrique Penna (ppenna) commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2303

What does this pull request change?

A cold nvx run now holds its kernel command line to COMMAND_LINE_BUDGET,
the 1024 bytes that OpenVMM leaves to NVX's tokens and --cmdline, whether or
not it has --mount shares, as nvx sandbox already does. Before, a cold run
without shares accepted a --cmdline of any length, --dry-run included, and
OpenVMM refused each launch whose effective line passed its 2047-byte limit.

  • cold_vm_config in nvx/src/host/cli/run.rs, where a reviewer should
    start, 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 the
    number from COMMAND_LINE_BUDGET.
  • cold_preflight runs cold_vm_config before anything else, so the
    refusal comes before an artifact download, a VM directory, or an OpenVMM
    process, as the other cold-boot refusals do.
  • The run section of nvx/README.md and the --cmdline row of
    doc/usage.md say 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's
start, already are. A restore is unchanged, since it refuses --cmdline, and
so is the library: VmConfig still leaves the budget to its callers.

Overlap: #2292, for #2291, rewrites the same lines of the shares message in
cold_vm_config to format COMMAND_LINE_BUDGET, and the sandbox's message in
start.rs. Whichever lands second conflicts in run.rs; the resolution keeps
this change's cold_vm_config, which already formats the constant with the
shares 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-run created its VM directory, launched OpenVMM, and exited 1 with
fatal error: microVM kernel command line is 2505 bytes; the limit is 2047 bytes plus the terminating NUL, on every attempt. With one --mount, the
same --cmdline was refused at once with the budget message, and
nvx sandbox refuses it for every start.

Root cause: cold_vm_config checked the budget only inside
if let Some(export) = &config.filesystem, as since 4ca0741, which added
the check with the cold blockless lifecycle. Nothing else bounds the length
of a run's kernel command line: VmConfig::check refuses tokens by name
alone, and VmConfig::check_command_line measures OpenVMM's Windows process
command line, not the kernel's. The sandbox's check_command_line holds every
start to the budget and counts no bootstrap tokens without an export, which
this change reproduces.

Alternatives rejected:

  • Bounding a run without shares by OpenVMM's 2047-byte effective limit
    instead: NVX would have to model the tokens that OpenVMM's machine profile
    appends, such as console=, nr_cpus=, and the network bootstrap, which it
    leaves to OpenVMM on purpose, and the run would accept lines that the same
    run with a share, or a sandbox, refuses.
  • Leaving the refusal to OpenVMM: the dry run would keep reporting success for
    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 --run on Windows 11, with
    Git's usr\bin on PATH and NVX set 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 --run in a clone of the
    fix in WSL 2 (Ubuntu 26.04), with a python link to python3 on PATH:
    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, and nvx-guest-binaries-build). nvx-cli
    stopped at its first command, python3 -m pip install --requirement scripts/setup/azure/requirements.txt, which the distribution's externally
    managed 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 NVX set to the release
    build of the fix, passed: 2,326 unit tests (41 skipped), the 84 adversarial
    tests, and the --help checks.
  • python scripts\nvx.py test-microvm --backend whp --scenario filesystem-comma-paths on Windows 11, with NVX set to the release build
    of the fix: passed, with three cold nvx run boots with shares through the
    changed 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_effect in nvx/: with the fix,
    passed; with the new tests on the base revision's run.rs, failed, the
    unit 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 was
    expected.
  • A code-review pass over the branch's diff found no issues.

Runs before and after the fix, with the release artifacts of
v0.1.0-dev.b269fea351a8 that nvx download installed. The reproduction of
#2303 is a dry run and a launch of a 2,402-byte --cmdline, and the same dry
run with one --mount; the smoke boot runs nvx run --cmdline 'quiet loglevel=3'
and enters /sbin/nvx-exit 0 in the guest's shell:

Execution Backend Host type Revision Reproduction Smoke boot
This Windows workstation, the local fallback for the unreachable WHP profiles WHP none, local base b269fea351a8 Dry run exit 0; launch exit 1 from OpenVMM, microVM kernel command line is 2505 bytes; the limit is 2047 bytes plus the terminating NUL; with --mount, exit 1 with the budget refusal Not run
The same WHP none, local fix 3a238be3194 Dry run and launch exit 1 with --cmdline exceeds the 1024-byte budget ... before OpenVMM starts; with --mount, the refusal as before; no VM directory left NVX-GUEST-BOOT-OK: alpine, exit 0
Its default WSL 2 distribution, the WSL fallback for the unreachable KVM profiles KVM none, WSL base b269fea351a8 As on WHP at the base Exit 1 with the default CPU profile, [E_PROFILE_UNSUPPORTED] failed to launch vm worker
The same KVM none, WSL fix 3a238be3194 As on WHP with the fix The same E_PROFILE_UNSUPPORTED as 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 0
None: no MSHV profile was reachable, and MSHV never runs in WSL MSHV - - Left to CI Left to CI

The default CPU profile's E_PROFILE_UNSUPPORTED in WSL happens at the base
revision 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:

  • WHP: Windows 11 Enterprise 10.0.26300, 12th Gen Intel Core i9-12900H, a
    local fallback with no recorded host type, default Alpine guest.
  • KVM: Ubuntu 26.04 LTS in WSL 2 (kernel 6.18.58.1-microsoft-standard-WSL2)
    on the same workstation, a WSL fallback with no recorded host type, default
    Alpine guest.
  • nvx_hosts.py select BACKEND --host-type virtual-machine placed no backend,
    and select BACKEND reached none of the configured profiles:
    azure-intel-kvm-1 to -5, -7, and azure-amd-kvm-1 to -4 for KVM;
    azure-intel-whp-1 to -7, -11, -12, and azure-amd-whp-1 to -4 for
    WHP; and azure-intel-mshv-1 to -5, -8, and azure-amd-mshv-1 to -4
    for MSHV.

Left to CI, and its result: run 46102305741
of 3a238be3194 passed, with the platform jobs and the microVM tests on
Linux/KVM, Linux/MSHV, and Windows/WHP virtual machines, the packages, the
performance regression gate, and Required status check:

  • Every MSHV run, and runs on hosts with a recorded host type for KVM and WHP.
  • The other microVM scenarios. None reaches the new refusal: those that
    cold-boot nvx run, the egress-policy scenarios and
    filesystem-comma-paths, pass --cmdline 'quiet loglevel=0', and
    command-line-limit boots OpenVMM directly.

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 lists one: run_refusals in
nvx/tests/cli/validation.rs, the table of run refusals that
validation_errors_exit_1_before_any_side_effect checks, gains two cases, a
dry run and a launch of a 1,100-byte --cmdline without shares, which must
exit 1 with --cmdline exceeds the 1024-byte budget before 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.

Copilot AI balanced review requested due to automatic review settings November 28, 2026 03:19
@github-actions github-actions Bot added the tests-modified Changes existing tests, test data, or test wiring label Nov 28, 2026
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

This pull request changes existing tests

It 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

Change What Before After
modified helper fn run_refusals in cli/validation (tests) nvx/tests/cli/validation.rs:883 nvx/tests/cli/validation.rs:883

Relocated unchanged: 0; added: 1. Compared the merge base 895d8f922bec with 4fd50f4c916b.

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 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 from COMMAND_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>
@ppenna
Pedro Henrique Penna (ppenna) force-pushed the agents/issue-2303-cold-run-cmdline-budget branch from 3a238be to 4fd50f4 Compare November 28, 2026 16:20
Copilot AI balanced review requested due to automatic review settings November 28, 2026 16:20

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 block the change enforcing the command-line budget across all cold boots.

No open issues 🎉

Review effort: Balanced

@ppenna
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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests-modified Changes existing tests, test data, or test wiring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nvx: a cold run without --mount accepts a --cmdline beyond the kernel command line's budget, which OpenVMM refuses at every launch

2 participants