Skip to content

Relax layout requirements for MultiUseSandbox::restore - #1728

Open
ludfjig wants to merge 5 commits into
ll/snapshot-restore-transactionfrom
ll/snapshot-restore-layout-compatibility
Open

Relax layout requirements for MultiUseSandbox::restore#1728
ludfjig wants to merge 5 commits into
ll/snapshot-restore-transactionfrom
ll/snapshot-restore-layout-compatibility

Conversation

@ludfjig

@ludfjig ludfjig commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

This makes it possible to restore snapshots from different guest binaries and memory layouts into a sandbox, provided the registered host functions are compatible.

@ludfjig ludfjig changed the title snapshot restore layout compatibility Relax layout requirements for MultiUseSandbox::restore Aug 12, 2026
@ludfjig ludfjig added the kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. label Aug 12, 2026
@ludfjig
ludfjig force-pushed the ll/snapshot-restore-layout-compatibility branch from 2074b7b to 2150200 Compare August 12, 2026 18:11
@ludfjig
ludfjig force-pushed the ll/snapshot-restore-layout-compatibility branch 2 times, most recently from afdbb20 to d4e7519 Compare August 12, 2026 23:08
@ludfjig
ludfjig force-pushed the ll/snapshot-restore-layout-compatibility branch from d4e7519 to f0fa0c2 Compare August 13, 2026 19:46
@ludfjig
ludfjig force-pushed the ll/snapshot-restore-layout-compatibility branch 2 times, most recently from 3518a13 to a110461 Compare August 13, 2026 21:38
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
@ludfjig
ludfjig force-pushed the ll/snapshot-restore-layout-compatibility branch from a110461 to 8297af8 Compare August 13, 2026 22:44
@ludfjig
ludfjig marked this pull request as ready for review August 13, 2026 23:20
@ludfjig
ludfjig requested a review from danbugs as a code owner August 13, 2026 23:20
Copilot AI lite review requested due to automatic review settings August 13, 2026 23: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.

Pull request overview

This PR relaxes MultiUseSandbox::restore compatibility rules so snapshots can be restored across different guest binaries and sandbox memory layouts, as long as the target sandbox’s registered host functions satisfy the snapshot’s requirements.

Changes:

  • Remove layout-compatibility validation from snapshot restore, and drop the SnapshotLayoutMismatch error path.
  • Update restore to fully reset VM mappings during restore and clear crashdump state that would otherwise refer to the pre-restore guest.
  • Add/expand tests covering cross-guest restore (WIT/Rust/C) and cross-layout restore, including persisted snapshots with non-default layouts.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/hyperlight_host/tests/wit_test.rs Adds integration tests restoring WIT snapshots over Rust/C guests and vice-versa.
src/hyperlight_host/src/sandbox/snapshot/mod.rs Removes Snapshot::validate_compatibility (layout + host funcs) helper.
src/hyperlight_host/src/sandbox/snapshot/file_tests.rs Adds persisted non-default layout test; updates restore semantics comment.
src/hyperlight_host/src/sandbox/initialized_multi_use.rs Implements relaxed restore (host-func-only validation) and remaps/unmaps regions during restore; updates docs/tests.
src/hyperlight_host/src/mem/layout.rs Removes SandboxMemoryLayout::is_compatible_with and its tests.
src/hyperlight_host/src/hypervisor/hyperlight_vm/mod.rs Adds clear_crashdump_binary_path for post-restore crashdump correctness.
src/hyperlight_host/src/error.rs Removes HyperlightError::SnapshotLayoutMismatch variant.
CHANGELOG.md Notes the new restore flexibility.
Suppressed comments (1)

src/hyperlight_host/src/sandbox/initialized_multi_use.rs:469

  • restore now unmaps all VM regions returned by self.vm.get_mapped_regions() before applying the snapshot. The rustdoc for restore does not mention that mappings created via map_region / map_file_cow will be removed, which is a user-visible behavior change and can surprise callers relying on those mappings persisting across restores.
    /// signature). Extras on the sandbox are allowed. The registry
    /// itself is left unchanged. A mismatch returns
    /// [`SnapshotHostFunctionMismatch`](crate::HyperlightError::SnapshotHostFunctionMismatch)
    /// carrying the missing names and signature differences.
    ///

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread CHANGELOG.md
MSRs, on MSHV and WHP this is not enforced. by @ludfjig in https://github.com/hyperlight-dev/hyperlight/pull/991
* **Breaking:** Filesystem paths are now represented using `PathBuf`. `GuestBinary::FilePath` now stores a `PathBuf` instead of a `String`, and `MultiUseSandbox::generate_crashdump_to_dir` accepts `Into<PathBuf>` instead of `Into<String>`. Callers passing a `String` to `GuestBinary::FilePath` must convert it using `.into()`.
* Deprecate `MultiUseSandbox::poisoned` in favor of `MultiUseSandbox::status().is_poisoned()`.
* `MultiUseSandbox::restore` has been made more flexible and now accepts snapshots from any guest binary or memory layout when host functions are compatible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement For PRs adding features, improving functionality, docs, tests, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants