Skip to content

Commit 49d5a53

Browse files
committed
feat(virtq): use virtq for capi ret error
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
1 parent 611f197 commit 49d5a53

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

src/hyperlight_guest/src/virtq/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ impl GuestContext {
313313
self.generation
314314
}
315315

316-
fn try_send(
316+
fn try_send_readonly(
317317
&mut self,
318318
header: &[u8],
319319
payload: &[u8],

src/hyperlight_guest_capi/src/error.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use core::ffi::{CStr, c_char};
1919
use flatbuffers::FlatBufferBuilder;
2020
use hyperlight_common::flatbuffer_wrappers::function_types::FunctionCallResult;
2121
use hyperlight_common::flatbuffer_wrappers::guest_error::{ErrorCode, GuestError};
22-
use hyperlight_guest_bin::GUEST_HANDLE;
2322

2423
use crate::alloc::borrow::ToOwned;
2524

@@ -35,12 +34,11 @@ pub extern "C" fn hl_set_error(err: ErrorCode, message: *const c_char) {
3534
let fcr = FunctionCallResult::new(guest_error);
3635
let mut builder = FlatBufferBuilder::new();
3736
let data = fcr.encode(&mut builder);
38-
unsafe {
39-
#[allow(static_mut_refs)] // we are single threaded
40-
GUEST_HANDLE
41-
.push_shared_output_data(data)
42-
.expect("Failed to set error")
43-
}
37+
38+
hyperlight_guest::virtq::with_context(|ctx| {
39+
ctx.send_h2g_result(data)
40+
.expect("Failed to send error via virtq");
41+
});
4442
}
4543

4644
#[unsafe(no_mangle)]

0 commit comments

Comments
 (0)