@@ -121,49 +121,6 @@ pub(super) fn get_guest_log_filter(guest_max_log_level: Option<LevelFilter>) ->
121121 GuestLogFilter :: from ( guest_log_level_filter) . into ( )
122122}
123123
124- /// Represents a Hyperlight Virtual Machine instance.
125- ///
126- /// This struct manages the lifecycle of the VM, including:
127- /// - The underlying hypervisor implementation (e.g., KVM, MSHV, WHP).
128- /// - Memory management, including initial sandbox regions and dynamic mappings.
129- /// - The vCPU execution loop and handling of VM exits (I/O, MMIO, interrupts).
130- pub ( crate ) struct HyperlightVm {
131- #[ cfg( gdb) ]
132- pub ( super ) vm : Box < dyn DebuggableVm > ,
133- #[ cfg( not( gdb) ) ]
134- pub ( super ) vm : Box < dyn VirtualMachine > ,
135- pub ( super ) page_size : usize ,
136- pub ( super ) entrypoint : NextAction , // only present if this vm has not yet been initialised
137- pub ( super ) rsp_gva : u64 ,
138- pub ( super ) interrupt_handle : Arc < dyn InterruptHandleImpl > ,
139-
140- pub ( super ) next_slot : u32 , // Monotonically increasing slot number
141- pub ( super ) freed_slots : Vec < u32 > , // Reusable slots from unmapped regions
142-
143- pub ( super ) snapshot_slot : u32 ,
144- // The current snapshot region, used to keep it alive as long as
145- // it is used & when unmapping
146- pub ( super ) snapshot_memory : Option < GuestSharedMemory > ,
147- pub ( super ) scratch_slot : u32 , // The slot number used for the scratch region
148- // The current scratch region, used to keep it alive as long as it
149- // is used & when unmapping
150- pub ( super ) scratch_memory : Option < GuestSharedMemory > ,
151-
152- pub ( super ) mmap_regions : Vec < ( u32 , MemoryRegion ) > , // Later mapped regions (slot number, region)
153-
154- pub ( super ) pending_tlb_flush : bool ,
155-
156- #[ cfg( gdb) ]
157- pub ( super ) gdb_conn : Option < DebugCommChannel < DebugResponse , DebugMsg > > ,
158- #[ cfg( gdb) ]
159- pub ( super ) sw_breakpoints : HashMap < u64 , u8 > , // addr -> original instruction
160- #[ cfg( feature = "mem_profile" ) ]
161- pub ( super ) trace_info : MemTraceInfo ,
162- #[ cfg( crashdump) ]
163- pub ( super ) rt_cfg : SandboxRuntimeConfig ,
164- }
165-
166-
167124/// DispatchGuestCall error
168125#[ derive( Debug , thiserror:: Error ) ]
169126pub enum DispatchGuestCallError {
@@ -395,6 +352,49 @@ pub enum HyperlightVmError {
395352 #[ error( "Access page table error: {0}" ) ]
396353 AccessPageTable ( #[ from] AccessPageTableError ) ,
397354}
355+
356+ /// Represents a Hyperlight Virtual Machine instance.
357+ ///
358+ /// This struct manages the lifecycle of the VM, including:
359+ /// - The underlying hypervisor implementation (e.g., KVM, MSHV, WHP).
360+ /// - Memory management, including initial sandbox regions and dynamic mappings.
361+ /// - The vCPU execution loop and handling of VM exits (I/O, MMIO, interrupts).
362+ pub ( crate ) struct HyperlightVm {
363+ #[ cfg( gdb) ]
364+ pub ( super ) vm : Box < dyn DebuggableVm > ,
365+ #[ cfg( not( gdb) ) ]
366+ pub ( super ) vm : Box < dyn VirtualMachine > ,
367+ pub ( super ) page_size : usize ,
368+ pub ( super ) entrypoint : NextAction , // only present if this vm has not yet been initialised
369+ pub ( super ) rsp_gva : u64 ,
370+ pub ( super ) interrupt_handle : Arc < dyn InterruptHandleImpl > ,
371+
372+ pub ( super ) next_slot : u32 , // Monotonically increasing slot number
373+ pub ( super ) freed_slots : Vec < u32 > , // Reusable slots from unmapped regions
374+
375+ pub ( super ) snapshot_slot : u32 ,
376+ // The current snapshot region, used to keep it alive as long as
377+ // it is used & when unmapping
378+ pub ( super ) snapshot_memory : Option < GuestSharedMemory > ,
379+ pub ( super ) scratch_slot : u32 , // The slot number used for the scratch region
380+ // The current scratch region, used to keep it alive as long as it
381+ // is used & when unmapping
382+ pub ( super ) scratch_memory : Option < GuestSharedMemory > ,
383+
384+ pub ( super ) mmap_regions : Vec < ( u32 , MemoryRegion ) > , // Later mapped regions (slot number, region)
385+
386+ pub ( super ) pending_tlb_flush : bool ,
387+
388+ #[ cfg( gdb) ]
389+ pub ( super ) gdb_conn : Option < DebugCommChannel < DebugResponse , DebugMsg > > ,
390+ #[ cfg( gdb) ]
391+ pub ( super ) sw_breakpoints : HashMap < u64 , u8 > , // addr -> original instruction
392+ #[ cfg( feature = "mem_profile" ) ]
393+ pub ( super ) trace_info : MemTraceInfo ,
394+ #[ cfg( crashdump) ]
395+ pub ( super ) rt_cfg : SandboxRuntimeConfig ,
396+ }
397+
398398impl HyperlightVm {
399399 /// Map a region of host memory into the sandbox.
400400 ///
0 commit comments