Skip to content

Commit 3ec69ee

Browse files
committed
Add OCI snapshot persistence
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
1 parent e6991e7 commit 3ec69ee

5 files changed

Lines changed: 1599 additions & 1 deletion

File tree

Cargo.lock

Lines changed: 186 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/hyperlight_host/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ thiserror = "2.0.18"
4949
chrono = { version = "0.4", optional = true }
5050
anyhow = "1.0"
5151
metrics = "0.24.6"
52+
serde = { version = "1.0", features = ["derive"] }
5253
serde_json = "1.0"
5354
elfcore = { version = "2.0", optional = true }
5455
uuid = { version = "1.23.1", features = ["v4"] }
56+
oci-spec = { version = "0.8", default-features = false, features = ["image"] }
57+
sha2 = "0.10"
58+
hex = "0.4"
5559

5660
[target.'cfg(windows)'.dependencies]
5761
windows = { version = "0.62", features = [
@@ -83,7 +87,6 @@ mshv-ioctls = { version = "0.6", optional = true}
8387
[dev-dependencies]
8488
uuid = { version = "1.23.1", features = ["v4"] }
8589
signal-hook-registry = "1.4.8"
86-
serde = "1.0"
8790
iced-x86 = { version = "1.21", default-features = false, features = ["std", "code_asm"] }
8891
proptest = "1.11.0"
8992
tempfile = "3.27.0"

src/hyperlight_host/src/sandbox/initialized_multi_use.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,20 @@ impl MultiUseSandbox {
188188
/// # Ok(())
189189
/// # }
190190
/// ```
191+
///
192+
/// From a snapshot loaded from disk:
193+
///
194+
/// ```no_run
195+
/// # use std::sync::Arc;
196+
/// # use hyperlight_host::{HostFunctions, MultiUseSandbox};
197+
/// # use hyperlight_host::sandbox::snapshot::Snapshot;
198+
/// # fn example() -> Result<(), Box<dyn std::error::Error>> {
199+
/// let snapshot = Arc::new(Snapshot::from_oci("./guest_snapshot", "latest")?);
200+
/// let mut sandbox = MultiUseSandbox::from_snapshot(snapshot, HostFunctions::default(), None)?;
201+
/// let result: String = sandbox.call("Echo", "hello".to_string())?;
202+
/// # Ok(())
203+
/// # }
204+
/// ```
191205
#[instrument(err(Debug), skip_all, parent = Span::current(), level = "Trace")]
192206
pub fn from_snapshot(
193207
snapshot: Arc<Snapshot>,

0 commit comments

Comments
 (0)