@@ -29,7 +29,13 @@ use crate::{new_error, Result};
2929#[ derive( Default ,  Clone ) ]  
3030/// A Wrapper around details of functions exposed by the Host 
3131pub  struct  HostFuncsWrapper  { 
32-     functions_map :  HashMap < String ,  ( HyperlightFunction ,  Option < Vec < ExtraAllowedSyscall > > ) > , 
32+     functions_map :  HashMap < String ,  FunctionEntry > , 
33+ } 
34+ 
35+ #[ derive( Clone ) ]  
36+ pub  struct  FunctionEntry  { 
37+     pub  function :  HyperlightFunction , 
38+     pub  extra_allowed_syscalls :  Option < Vec < ExtraAllowedSyscall > > , 
3339} 
3440
3541impl  HostFuncsWrapper  { 
@@ -86,7 +92,7 @@ impl HostFuncsWrapper {
8692    fn  register_host_function_helper ( 
8793        & mut  self , 
8894        name :  String , 
89-         func :  HyperlightFunction , 
95+         function :  HyperlightFunction , 
9096        extra_allowed_syscalls :  Option < Vec < ExtraAllowedSyscall > > , 
9197    )  -> Result < ( ) >  { 
9298        #[ cfg( not( all( feature = "seccomp" ,  target_os = "linux" ) ) ) ]  
@@ -95,16 +101,24 @@ impl HostFuncsWrapper {
95101                "Extra syscalls are only supported on Linux with seccomp" 
96102            ) ) ; 
97103        } 
98-         self . functions_map 
99-             . insert ( name,  ( func,  extra_allowed_syscalls) ) ; 
104+         self . functions_map . insert ( 
105+             name, 
106+             FunctionEntry  { 
107+                 function, 
108+                 extra_allowed_syscalls, 
109+             } , 
110+         ) ; 
100111        Ok ( ( ) ) 
101112    } 
102113
103114    #[ instrument( err( Debug ) ,  skip_all,  parent = Span :: current( ) ,  level = "Trace" ) ]  
104115    fn  call_host_func_impl ( & self ,  name :  & str ,  args :  Vec < ParameterValue > )  -> Result < ReturnValue >  { 
105116        // Inner function containing the common logic 
106117        let  do_call = || { 
107-             let  ( func,  syscalls)  = self 
118+             let  FunctionEntry  { 
119+                 function, 
120+                 extra_allowed_syscalls, 
121+             }  = self 
108122                . functions_map 
109123                . get ( name) 
110124                . ok_or_else ( || HostFunctionNotFound ( name. to_string ( ) ) ) ?; 
@@ -113,12 +127,12 @@ impl HostFuncsWrapper {
113127            { 
114128                let  seccomp_filter =
115129                    crate :: seccomp:: guest:: get_seccomp_filter_for_host_function_worker_thread ( 
116-                         syscalls . clone ( ) , 
130+                         extra_allowed_syscalls . clone ( ) , 
117131                    ) ?; 
118132                seccompiler:: apply_filter ( & seccomp_filter) ?; 
119133            } 
120134
121-             crate :: metrics:: maybe_time_and_emit_host_call ( name,  || func . call ( args) ) 
135+             crate :: metrics:: maybe_time_and_emit_host_call ( name,  || function . call ( args) ) 
122136        } ; 
123137
124138        if  cfg ! ( all( feature = "seccomp" ,  target_os = "linux" ) )  { 
0 commit comments