mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-12-23 16:43:24 +03:00
commit
7b86d2971e
@ -89,6 +89,7 @@ async fn handle_kernel_request(
|
||||
reverse_cap_index: &mut t::ReverseCapIndex,
|
||||
caps_oracle: t::CapMessageSender,
|
||||
engine: &Engine,
|
||||
home_directory_path: &str,
|
||||
) {
|
||||
let t::Message::Request(request) = km.message else {
|
||||
return;
|
||||
@ -274,6 +275,7 @@ async fn handle_kernel_request(
|
||||
},
|
||||
reboot: false,
|
||||
},
|
||||
&home_directory_path,
|
||||
)
|
||||
.await
|
||||
{
|
||||
@ -580,6 +582,7 @@ async fn start_process(
|
||||
engine: &Engine,
|
||||
caps_oracle: t::CapMessageSender,
|
||||
process_metadata: &StartProcessMetadata,
|
||||
home_directory_path: &str,
|
||||
) -> Result<()> {
|
||||
let (send_to_process, recv_in_process) =
|
||||
mpsc::channel::<Result<t::KernelMessage, t::WrappedSendError>>(PROCESS_CHANNEL_CAPACITY);
|
||||
@ -622,6 +625,7 @@ async fn start_process(
|
||||
km_blob_bytes,
|
||||
caps_oracle,
|
||||
engine.clone(),
|
||||
home_directory_path.to_string(),
|
||||
)),
|
||||
);
|
||||
|
||||
@ -786,6 +790,7 @@ pub async fn kernel(
|
||||
&engine,
|
||||
caps_oracle_sender.clone(),
|
||||
&metadata,
|
||||
home_directory_path.as_str(),
|
||||
)
|
||||
.await
|
||||
{
|
||||
@ -1090,6 +1095,7 @@ pub async fn kernel(
|
||||
&mut reverse_cap_index,
|
||||
caps_oracle_sender.clone(),
|
||||
&engine,
|
||||
&home_directory_path,
|
||||
).await;
|
||||
} else {
|
||||
// pass message to appropriate runtime module or process
|
||||
|
@ -8,11 +8,15 @@ pub use lib::Process;
|
||||
use ring::signature::{self, KeyPair};
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use std::sync::Arc;
|
||||
use tokio::fs;
|
||||
use tokio::task::JoinHandle;
|
||||
use wasmtime::component::ResourceTable as Table;
|
||||
use wasmtime::component::*;
|
||||
use wasmtime::{Engine, Store};
|
||||
use wasmtime_wasi::preview2::{pipe::MemoryOutputPipe, WasiCtx, WasiCtxBuilder, WasiView};
|
||||
use wasmtime_wasi::preview2::{
|
||||
pipe::MemoryOutputPipe, DirPerms, FilePerms, WasiCtx, WasiCtxBuilder, WasiView,
|
||||
};
|
||||
use wasmtime_wasi::sync::Dir;
|
||||
|
||||
const STACK_TRACE_SIZE: usize = 5000;
|
||||
|
||||
@ -493,6 +497,7 @@ pub async fn make_process_loop(
|
||||
wasm_bytes: Vec<u8>,
|
||||
caps_oracle: t::CapMessageSender,
|
||||
engine: Engine,
|
||||
home_directory_path: String,
|
||||
) -> Result<()> {
|
||||
// before process can be instantiated, need to await 'run' message from kernel
|
||||
let mut pre_boot_queue = Vec::<Result<t::KernelMessage, t::WrappedSendError>>::new();
|
||||
@ -536,7 +541,31 @@ pub async fn make_process_loop(
|
||||
|
||||
let table = Table::new();
|
||||
let wasi_stderr = MemoryOutputPipe::new(STACK_TRACE_SIZE);
|
||||
let wasi = WasiCtxBuilder::new().stderr(wasi_stderr.clone()).build();
|
||||
|
||||
let tmp_path = format!(
|
||||
"{}/vfs/{}:{}/tmp",
|
||||
home_directory_path,
|
||||
metadata.our.process.package(),
|
||||
metadata.our.process.publisher()
|
||||
);
|
||||
if let Err(e) = fs::create_dir_all(&tmp_path).await {
|
||||
panic!("failed creating tmp dir! {:?}", e);
|
||||
}
|
||||
let Ok(wasi_tempdir) =
|
||||
Dir::open_ambient_dir(tmp_path.clone(), wasmtime_wasi::sync::ambient_authority())
|
||||
else {
|
||||
panic!("failed to open ambient tmp dir!");
|
||||
};
|
||||
let wasi = WasiCtxBuilder::new()
|
||||
.preopened_dir(
|
||||
wasi_tempdir,
|
||||
DirPerms::all(),
|
||||
FilePerms::all(),
|
||||
tmp_path.clone(),
|
||||
)
|
||||
.env("TEMP_DIR", tmp_path)
|
||||
.stderr(wasi_stderr.clone())
|
||||
.build();
|
||||
|
||||
wasmtime_wasi::preview2::command::add_to_linker(&mut linker).unwrap();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user