@@ -72,6 +72,8 @@ use crate::HyperlightError;
7272use crate :: mem:: memory_region:: { MemoryRegion , MemoryRegionFlags } ;
7373use crate :: mem:: ptr:: { GuestPtr , RawPtr } ;
7474use crate :: sandbox:: SandboxConfiguration ;
75+ #[ cfg( feature = "trace_guest" ) ]
76+ use crate :: sandbox:: TraceInfo ;
7577#[ cfg( crashdump) ]
7678use crate :: sandbox:: uninitialized:: SandboxRuntimeConfig ;
7779use crate :: { Result , log_then_return, new_error} ;
@@ -311,6 +313,9 @@ pub(crate) struct HypervLinuxDriver {
311313 gdb_conn : Option < DebugCommChannel < DebugResponse , DebugMsg > > ,
312314 #[ cfg( crashdump) ]
313315 rt_cfg : SandboxRuntimeConfig ,
316+ #[ cfg( feature = "trace_guest" ) ]
317+ #[ allow( dead_code) ]
318+ trace_info : TraceInfo ,
314319}
315320
316321impl HypervLinuxDriver {
@@ -322,6 +327,8 @@ impl HypervLinuxDriver {
322327 /// the underlying virtual CPU after this function returns. Call the
323328 /// `apply_registers` method to do that, or more likely call
324329 /// `initialise` to do it for you.
330+ #[ allow( clippy:: too_many_arguments) ]
331+ // TODO: refactor this function to take fewer arguments. Add trace_info to rt_cfg
325332 #[ instrument( skip_all, parent = Span :: current( ) , level = "Trace" ) ]
326333 pub ( crate ) fn new (
327334 mem_regions : Vec < MemoryRegion > ,
@@ -331,6 +338,7 @@ impl HypervLinuxDriver {
331338 config : & SandboxConfiguration ,
332339 #[ cfg( gdb) ] gdb_conn : Option < DebugCommChannel < DebugResponse , DebugMsg > > ,
333340 #[ cfg( crashdump) ] rt_cfg : SandboxRuntimeConfig ,
341+ #[ cfg( feature = "trace_guest" ) ] trace_info : TraceInfo ,
334342 ) -> Result < Self > {
335343 let mshv = Mshv :: new ( ) ?;
336344 let pr = Default :: default ( ) ;
@@ -438,6 +446,8 @@ impl HypervLinuxDriver {
438446 gdb_conn,
439447 #[ cfg( crashdump) ]
440448 rt_cfg,
449+ #[ cfg( feature = "trace_guest" ) ]
450+ trace_info,
441451 } ;
442452
443453 // Send the interrupt handle to the GDB thread if debugging is enabled
@@ -646,7 +656,12 @@ impl Hypervisor for HypervLinuxDriver {
646656 outb_handle_fn
647657 . try_lock ( )
648658 . map_err ( |e| new_error ! ( "Error locking at {}:{}: {}" , file!( ) , line!( ) , e) ) ?
649- . call ( port, val) ?;
659+ . call (
660+ #[ cfg( feature = "trace_guest" ) ]
661+ self ,
662+ port,
663+ val,
664+ ) ?;
650665
651666 // update rip
652667 self . vcpu_fd . set_reg ( & [ hv_register_assoc {
@@ -1142,6 +1157,8 @@ mod tests {
11421157 #[ cfg( crashdump) ]
11431158 guest_core_dump : true ,
11441159 } ,
1160+ #[ cfg( feature = "trace_guest" ) ]
1161+ TraceInfo :: new ( ) . unwrap ( ) ,
11451162 )
11461163 . unwrap ( ) ;
11471164 }
0 commit comments