Skip to content
Merged
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
4 changes: 2 additions & 2 deletions host/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ name = "pyhl"
path = "src/bin/pyhl.rs"

[dependencies]
# hyperlight-dev/hyperlight#1373 — Ludvig's Snapshot::to_file/from_file
# Uses PAGE_READONLY mapping (no host commit charge per VM).
hyperlight-host = { git = "https://github.com/hyperlight-dev/hyperlight", branch = "disk_snapshot_copy", features = ["executable_heap", "hw-interrupts"] }
# danbugs/hyperlight perf/whp-warm-start — snapshot file support + WHP warm-start optimizations.
hyperlight-host = { git = "https://github.com/danbugs/hyperlight", rev = "5cf37d92", features = ["executable_heap", "hw-interrupts", "whp-no-surrogate"] }
clap = { version = "4", features = ["derive", "env"] }
anyhow = "1"
memmap2 = "0.9"
Expand Down
24 changes: 8 additions & 16 deletions host/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2008,10 +2008,9 @@ pub struct Sandbox {
inner: MultiUseSandbox,
/// Post-init snapshot for fast restore between calls.
snapshot: Option<Arc<Snapshot>>,
/// File mapping to re-register after snapshot restore.
/// Snapshot restore unmaps all non-snapshot regions.
/// When set, restore uses the preserving variant to keep the
/// read-only file mapping alive across restores.
file_mapping_path: Option<std::path::PathBuf>,
file_mapping_base: u64,
exit_code: Arc<AtomicI32>,
/// Shared socket table — cleared on [`Sandbox::restore`] so that
/// host-side fds don't leak across guest restore cycles.
Expand Down Expand Up @@ -2247,7 +2246,7 @@ impl Sandbox {
tools_ref.dispatch(&payload)
})?;

Self::finish_evolve(usbox, None, 0, exit_code, sleep_cancel, socket_table)
Self::finish_evolve(usbox, None, exit_code, sleep_cancel, socket_table)
}

/// Low-level: boot with a zero-copy mapped initrd file. Prefer the builder.
Expand Down Expand Up @@ -2304,7 +2303,6 @@ impl Sandbox {
Self::finish_evolve(
usbox,
initrd_path.map(|p| p.to_path_buf()),
INITRD_MAP_BASE,
exit_code,
sleep_cancel,
socket_table,
Expand All @@ -2314,7 +2312,6 @@ impl Sandbox {
fn finish_evolve(
usbox: UninitializedSandbox,
file_mapping_path: Option<std::path::PathBuf>,
file_mapping_base: u64,
exit_code: Arc<AtomicI32>,
sleep_cancel: SleepCancel,
socket_table: Option<Arc<Mutex<SocketTable>>>,
Expand All @@ -2325,7 +2322,6 @@ impl Sandbox {
inner,
snapshot,
file_mapping_path,
file_mapping_base,
exit_code,
socket_table,
sleep_cancel,
Expand All @@ -2338,15 +2334,12 @@ impl Sandbox {
/// guest memory to the state captured after init.
pub fn restore(&mut self) -> Result<()> {
if let Some(ref snap) = self.snapshot {
self.inner.restore(snap.clone())?;
}
// Re-register file mapping after restore (snapshot restore
// unmaps all non-snapshot regions including file mappings)
if let Some(ref path) = self.file_mapping_path {
self.inner
.map_file_cow(path, self.file_mapping_base, Some("initrd"))?;
if self.file_mapping_path.is_some() {
self.inner.restore_preserving_file_mappings(snap.clone())?;
} else {
self.inner.restore(snap.clone())?;
}
}
// Close leaked host-side sockets the guest "forgot" about.
if let Some(ref table) = self.socket_table {
table.lock().unwrap().clear();
}
Expand Down Expand Up @@ -2543,7 +2536,6 @@ impl Sandbox {
inner,
snapshot: Some(arc),
file_mapping_path: initrd,
file_mapping_base: INITRD_MAP_BASE,
exit_code,
socket_table,
sleep_cancel,
Expand Down
Loading