@@ -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
@@ -668,7 +678,12 @@ impl Hypervisor for HypervLinuxDriver {
668678 outb_handle_fn
669679 . try_lock ( )
670680 . map_err ( |e| new_error ! ( "Error locking at {}:{}: {}" , file!( ) , line!( ) , e) ) ?
671- . call ( port, val) ?;
681+ . call (
682+ #[ cfg( feature = "trace_guest" ) ]
683+ self ,
684+ port,
685+ val,
686+ ) ?;
672687
673688 // update rip
674689 self . vcpu_fd . set_reg ( & [ hv_register_assoc {
@@ -1164,6 +1179,8 @@ mod tests {
11641179 #[ cfg( crashdump) ]
11651180 guest_core_dump : true ,
11661181 } ,
1182+ #[ cfg( feature = "trace_guest" ) ]
1183+ TraceInfo :: new ( ) . unwrap ( ) ,
11671184 )
11681185 . unwrap ( ) ;
11691186 }
0 commit comments