Repository navigation
nvx-rs: split the host's oversized files into directory modules #898
Description
Parent: #896. Needs: #897: the artifacts split includes the helpers that #897 moves there, and its guard protects the layering.
Goal. Split host's oversized files into directory modules along their existing sections, with no public API change and no test-name change. Inline mod tests blocks move to X/tests.rs and keep their module path.
Today (dev 6af32ba0), the candidates, in production lines without their inline tests:
| File | Production lines | Inline test lines | Open PRs that edit it |
|---|---|---|---|
filesystem.rs |
2,041 | 1,685 | #864, #876, #885 |
platform/windows.rs |
1,468 | 358 | #881, #885, #887 |
sandbox/mount.rs |
1,190 | 0 | none |
instance.rs |
1,036 | 212 | #886 |
cli/sandbox/lifecycle.rs |
996 | 118 | #886 |
store/mod.rs |
987 | 0 | #881, #885, #886, #888 |
cli/sandbox/mod.rs |
941 | 0 | none |
network/mod.rs |
928 | 988 | none |
artifacts.rs |
919 | 727 | none |
supervisor/mod.rs |
703 | 0 | #886, #887, #888 |
platform/linux.rs |
680 | 49 | #881, #885, #887 |
sandbox/plan.rs (853 lines) stays whole: its form already lives in plan/form.rs, and #884 and #888 extend it.
Splits. Today's line ranges, in nvx-rs/src/host/:
filesystem.rs → filesystem/:
mod.rs: the constants and types (filesystem.rs:48-221and284-375),planand the checks of its mappings (377-755), the root checks thatplanandExportPlan::checkshare (1241-1316), andMapped(1935-1949).guest_path.rs:guest_source,guest_pathandresolve_guest_path(222-282), andwithinanddepth(1951-1964).policy.rs: the resolution of access policies, fromPolicyPaththroughwritable_part(757-1239).verify.rs:ExportPlan::{check, verify, kernel_token, guest_table, openvmm_arguments}, their helpers, and the accessors ofExportChild(1318-1783).limits.rs:check_root,check_policy_pathsandpolicy_limits(1785-1901).host_path.rs:is_reparse_point,identityandrelative_text(1903-1933), andcanonicalize,canonicalize_lenient,strip_verbatimanddisplay_path(1966-2040).tests.rs:2042-3726.
platform/windows.rs → platform/windows/, and platform/linux.rs → platform/linux/:
| Module | platform/windows.rs |
platform/linux.rs |
|---|---|---|
mod.rs |
SUPPORTED and the handle helpers (67-100), probe_hypervisor (802-853) |
The constants (19-38), probe_hypervisor (348-361) |
process.rs |
creation_time through BOOT_ID_KEY (102-348) |
process_start_time through boot_id (40-286) |
spawn.rs |
LaunchedProcess through append_argument (350-800) |
detach, inherit_only and allowlist (288-346) |
private.rs |
Private directories and their ACLs, create_private_dir through set_access (855-1161) |
Private directories and their modes, create_private_dir through open_plain_dir (363-501) |
identity.rs |
File identities and the log claim (1163-1230) |
File identities and the log claim (503-550) |
endpoint.rs |
The control endpoint and PipeTransport (1232-1433) |
The control endpoint and UnixTransport (552-679) |
interrupt.rs |
INTERRUPTED through interrupted, feature cli (1435-1467) |
None |
tests.rs |
1469-1826 |
681-729 |
platform/mod.rs keeps its surface, pub(crate) use imp::* and pub use imp::{SUPPORTED, create_private_dir, file_identity, process_start_time} (platform/mod.rs:27-35), so each mod.rs re-exports its submodules' items. #[allow(unsafe_code)] stays on mod windows (platform/mod.rs:22-25), and covers its submodules.
artifacts.rs → artifacts/:
mod.rs:Artifactsand its discovery (artifacts.rs:45-361), and the constants of the layouts and their metadata (363-390).guest.rs:Guest(392-490).dir.rs:LayoutandArtifactDir(492-769), andArtifactPathsandGuestPaths(878-918).identity.rs:sha256_identity,read_metadataandprovenance_identity(771-869).require.rs:required(871-876), and the helpers that nvx-rs: make the host module's dependency graph acyclic #897 moves toartifacts.tests.rs:920-1646. The module keeps its name, so that the bundling step'sartifactsfilter still selects these tests.
instance.rs → instance/:
mod.rs:generate_capabilityand the helpers of launches and sessions (instance.rs:207-279),Foundand its states (281-399), andInstance(401-606).files.rs: the private-file helpers (84-205), with the publicwrite_private,write_json,read_json,remove_if_presentandremove_interrupted_writes.locked.rs:LockedInstanceandcheck_timeout(608-869).execution.rs:OutputSink,WorkloadOutcomeandExecution(871-1035).tests.rs:1037-1248.
network/mod.rs, into new files beside it:
rule.rs:Access(network/mod.rs:55-72),ProtocolthroughEgressRules(111-331), andparse_rulesandparse_rule(785-836).loopback.rs:HostLoopback(74-109),ForwardProtocolandLoopbackForward(333-391), andcheck_loopback_forwards(838-916).proxy.rs:ProxySchemeandNetworkProxy(393-525).arguments.rs:openvmm_arguments,proxy_argumentsandcheck_proxy_only(613-783), andguest_subnet(918-927).tests.rs:929-1916.NetworkPolicy(527-611) and the constants (40-53) stay inmod.rs. The existingnetwork::policysubmodule holds the egress policy files, notNetworkPolicy.
sandbox/mount.rs → sandbox/mount/, which holds its tests.rs already:
mod.rs: the constants, and the access, owner, kind and policy types (mount.rs:42-252).request.rs: the parsing and checks of mount values and targets (254-369), andSandboxMount(371-725).host_paths.rs:HostQueriesthroughcheck_distinct_host_paths(727-870).aggregate.rs:aggregate_child_namethroughplan_mounts_with(872-999).boot.rs:BootShares,boot_sharesand the command-line fragments (1001-1187).
store/mod.rs, whose first 211 lines are the module's documentation:
names.rs:FORMATand the file names (store/mod.rs:246-281).locked.rs:LockedStore(589-866).launch.rs:end_process,RecoveryandLaunch(868-987).SandboxStoreand its helpers stay inmod.rs.
supervisor/mod.rs:
launch.rs:launch,abandon_afterandStarting(supervisor/mod.rs:116-323).vmm.rs:Vmm,StopOutcome,Stopped, and the stop and terminate steps (325-598).reattach.rs:Reattached,reattachandreattach_with(600-703).
cli/sandbox/lifecycle.rs → cli/sandbox/lifecycle/:
mod.rs: the configuration,provision,find_vmand the lookups of running VMs (lifecycle.rs:85-101and342-500).directory.rs: the state directory (103-204).outcome.rs: the outcome files (206-340).start.rs:startthroughexec_workload(502-834).stop.rs:stopthroughdeprovision(836-995).tests.rs:997-1114.
cli/sandbox/mod.rs:
options.rs: the parser,SYNTAXthroughsandbox_network(cli/sandbox/mod.rs:59-523).one_shot.rs:run_openvmm,OneShot,end_interruptedandspawn_error(811-938).
Rules:
- One file per PR, or per commit.
- Rename a file that becomes
X/mod.rswithgit mv, in a commit of its own, before splitting it, so thatgit log --followand blame follow it. - Private helpers shared across the new siblings become
pub(super). Public items are re-exported frommod.rs. - Moved intra-doc links that use
super::getcrate::paths (nvx-rs: break the host module into finer-grained modules #896, invariant 6). A submodule named after an item of its parent (filesystem::guest_path,supervisor::launch, and the CLI'sstartandstop) makes the links to that item ambiguous (filesystem.rs:19and287,supervisor/mod.rs:13,cli/sandbox/lifecycle.rs:26-50), so they takefn@. - Duplicated helpers are not merged (nvx-rs: break the host module into finer-grained modules #896).
- A file that open PRs edit waits until they land.
network/mod.rs,artifacts.rs,cli/sandbox/mod.rsandsandbox/mount.rscan go first.
Acceptance, per split: zero public API diff (#896, invariant 1), an identical cargo test -- --list on Linux and Windows, the guard green, and CI green.
Activity