Repository navigation
host: make a capture one value, which names its snapshots - #1275
Pedro Henrique Penna (ppenna) merged 1 commit into
Conversation
This pull request changes existing testsIt modifies or removes 2 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: 1; added: 11. Compared the merge base |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the capture-configuration API and shared-type changes.
No open issues 🎉
What changed in this PR
This PR advances #1097 by adding a caller-owned CaptureConfig to NVX’s VM configuration API. It validates capture settings without host access and derives a stable identity for naming snapshots.
Changes:
- Adds capture configuration, resource capacities, disk geometry checks, and SHA-256 capture identities.
- Moves shared invariant and geometry types into
host::config, preserving existing template exports. - Adds validation and identity tests, updates documentation, and records the new public API on both platforms.
| File | Description |
|---|---|
nvx-rs/src/host/template/manifest/tests.rs |
Relocates geometry validation cases to configuration tests. |
nvx-rs/src/host/template/manifest.rs |
Uses shared processor counts and relocated geometry validation. |
nvx-rs/src/host/template/key/tests.rs |
Moves invariant-setting tests to their new owning module. |
nvx-rs/src/host/template/key.rs |
Re-exports invariants while retaining their canonical encoding. |
nvx-rs/src/host/sandbox/geometry.rs |
Re-exports the relocated block geometry type. |
nvx-rs/src/host/mod.rs |
Documents capture configuration and snapshot identities. |
nvx-rs/src/host/config/tests.rs |
Tests capture validation, identity inputs, serialization, and exclusions. |
nvx-rs/src/host/config/mod.rs |
Implements capture configuration, validation, identities, and shared types. |
nvx-rs/README.md |
Explains the capture API and identity contract. |
nvx-rs/public-api/windows.txt |
Records the added Windows public API items. |
nvx-rs/public-api/linux.txt |
Records the added Linux public API items. |
Review effort: Balanced
|
Scope update following the revised #1076/#1097 contract: new host APIs return the crate's
Adapt this PR with the updated #1270 stack and remove the obsolete error ancestor. Earlier validation keeps its recorded-head labels; revised code/input and error-kind changes need affected checks and reviews before current-design readiness. No Ready transition or manual CI dispatch is included. |
9bc10d2 to
b6cd20c
Compare
1c8feca to
240dfc8
Compare
b6cd20c to
cf70f88
Compare
cf70f88 to
12717eb
Compare
240dfc8 to
0cb43ea
Compare
12717eb to
d9cf939
Compare
Add CaptureConfig, the disk geometries, processor and memory capacities, and opaque invariant settings that a capture adds to its VM configuration. Boot holds an optional capture, and VmConfig::check checks it with the rest of the configuration. CaptureConfig::check is pure and returns the crate's Unsupported errors for invalid capacities and disk geometries. CaptureConfig::identity names equivalent snapshots with a deterministic SHA-256 identity. It includes the supplied runtime identities and contract versions, hypervisor and CPU-profile request, capture disks and capacities, invariants, effective NIC address, console, export presence and boot line. It excludes paths, launch options, the restore view and network policy, the VM's duplicate resource fields, and every root detail: the supported fresh capture is blockless. Identity calculation reads nothing on the host; later VM creation owns the fresh-capture root and export refusals. Move Invariants and BlockGeometry, preserving invariant limits and the template manifest's geometry checks. Keep their existing template exports and invariant encoding. Move the invariant test unchanged, move the three manifest geometry cases to configuration tests, and cover capture checks, identity inclusions and exclusions, and checking a boot's capture. Document the value API and update both public-API snapshots. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 678335a1-aaee-4d19-8433-1b25301f5e65
0cb43ea to
b5c0eb9
Compare
1790d3f
into
feature/nvx-refactor
Closes #1097. Stacked on #1270.
What and why
SL2.3c: a capture is one value, which names its snapshots.
Boot::captureholds aCaptureConfig: fresh disk geometries, processor andmemory boot values and capacities, and opaque invariants.
DiskCaptureisnon-exhaustive; its supported variant is
Fresh { image, scratch }.CaptureConfig::checkperforms value-only checks, without host I/O. Processorboot values and capacities must be 1, 2, 4 or 8, with boot no greater than
capacity. Memory at boot must be nonzero; its capacity must cover it and be
aligned to 128 MiB. Disk geometries and invariants retain their existing checks.
Refusals use the crate's single
Error/Resultcontract andUnsupported.VmConfig::checkalso checks its boot's capture and preserves its error.CaptureConfig::identityreturns aCaptureIdentity, displayed and serializedas 64 lowercase hexadecimal digits. Its domain-separated, length-prefixed
SHA-256 encoding includes runtime identity and contract versions, hypervisor
and requested CPU profile, capture geometries, processor and memory capacities,
invariants, effective NIC address, console, export presence and boot command
line. An omitted NIC address equals the explicit default.
Identity excludes paths, launch options, view and network policy, the VM's
separate processor and memory settings, and every root setting. Computing it
reads nothing on the host and does not create, validate or store a snapshot.
InvariantsandBlockGeometrymove intohost::config, together with theexisting invariant, geometry and processor checks. Existing template paths
remain available through re-exports. Both public API snapshots and the host
documentation describe the new configuration values.
Size
283 core lines in 4 counted files, within the 500-line cap. The change is one
logical commit; it retains both the root-independent identity and the boot
capture check.
Tests
The change carries
tests-modified. Existing test changes are:configurations_pass_with_or_without_a_nic_address_and_a_bootaddscapture: Noneto its twoBootvalues; its assertions are unchanged.manifests_of_invalid_machines_are_refusedmoves three geometry cases(logical block size 256, physical block size 256, and length 1000) to the
direct configuration test
block_geometries_hold_whole_blocks_of_power_of_two_sizes,retaining their expected messages.
invariant_settings_have_one_formmoves unchanged withInvariants.The test-change checker reports eleven added tests. Focused configuration
coverage includes supported and refused capacities and geometries, invariant
limits, checking a boot's capture through
VmConfig::check, identity text andserialization, every identifying input, omitted versus explicit default NIC,
and exclusion of all launch, clone and root settings.
Validation
At
240dfc814c3840cae379db7b1ca85f2710a2eaad, the complete applicable commandsfrom
check-nvx-rsandvalidate-nvxpassed on Windows and Linux, andcheck-qualitypassed on Linux. The full CLI unit commands ran 1810 tests oneach platform, with the expected platform skips (67 on Windows, 30 on Linux).
The focused configuration tests passed 13 of 13.
On both WHP and MSHV, the complete default Alpine suite passed all 50 selected
scenarios (56 execution records across 1, 2, 4 and 8 processors), the required
Ubuntu and Azure Linux sets passed 6 and 7 scenarios, and the complete canonical
runtime-adapter suite passed 156 scenarios in 11 targets, with no failed or
ignored scenarios. The canonical VM drivers used the actual hash-verified test
runners built at this head; their inventory and selectors were unchanged.