@@ -47,14 +47,6 @@ use wasmtime_wasi_threads::WasiThreadsCtx;
4747/// shutting down RawPOSIX, ensuring runtime-wide cleanup happens only after the
4848/// last process terminates.
4949pub fn execute_wasmtime ( lindboot_cli : CliOptions ) -> anyhow:: Result < Vec < Val > > {
50- // -- Initialize the Wasmtime execution environment --
51- let wasm_file_path = Path :: new ( lindboot_cli. wasm_file ( ) ) ;
52- let args = lindboot_cli. args . clone ( ) ;
53- let wt_config = make_wasmtime_config ( lindboot_cli. wasmtime_backtrace ) ;
54- let engine = Engine :: new ( & wt_config) . context ( "failed to create execution engine" ) ?;
55- let host = HostCtx :: default ( ) ;
56- let mut wstore = Store :: new ( & engine, host) ;
57-
5850 // -- Initialize Lind + RawPOSIX + 3i runtime --
5951 // Initialize the Lind cage counter
6052 let lind_manager = Arc :: new ( LindCageManager :: new ( 0 ) ) ;
@@ -75,30 +67,8 @@ pub fn execute_wasmtime(lindboot_cli: CliOptions) -> anyhow::Result<Vec<Val>> {
7567 panic ! ( "[lind-boot] egister syscall handlers (clone/exec/exit) with 3i failed" ) ;
7668 }
7769
78- // -- Load module and attach host APIs --
79- let module = read_wasm_or_cwasm ( & engine, wasm_file_path) ?;
80- let mut linker = Linker :: new ( & engine) ;
81-
82- attach_api (
83- & mut wstore,
84- & mut linker,
85- & module,
86- lind_manager. clone ( ) ,
87- lindboot_cli. clone ( ) ,
88- None ,
89- ) ?;
90-
9170 // -- Run the first module in the first cage --
92- let result = wasmtime_wasi:: runtime:: with_ambient_tokio_runtime ( || {
93- load_main_module (
94- & mut wstore,
95- & mut linker,
96- & module,
97- CAGE_START_ID as u64 ,
98- & args,
99- )
100- . with_context ( || format ! ( "failed to run main module" ) )
101- } ) ;
71+ let result = execute_with_lind ( lindboot_cli, lind_manager. clone ( ) , CAGE_START_ID as u64 ) ;
10272
10373 match result {
10474 Ok ( ref _res) => {
@@ -149,7 +119,7 @@ pub fn execute_with_lind(
149119 & module,
150120 lind_manager. clone ( ) ,
151121 lind_boot. clone ( ) ,
152- Some ( cageid as i32 ) ,
122+ cageid as i32 ,
153123 ) ?;
154124
155125 // -- Run the module in the cage --
@@ -271,7 +241,7 @@ fn attach_api(
271241 module : & Module ,
272242 lind_manager : Arc < LindCageManager > ,
273243 lindboot_cli : CliOptions ,
274- cageid : Option < i32 > ,
244+ cageid : i32 ,
275245) -> Result < ( ) > {
276246 // Initialize argv/environ data and attach all Lind host functions
277247 // (syscall dispatch, debug, signals, and argv/environ) to the linker.
0 commit comments