Skip to content

Commit d99d24b

Browse files
committed
update uses of call_guest_function_by_name with run
Signed-off-by: Jorge Prendes <[email protected]>
1 parent ebcd758 commit d99d24b

File tree

16 files changed

+94
-93
lines changed

16 files changed

+94
-93
lines changed

fuzz/fuzz_targets/host_print.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fuzz_target!(
2727

2828
|data: String| -> Corpus {
2929
let mut sandbox = SANDBOX.get().unwrap().lock().unwrap();
30-
let len: i32 = sandbox.call_guest_function_by_name::<i32>(
30+
let len: i32 = sandbox.run::<i32>(
3131
"PrintOutput",
3232
data,
3333
)

src/hyperlight_host/benches/benchmarks.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
use criterion::{Criterion, criterion_group, criterion_main};
1818
use hyperlight_host::GuestBinary;
1919
use hyperlight_host::sandbox::{
20-
Callable, MultiUseSandbox, SandboxConfiguration, UninitializedSandbox,
20+
MultiUseSandbox, SandboxConfiguration, UninitializedSandbox,
2121
};
2222
use hyperlight_testing::simple_guest_as_string;
2323

@@ -38,7 +38,7 @@ fn guest_call_benchmark(c: &mut Criterion) {
3838
group.bench_function("guest_call", |b| {
3939
let mut sbox = create_multiuse_sandbox();
4040

41-
b.iter(|| sbox.call::<String>("Echo", "hello\n".to_string()).unwrap());
41+
b.iter(|| sbox.run::<String>("Echo", "hello\n".to_string()).unwrap());
4242
});
4343

4444
// Benchmarks a single guest function call.
@@ -48,7 +48,7 @@ fn guest_call_benchmark(c: &mut Criterion) {
4848
let snapshot = sbox.snapshot().unwrap();
4949

5050
b.iter(|| {
51-
sbox.call::<String>("Echo", "hello\n".to_string()).unwrap();
51+
sbox.run::<String>("Echo", "hello\n".to_string()).unwrap();
5252
sbox.restore(&snapshot).unwrap();
5353
});
5454
});
@@ -67,7 +67,7 @@ fn guest_call_benchmark(c: &mut Criterion) {
6767

6868
b.iter(|| {
6969
multiuse_sandbox
70-
.call::<i32>("Add", (1_i32, 41_i32))
70+
.run::<i32>("Add", (1_i32, 41_i32))
7171
.unwrap()
7272
});
7373
});
@@ -99,7 +99,7 @@ fn guest_call_benchmark_large_param(c: &mut Criterion) {
9999

100100
b.iter(|| {
101101
sandbox
102-
.call_guest_function_by_name::<()>(
102+
.run::<()>(
103103
"LargeParameters",
104104
(large_vec.clone(), large_string.clone()),
105105
)

src/hyperlight_host/examples/func_ctx/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ fn main() {
3030
// Do several calls against a sandbox running the `simpleguest.exe` binary,
3131
// and print their results
3232
let res: String = sbox
33-
.call_guest_function_by_name("Echo", "hello".to_string())
33+
.run("Echo", "hello".to_string())
3434
.unwrap();
3535
println!("got Echo res: {res}");
3636

3737
let res: i32 = sbox
38-
.call_guest_function_by_name("CallMalloc", 200_i32)
38+
.run("CallMalloc", 200_i32)
3939
.unwrap();
4040
println!("got CallMalloc res: {res}");
4141
}

src/hyperlight_host/examples/guest-debugging/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fn main() -> hyperlight_host::Result<()> {
7575
let message =
7676
"Hello, World! I am executing inside of a VM with debugger attached :)\n".to_string();
7777
multi_use_sandbox_dbg
78-
.call_guest_function_by_name::<i32>(
78+
.run::<i32>(
7979
"PrintOutput", // function must be defined in the guest binary
8080
message.clone(),
8181
)
@@ -84,7 +84,7 @@ fn main() -> hyperlight_host::Result<()> {
8484
let message =
8585
"Hello, World! I am executing inside of a VM without debugger attached :)\n".to_string();
8686
multi_use_sandbox
87-
.call_guest_function_by_name::<i32>(
87+
.run::<i32>(
8888
"PrintOutput", // function must be defined in the guest binary
8989
message.clone(),
9090
)

src/hyperlight_host/examples/hello-world/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ fn main() -> hyperlight_host::Result<()> {
4040
// Call guest function
4141
let message = "Hello, World! I am executing inside of a VM :)\n".to_string();
4242
multi_use_sandbox
43-
.call_guest_function_by_name::<i32>(
43+
.run::<i32>(
4444
"PrintOutput", // function must be defined in the guest binary
4545
message,
4646
)

src/hyperlight_host/examples/logging/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn main() -> Result<()> {
5050
// Call a guest function 5 times to generate some log entries.
5151
for _ in 0..5 {
5252
multiuse_sandbox
53-
.call_guest_function_by_name::<String>("Echo", "a".to_string())
53+
.run::<String>("Echo", "a".to_string())
5454
.unwrap();
5555
}
5656

@@ -61,7 +61,7 @@ fn main() -> Result<()> {
6161
// Call a guest function that calls the HostPrint host function 5 times to generate some log entries.
6262
for _ in 0..5 {
6363
multiuse_sandbox
64-
.call_guest_function_by_name::<i32>("PrintOutput", msg.clone())
64+
.run::<i32>("PrintOutput", msg.clone())
6565
.unwrap();
6666
}
6767
Ok(())
@@ -95,7 +95,7 @@ fn main() -> Result<()> {
9595
for _ in 0..NUM_CALLS {
9696
barrier.wait();
9797
multiuse_sandbox
98-
.call_guest_function_by_name::<()>("Spin", ())
98+
.run::<()>("Spin", ())
9999
.unwrap_err();
100100
}
101101
thread.join().unwrap();

src/hyperlight_host/examples/metrics/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn do_hyperlight_stuff() {
6161
// Call a guest function 5 times to generate some metrics.
6262
for _ in 0..5 {
6363
multiuse_sandbox
64-
.call_guest_function_by_name::<String>("Echo", "a".to_string())
64+
.run::<String>("Echo", "a".to_string())
6565
.unwrap();
6666
}
6767

@@ -72,7 +72,7 @@ fn do_hyperlight_stuff() {
7272
// Call a guest function that calls the HostPrint host function 5 times to generate some metrics.
7373
for _ in 0..5 {
7474
multiuse_sandbox
75-
.call_guest_function_by_name::<i32>("PrintOutput", msg.clone())
75+
.run::<i32>("PrintOutput", msg.clone())
7676
.unwrap();
7777
}
7878
Ok(())
@@ -109,7 +109,7 @@ fn do_hyperlight_stuff() {
109109
for _ in 0..NUM_CALLS {
110110
barrier.wait();
111111
multiuse_sandbox
112-
.call_guest_function_by_name::<()>("Spin", ())
112+
.run::<()>("Spin", ())
113113
.unwrap_err();
114114
}
115115

src/hyperlight_host/examples/tracing-chrome/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn main() -> Result<()> {
3636

3737
// do the function call
3838
let current_time = std::time::Instant::now();
39-
let res: String = sbox.call_guest_function_by_name("Echo", "Hello, World!".to_string())?;
39+
let res: String = sbox.run("Echo", "Hello, World!".to_string())?;
4040
let elapsed = current_time.elapsed();
4141
println!("Function call finished in {:?}.", elapsed);
4242
assert_eq!(res, "Hello, World!");

src/hyperlight_host/examples/tracing-otlp/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ fn run_example(wait_input: bool) -> HyperlightResult<()> {
136136
// Call a guest function 5 times to generate some log entries.
137137
for _ in 0..5 {
138138
multiuse_sandbox
139-
.call_guest_function_by_name::<String>("Echo", "a".to_string())
139+
.run::<String>("Echo", "a".to_string())
140140
.unwrap();
141141
}
142142

@@ -147,7 +147,7 @@ fn run_example(wait_input: bool) -> HyperlightResult<()> {
147147
// Call a guest function that calls the HostPrint host function 5 times to generate some log entries.
148148
for _ in 0..5 {
149149
multiuse_sandbox
150-
.call_guest_function_by_name::<i32>("PrintOutput", msg.clone())
150+
.run::<i32>("PrintOutput", msg.clone())
151151
.unwrap();
152152
}
153153

@@ -180,7 +180,7 @@ fn run_example(wait_input: bool) -> HyperlightResult<()> {
180180
let _entered = span.enter();
181181
barrier.wait();
182182
multiuse_sandbox
183-
.call_guest_function_by_name::<()>("Spin", ())
183+
.run::<()>("Spin", ())
184184
.unwrap_err();
185185
}
186186
thread.join().expect("Thread panicked");

src/hyperlight_host/examples/tracing-tracy/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn main() -> Result<()> {
4242

4343
// do the function call
4444
let current_time = std::time::Instant::now();
45-
let res: String = sbox.call_guest_function_by_name("Echo", "Hello, World!".to_string())?;
45+
let res: String = sbox.run("Echo", "Hello, World!".to_string())?;
4646
let elapsed = current_time.elapsed();
4747
println!("Function call finished in {:?}.", elapsed);
4848
assert_eq!(res, "Hello, World!");

0 commit comments

Comments
 (0)