Skip to content

Commit adce75e

Browse files
committed
Add SandboxBuilder
`SandboxBuilder` is the entry point for creating a sandbox. It gathers machine configuration, host functions, init data and memory mappings, then builds a `MultiUseSandbox` from a guest binary on disk, a guest binary in memory, or a snapshot. It merges the roles of `SandboxConfiguration`, `GuestEnvironment` and `UninitializedSandbox` into a single type, so all three can become implementation details. Every setting has an in place accessor taking `&mut self` and a `with_*` counterpart consuming `self` for chaining. Machine configuration values are readable through `get_*`. `map_memory_region` is `unsafe`, matching `MultiUseSandbox::map_region`. The mapped region must stay valid for the lifetime of the built sandbox. `build_from_snapshot` errors when `init_data` or `max_guest_log_level` are set, as a snapshot already carries both.
1 parent 52ba62c commit adce75e

5 files changed

Lines changed: 539 additions & 1 deletion

File tree

src/hyperlight_host/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ pub use hypervisor::virtual_machine::is_hypervisor_present;
9191
pub use sandbox::MultiUseSandbox;
9292
/// The re-export for the `UninitializedSandbox` type
9393
pub use sandbox::UninitializedSandbox;
94+
/// The re-export for the `SandboxBuilder` type
95+
pub use sandbox::builder::SandboxBuilder;
9496
/// A collection of host functions that can be supplied to a sandbox
9597
/// constructor (e.g. [`MultiUseSandbox::from_snapshot`]).
9698
pub use sandbox::host_funcs::HostFunctions;

0 commit comments

Comments
 (0)