@@ -64,7 +64,7 @@ use hyperlight_host::func::Registerable;
6464use hyperlight_host:: sandbox:: snapshot:: Snapshot ;
6565use hyperlight_host:: sandbox:: uninitialized:: GuestEnvironment ;
6666use hyperlight_host:: sandbox:: SandboxConfiguration ;
67- use hyperlight_host:: { GuestBinary , MultiUseSandbox , UninitializedSandbox } ;
67+ use hyperlight_host:: { GuestBinary , HostFunctions , MultiUseSandbox , UninitializedSandbox } ;
6868use std:: collections:: HashMap ;
6969use std:: path:: Path ;
7070use std:: sync:: Arc ;
@@ -1402,22 +1402,25 @@ impl Sandbox {
14021402 pub fn from_snapshot_file_with < P : AsRef < Path > > ( path : P , preopens : & [ Preopen ] ) -> Result < Self > {
14031403 let loaded = Snapshot :: from_file_unchecked ( path. as_ref ( ) ) ?;
14041404 let arc = Arc :: new ( loaded) ;
1405- let mut inner = MultiUseSandbox :: from_snapshot ( arc. clone ( ) ) ?;
14061405
1407- // Wire up the fs_* tool handlers against the caller's preopens.
1408- // The snapshot was warmed up with hostfs already mounted, so the
1409- // guest will route fs_* calls through __dispatch → the FsRouter
1410- // we install here.
1406+ let mut host_funcs = HostFunctions :: default ( ) ;
14111407 if !preopens. is_empty ( ) {
14121408 if let Some ( tools) = build_tools ( None , preopens) ? {
14131409 let tools = Arc :: new ( tools) ;
14141410 let tools_ref = tools. clone ( ) ;
1415- inner. register_host_function ( "__dispatch" , move |payload : Vec < u8 > | -> Vec < u8 > {
1416- tools_ref. dispatch ( & payload)
1417- } ) ?;
1411+ host_funcs
1412+ . register_host_function ( "__dispatch" , move |payload : Vec < u8 > | -> Vec < u8 > {
1413+ tools_ref. dispatch ( & payload)
1414+ } ) ?;
14181415 }
1416+ } else {
1417+ host_funcs. register_host_function ( "__dispatch" , |_payload : Vec < u8 > | -> Vec < u8 > {
1418+ Vec :: new ( )
1419+ } ) ?;
14191420 }
14201421
1422+ let inner = MultiUseSandbox :: from_snapshot ( arc. clone ( ) , host_funcs, None ) ?;
1423+
14211424 Ok ( Self {
14221425 inner,
14231426 snapshot : Some ( arc) ,
0 commit comments