Open
Description
In practice, sandbox evolution seems to unify two fairly disparate things:
- the transition from an uninitialized sandbox to an initialized one that in practice is not customized
- the evolution of a MultiUseSandbox to have a new snapshot on the top of its stack.
We should probably worth think about whether or not this is worth keeping.
From the hello-world example:
- 1
let mut uninitialized_sandbox = UninitializedSandbox::new(
hyperlight_host::GuestBinary::FilePath(
hyperlight_testing::simple_guest_as_string().unwrap(),
),
None, // default configuration
None, // default run options
None, // default host print function
)?;
// Register a host functions
fn sleep_5_secs() -> hyperlight_host::Result<()> {
thread::sleep(std::time::Duration::from_secs(5));
Ok(())
}
let host_function = Arc::new(Mutex::new(sleep_5_secs));
host_function.register(&mut uninitialized_sandbox, "Sleep5Secs")?;
- 2
// Initialize sandbox to be able to call host functions
let mut multi_use_sandbox: MultiUseSandbox = uninitialized_sandbox.evolve(Noop::default())?
// Call guest function
let message = "Hello, World! I am executing inside of a VM :)\n".to_string();
let result = multi_use_sandbox.call_guest_function_by_name(
"PrintOutput", // function must be defined in the guest binary
ReturnType::Int,
Some(vec![ParameterValue::String(message.clone())]),
);
Metadata
Metadata
Assignees
Type
Projects
Status
No status