Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions docs/snapshot-oci-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@ Only a snapshot taken after the guest has run can be persisted. Such a
snapshot carries the captured vCPU registers needed to resume a call.
`Snapshot::save` rejects a pre-init snapshot.

`Snapshot::compact(None)` packs live memory pages into a single layer.
`Snapshot::compact(Some(&base))` retains referenced immutable layers identical
to the base and packs other live pages into at most one new layer. Base matching
uses the layer's address, geometry, and complete blob contents, so a separately
loaded base works too. The base must have the same memory layout.

Compaction leaves its inputs unchanged and preserves execution state, metadata,
transport state, page-table topology, and cached hashes of retained layers.
Repacked memory gets a fresh hash on its first ordinary save.
Packed layers are placed to preserve the loader's guest-code GPA-span bound
without keeping unused code bytes. If retained base layers alone fall short
and all live pages are already retained, one zero-filled host page supplies
the required span.
It does not change the file format:
save and restore the result normally. Saving includes every required blob,
including preserved base blobs; omitting or sharing those blobs during transport
is the caller's responsibility. Compaction copies live non-base pages and is
explicit rather than automatically performed on every snapshot.

[OCI Image Layout]: https://github.com/opencontainers/image-spec/blob/main/image-layout.md

## Directory layout
Expand Down
2 changes: 1 addition & 1 deletion src/hyperlight_host/src/mem/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ use crate::error::HyperlightError::{MemoryRequestTooBig, MemoryRequestTooSmall};
use crate::sandbox::SandboxConfiguration;
use crate::{Result, new_error};

#[derive(Copy, Clone)]
#[derive(Copy, Clone, PartialEq, Eq)]
pub(crate) struct SandboxMemoryLayout {
/// The size of the guest code section.
code_size: usize,
Expand Down
2 changes: 1 addition & 1 deletion src/hyperlight_host/src/mem/virtq/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub(crate) fn create_consumers(
}

/// Validated ring images excluded from ordinary snapshot pages.
#[derive(Debug, PartialEq, Eq)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub(crate) struct VirtqSnapshot {
/// Guest-to-host ring bytes.
g2h_ring: Vec<u8>,
Expand Down
Loading
Loading