Skip to main content

Crate squib_snapshot

Crate squib_snapshot 

Source
Expand description

squib-snapshot — bitcode state file, sparse memory file, dirty-page tracking.

Implements Phase 5 of the squib roadmap. The crate is split into:

  • error — wire-stable SnapshotError (I-RC-8 in 11 § 7).
  • stateMicrovmState and child structs (vCPU, GIC, MMDS, devices).
  • envelopeSnapshot<T> outer container with bitcode + CRC64 trailer.
  • atomic — D25 temp-file + fsync + rename writer with cross-FS pre-flight check.
  • memory — Full / sparse-of-dirty memory-file writer.
  • dirtyBox<[AtomicU64]> dirty bitmap + adaptive heuristic (D11 + D21).
  • save / load — high-level orchestrators that tie the pieces together.

Cross-references: 16-snapshots.md, 10-data-model.md § 5–6, 11-runtime-core. md § 6, 99-key-decisions.md § D5, D11, D21, D25.

§Quality bar

#![forbid(unsafe_code)] — every public surface is safe Rust. The Mach-exception pager that backs --mem-backend=Uffd lives in the sibling squib-host crate where the unsafe is bounded and reviewed.

Re-exports§

pub use atomic::AtomicWriter;
pub use atomic::TEMP_SUFFIX;
pub use atomic::UnlinkOnDrop;
pub use atomic::check_same_filesystem;
pub use atomic::derive_temp_path;
pub use dirty::ADAPTIVE_WINDOW;
pub use dirty::AdaptiveController;
pub use dirty::DEFAULT_STEP_DOWN_THRESHOLD;
pub use dirty::DirtyBitmap;
pub use dirty::TrackedRegion;
pub use dirty::TrackingGranule;
pub use envelope::Crc64Writer;
pub use envelope::SNAPSHOT_DESERIALIZATION_BYTES_LIMIT;
pub use envelope::SNAPSHOT_MAGIC_AARCH64;
pub use envelope::SNAPSHOT_VERSION;
pub use envelope::Snapshot;
pub use envelope::SnapshotHdr;
pub use envelope::arch_magic;
pub use error::Result;
pub use error::SnapshotError;
pub use load::LoadedSnapshot;
pub use load::SnapshotDescription;
pub use load::describe;
pub use load::load;
pub use memory::MemorySnapshotKind;
pub use memory::MemoryWriter;
pub use memory::PageReader;
pub use memory::VecPageReader;
pub use save::SaveReport;
pub use save::SaveRequest;
pub use save::SnapshotKind;
pub use save::save;
pub use state::DeviceState;
pub use state::DeviceStates;
pub use state::FpSimdRegs;
pub use state::GicState;
pub use state::GpRegs;
pub use state::MicrovmState;
pub use state::MmdsState;
pub use state::PsciVcpuState;
pub use state::VcpuState;
pub use state::VmInfo;
pub use vcpu_save::GicRestoreTarget;
pub use vcpu_save::GicSnapshotSource;
pub use vcpu_save::MmdsRestoreTarget;
pub use vcpu_save::MmdsSnapshotSource;
pub use vcpu_save::VcpuRestoreTarget;
pub use vcpu_save::VcpuSnapshotSource;
pub use vcpu_save::capture_vcpu_state;
pub use vcpu_save::normalized_psci_state;
pub use vcpu_save::restore_vcpu_state;

Modules§

atomic
Atomic temp-file + fsync + rename pattern (D25).
dirty
Dirty page tracking — Box<[AtomicU64]> shadow bitmap, adaptive heuristic.
envelope
Snapshot<Data> envelope, header, and CRC64 framing.
error
SnapshotError — wire-stable error variants for the snapshot subsystem.
load
High-level load orchestrator.
memory
Memory file writer / reader — Full dump and sparse-of-dirty.
save
High-level save / load orchestrator.
state
MicrovmState and child types — the snapshot state blob.
vcpu_save
vCPU + GIC capture/restore helpers — the host-portable surface.