diff --git a/src/hyperlight_host/src/hypervisor/crashdump.rs b/src/hyperlight_host/src/hypervisor/crashdump.rs index 44ba0891b..b821fba5f 100644 --- a/src/hyperlight_host/src/hypervisor/crashdump.rs +++ b/src/hyperlight_host/src/hypervisor/crashdump.rs @@ -295,10 +295,10 @@ pub(crate) fn generate_crashdump( if let Ok(nbytes) = checked_core_dump(ctx, create_dump_file) { if nbytes > 0 { println!("Core dump created successfully: {}", file_path); - log::error!("Core dump file: {}", file_path); + tracing::error!("Core dump file: {}", file_path); } } else { - log::error!("Failed to create core dump file"); + tracing::error!("Failed to create core dump file"); } Ok(()) @@ -331,7 +331,7 @@ fn core_dump_file_path(dump_dir: Option) -> String { if std::path::Path::new(&dump_dir).exists() { std::path::PathBuf::from(dump_dir) } else { - log::warn!( + tracing::warn!( "Directory \"{}\" does not exist, falling back to temp directory", dump_dir ); @@ -366,7 +366,7 @@ fn checked_core_dump( // If the HV returned a context it means we can create a core dump // This is the case when the sandbox has been configured at runtime to allow core dumps if let Some(ctx) = ctx { - log::info!("Creating core dump file..."); + tracing::info!("Creating core dump file..."); // Set up data sources for the core dump let guest_view = GuestView::new(&ctx); diff --git a/src/hyperlight_host/src/hypervisor/gdb/arch.rs b/src/hyperlight_host/src/hypervisor/gdb/arch.rs index 88bd0182d..b2ebb82a3 100644 --- a/src/hyperlight_host/src/hypervisor/gdb/arch.rs +++ b/src/hyperlight_host/src/hypervisor/gdb/arch.rs @@ -94,7 +94,7 @@ pub(crate) fn vcpu_stop_reason( } // Log an error and provide internal debugging info - log::error!( + tracing::error!( r"The vCPU exited because of an unknown reason: rip: {:?} dr6: {:?} diff --git a/src/hyperlight_host/src/hypervisor/gdb/event_loop.rs b/src/hyperlight_host/src/hypervisor/gdb/event_loop.rs index 69dec3407..bc7c9fd14 100644 --- a/src/hyperlight_host/src/hypervisor/gdb/event_loop.rs +++ b/src/hyperlight_host/src/hypervisor/gdb/event_loop.rs @@ -54,7 +54,7 @@ impl run_blocking::BlockingEventLoop for GdbBlockingEventLoop { loop { match target.try_recv() { Ok(DebugResponse::VcpuStopped(stop_reason)) => { - log::debug!("VcpuStopped with reason {:?}", stop_reason); + tracing::debug!("VcpuStopped with reason {:?}", stop_reason); // Resume execution if unknown reason for stop let stop_response = match stop_reason { @@ -73,7 +73,7 @@ impl run_blocking::BlockingEventLoop for GdbBlockingEventLoop { signal: Signal(signals::SIGSEGV as u8), }, VcpuStopReason::Unknown => { - log::warn!("Unknown stop reason received"); + tracing::warn!("Unknown stop reason received"); // Marking as a SwBreak so the gdb inspect where/why it stopped BaseStopReason::SwBreak(()) @@ -83,7 +83,7 @@ impl run_blocking::BlockingEventLoop for GdbBlockingEventLoop { return Ok(run_blocking::Event::TargetStopped(stop_response)); } Ok(msg) => { - log::error!("Unexpected message received {:?}", msg); + tracing::error!("Unexpected message received {:?}", msg); } Err(crossbeam_channel::TryRecvError::Empty) => (), Err(crossbeam_channel::TryRecvError::Disconnected) => { @@ -112,13 +112,13 @@ impl run_blocking::BlockingEventLoop for GdbBlockingEventLoop { fn on_interrupt( target: &mut Self::Target, ) -> Result, ::Error> { - log::info!("Received interrupt from GDB client - sending signal to target thread"); + tracing::info!("Received interrupt from GDB client - sending signal to target thread"); // Send a signal to the target thread to interrupt it let res = target.interrupt_vcpu(); if !res { - log::error!("Failed to send signal to target thread"); + tracing::error!("Failed to send signal to target thread"); return Err(GdbTargetError::SendSignalError); } @@ -133,21 +133,21 @@ pub(crate) fn event_loop_thread( match debugger.run_blocking::(target) { Ok(disconnect_reason) => match disconnect_reason { DisconnectReason::Disconnect => { - log::info!("Gdb client disconnected"); + tracing::info!("Gdb client disconnected"); if let Err(e) = target.disable_debug() { - log::error!("Cannot disable debugging: {:?}", e); + tracing::error!("Cannot disable debugging: {:?}", e); } } DisconnectReason::TargetExited(_) => { - log::info!("Guest finalized execution and disconnected"); + tracing::info!("Guest finalized execution and disconnected"); } DisconnectReason::TargetTerminated(sig) => { - log::info!("Gdb target terminated with signal {}", sig) + tracing::info!("Gdb target terminated with signal {}", sig) } - DisconnectReason::Kill => log::info!("Gdb sent a kill command"), + DisconnectReason::Kill => tracing::info!("Gdb sent a kill command"), }, Err(e) => { - log::error!("fatal error encountered: {e:?}"); + tracing::error!("fatal error encountered: {e:?}"); } } } diff --git a/src/hyperlight_host/src/hypervisor/gdb/mod.rs b/src/hyperlight_host/src/hypervisor/gdb/mod.rs index 6ef5a3322..d8e2fd262 100644 --- a/src/hyperlight_host/src/hypervisor/gdb/mod.rs +++ b/src/hyperlight_host/src/hypervisor/gdb/mod.rs @@ -125,7 +125,7 @@ impl DebugMemoryAccess { let mem_offset = (gpa as usize) .checked_sub(SandboxMemoryLayout::BASE_ADDRESS) .ok_or_else(|| { - log::warn!( + tracing::warn!( "gpa={:#X} causes subtract with underflow: \"gpa - BASE_ADDRESS={:#X}-{:#X}\"", gpa, gpa, @@ -138,11 +138,11 @@ impl DebugMemoryAccess { let mut region_found = false; for reg in self.guest_mmap_regions.iter() { if reg.guest_region.contains(&mem_offset) { - log::debug!("Found mapped region containing {:X}: {:#?}", gpa, reg); + tracing::debug!("Found mapped region containing {:X}: {:#?}", gpa, reg); // Region found - calculate the offset within the region let region_offset = mem_offset.checked_sub(reg.guest_region.start).ok_or_else(|| { - log::warn!( + tracing::warn!( "Cannot calculate offset in memory region: mem_offset={:#X}, base={:#X}", mem_offset, reg.guest_region.start, @@ -177,7 +177,7 @@ impl DebugMemoryAccess { } else { (&mut mgr.shared_mem, mem_offset, "snapshot") }; - log::debug!( + tracing::debug!( "No mapped region found containing {:X}. Trying {} memory at offset {:X} ...", gpa, name, @@ -208,7 +208,7 @@ impl DebugMemoryAccess { let mem_offset = (gpa as usize) .checked_sub(SandboxMemoryLayout::BASE_ADDRESS) .ok_or_else(|| { - log::warn!( + tracing::warn!( "gpa={:#X} causes subtract with underflow: \"gpa - BASE_ADDRESS={:#X}-{:#X}\"", gpa, gpa, @@ -221,11 +221,11 @@ impl DebugMemoryAccess { let mut region_found = false; for reg in self.guest_mmap_regions.iter() { if reg.guest_region.contains(&mem_offset) { - log::debug!("Found mapped region containing {:X}: {:#?}", gpa, reg); + tracing::debug!("Found mapped region containing {:X}: {:#?}", gpa, reg); // Region found - calculate the offset within the region let region_offset = mem_offset.checked_sub(reg.guest_region.start).ok_or_else(|| { - log::warn!( + tracing::warn!( "Cannot calculate offset in memory region: mem_offset={:#X}, base={:#X}", mem_offset, reg.guest_region.start, @@ -260,7 +260,7 @@ impl DebugMemoryAccess { } else { (&mut mgr.shared_mem, mem_offset, "snapshot") }; - log::debug!( + tracing::debug!( "No mapped region found containing {:X}. Trying {} memory at offset {:X} ...", gpa, name, @@ -415,14 +415,14 @@ pub(crate) fn create_gdb_thread( let (gdb_conn, hyp_conn) = DebugCommChannel::unbounded(); let socket = format!("localhost:{}", port); - log::info!("Listening on {:?}", socket); + tracing::info!("Listening on {:?}", socket); let listener = TcpListener::bind(socket)?; - log::info!("Starting GDB thread"); + tracing::info!("Starting GDB thread"); let _handle = thread::Builder::new() .name("GDB handler".to_string()) .spawn(move || -> Result<(), GdbTargetError> { - log::info!("Waiting for GDB connection ... "); + tracing::info!("Waiting for GDB connection ... "); let (conn, _) = listener.accept()?; let conn: Box> = Box::new(conn); @@ -433,7 +433,7 @@ pub(crate) fn create_gdb_thread( // Waits for vCPU to stop at entrypoint breakpoint let msg = target.recv()?; if let DebugResponse::InterruptHandle(handle) = msg { - log::info!("Received interrupt handle: {:?}", handle); + tracing::info!("Received interrupt handle: {:?}", handle); target.set_interrupt_handle(handle); } else { return Err(GdbTargetError::UnexpectedMessage); diff --git a/src/hyperlight_host/src/hypervisor/gdb/x86_64_target.rs b/src/hyperlight_host/src/hypervisor/gdb/x86_64_target.rs index 7ba38fc48..f5950039b 100644 --- a/src/hyperlight_host/src/hypervisor/gdb/x86_64_target.rs +++ b/src/hyperlight_host/src/hypervisor/gdb/x86_64_target.rs @@ -77,18 +77,18 @@ impl HyperlightSandboxTarget { /// Sends an event to the Hypervisor that tells it to resume vCPU execution /// Note: The method waits for a confirmation message pub(crate) fn resume_vcpu(&mut self) -> Result<(), GdbTargetError> { - log::info!("Resume vCPU execution"); + tracing::info!("Resume vCPU execution"); match self.send_command(DebugMsg::Continue)? { DebugResponse::Continue => Ok(()), DebugResponse::NotAllowed => { - log::error!("Action not allowed at this time, crash might have occurred"); + tracing::error!("Action not allowed at this time, crash might have occurred"); // This is a consequence of the target crashing or being in an invalid state // we cannot continue execution, but we can still read registers and memory Ok(()) } msg => { - log::error!("Unexpected message received: {:?}", msg); + tracing::error!("Unexpected message received: {:?}", msg); Err(GdbTargetError::UnexpectedMessage) } } @@ -103,16 +103,16 @@ impl HyperlightSandboxTarget { /// and continue executing /// Note: The method waits for a confirmation message pub(crate) fn disable_debug(&mut self) -> Result<(), GdbTargetError> { - log::info!("Disable debugging and resume execution"); + tracing::info!("Disable debugging and resume execution"); match self.send_command(DebugMsg::DisableDebug)? { DebugResponse::DisableDebug => Ok(()), DebugResponse::ErrorOccurred => { - log::error!("Error occurred"); + tracing::error!("Error occurred"); Err(GdbTargetError::UnexpectedError) } msg => { - log::error!("Unexpected message received: {:?}", msg); + tracing::error!("Unexpected message received: {:?}", msg); Err(GdbTargetError::UnexpectedMessage) } } @@ -123,7 +123,7 @@ impl HyperlightSandboxTarget { if let Some(handle) = &self.interrupt_handle { handle.kill_from_debugger() } else { - log::warn!("No interrupt handle set, cannot interrupt vCPU"); + tracing::warn!("No interrupt handle set, cannot interrupt vCPU"); false } @@ -156,7 +156,7 @@ impl SingleThreadBase for HyperlightSandboxTarget { gva: ::Usize, data: &mut [u8], ) -> TargetResult { - log::debug!("Read addr: {:X} len: {:X}", gva, data.len()); + tracing::debug!("Read addr: {:X} len: {:X}", gva, data.len()); match self.send_command(DebugMsg::ReadAddr(gva, data.len()))? { DebugResponse::ReadAddr(v) => { @@ -165,11 +165,11 @@ impl SingleThreadBase for HyperlightSandboxTarget { Ok(v.len()) } DebugResponse::ErrorOccurred => { - log::error!("Error occurred"); + tracing::error!("Error occurred"); Err(TargetError::NonFatal) } msg => { - log::error!("Unexpected message received: {:?}", msg); + tracing::error!("Unexpected message received: {:?}", msg); Err(TargetError::Fatal(GdbTargetError::UnexpectedMessage)) } } @@ -180,23 +180,23 @@ impl SingleThreadBase for HyperlightSandboxTarget { gva: ::Usize, data: &[u8], ) -> TargetResult<(), Self> { - log::debug!("Write addr: {:X} len: {:X}", gva, data.len()); + tracing::debug!("Write addr: {:X} len: {:X}", gva, data.len()); let v = Vec::from(data); match self.send_command(DebugMsg::WriteAddr(gva, v))? { DebugResponse::WriteAddr => Ok(()), DebugResponse::NotAllowed => { - log::error!("Action not allowed at this time, crash might have occurred"); + tracing::error!("Action not allowed at this time, crash might have occurred"); // This is a consequence of the target crashing or being in an invalid state // we cannot continue execution, but we can still read registers and memory Ok(()) } DebugResponse::ErrorOccurred => { - log::error!("Error occurred"); + tracing::error!("Error occurred"); Err(TargetError::NonFatal) } msg => { - log::error!("Unexpected message received: {:?}", msg); + tracing::error!("Unexpected message received: {:?}", msg); Err(TargetError::Fatal(GdbTargetError::UnexpectedMessage)) } } @@ -206,7 +206,7 @@ impl SingleThreadBase for HyperlightSandboxTarget { &mut self, regs: &mut ::Registers, ) -> TargetResult<(), Self> { - log::debug!("Read regs"); + tracing::debug!("Read regs"); match self.send_command(DebugMsg::ReadRegisters)? { DebugResponse::ReadRegisters(boxed_regs) => { @@ -236,12 +236,12 @@ impl SingleThreadBase for HyperlightSandboxTarget { Ok(()) } DebugResponse::ErrorOccurred => { - log::error!("Error occurred"); + tracing::error!("Error occurred"); Err(TargetError::NonFatal) } msg => { - log::error!("Unexpected message received: {:?}", msg); + tracing::error!("Unexpected message received: {:?}", msg); Err(TargetError::Fatal(GdbTargetError::UnexpectedMessage)) } } @@ -251,7 +251,7 @@ impl SingleThreadBase for HyperlightSandboxTarget { &mut self, regs: &::Registers, ) -> TargetResult<(), Self> { - log::debug!("Write regs"); + tracing::debug!("Write regs"); let common_regs = CommonRegisters { rax: regs.regs[0], @@ -291,17 +291,17 @@ impl SingleThreadBase for HyperlightSandboxTarget { ))))? { DebugResponse::WriteRegisters => Ok(()), DebugResponse::NotAllowed => { - log::error!("Action not allowed at this time, crash might have occurred"); + tracing::error!("Action not allowed at this time, crash might have occurred"); // This is a consequence of the target crashing or being in an invalid state // we cannot continue execution, but we can still read registers and memory Ok(()) } DebugResponse::ErrorOccurred => { - log::error!("Error occurred"); + tracing::error!("Error occurred"); Err(TargetError::NonFatal) } msg => { - log::error!("Unexpected message received: {:?}", msg); + tracing::error!("Unexpected message received: {:?}", msg); Err(TargetError::Fatal(GdbTargetError::UnexpectedMessage)) } } @@ -314,7 +314,7 @@ impl SingleThreadBase for HyperlightSandboxTarget { impl SectionOffsets for HyperlightSandboxTarget { fn get_section_offsets(&mut self) -> Result::Usize>, Self::Error> { - log::debug!("Get section offsets"); + tracing::debug!("Get section offsets"); match self.send_command(DebugMsg::GetCodeSectionOffset)? { DebugResponse::GetCodeSectionOffset(text) => Ok(Offsets::Segments { @@ -322,11 +322,11 @@ impl SectionOffsets for HyperlightSandboxTarget { data_seg: None, }), DebugResponse::ErrorOccurred => { - log::error!("Error occurred"); + tracing::error!("Error occurred"); Err(GdbTargetError::UnexpectedError) } msg => { - log::error!("Unexpected message received: {:?}", msg); + tracing::error!("Unexpected message received: {:?}", msg); Err(GdbTargetError::UnexpectedMessage) } } @@ -348,22 +348,22 @@ impl HwBreakpoint for HyperlightSandboxTarget { addr: ::Usize, _kind: ::BreakpointKind, ) -> TargetResult { - log::debug!("Add hw breakpoint at address {:X}", addr); + tracing::debug!("Add hw breakpoint at address {:X}", addr); match self.send_command(DebugMsg::AddHwBreakpoint(addr))? { DebugResponse::AddHwBreakpoint(rsp) => Ok(rsp), DebugResponse::NotAllowed => { - log::error!("Action not allowed at this time, crash might have occurred"); + tracing::error!("Action not allowed at this time, crash might have occurred"); // This is a consequence of the target crashing or being in an invalid state // we cannot continue execution, but we can still read registers and memory Err(TargetError::NonFatal) } DebugResponse::ErrorOccurred => { - log::error!("Error occurred"); + tracing::error!("Error occurred"); Err(TargetError::NonFatal) } msg => { - log::error!("Unexpected message received: {:?}", msg); + tracing::error!("Unexpected message received: {:?}", msg); Err(TargetError::Fatal(GdbTargetError::UnexpectedMessage)) } } @@ -374,22 +374,22 @@ impl HwBreakpoint for HyperlightSandboxTarget { addr: ::Usize, _kind: ::BreakpointKind, ) -> TargetResult { - log::debug!("Remove hw breakpoint at address {:X}", addr); + tracing::debug!("Remove hw breakpoint at address {:X}", addr); match self.send_command(DebugMsg::RemoveHwBreakpoint(addr))? { DebugResponse::RemoveHwBreakpoint(rsp) => Ok(rsp), DebugResponse::NotAllowed => { - log::error!("Action not allowed at this time, crash might have occurred"); + tracing::error!("Action not allowed at this time, crash might have occurred"); // This is a consequence of the target crashing or being in an invalid state // we cannot continue execution, but we can still read registers and memory Err(TargetError::NonFatal) } DebugResponse::ErrorOccurred => { - log::error!("Error occurred"); + tracing::error!("Error occurred"); Err(TargetError::NonFatal) } msg => { - log::error!("Unexpected message received: {:?}", msg); + tracing::error!("Unexpected message received: {:?}", msg); Err(TargetError::Fatal(GdbTargetError::UnexpectedMessage)) } } @@ -402,22 +402,22 @@ impl SwBreakpoint for HyperlightSandboxTarget { addr: ::Usize, _kind: ::BreakpointKind, ) -> TargetResult { - log::debug!("Add sw breakpoint at address {:X}", addr); + tracing::debug!("Add sw breakpoint at address {:X}", addr); match self.send_command(DebugMsg::AddSwBreakpoint(addr))? { DebugResponse::AddSwBreakpoint(rsp) => Ok(rsp), DebugResponse::NotAllowed => { - log::error!("Action not allowed at this time, crash might have occurred"); + tracing::error!("Action not allowed at this time, crash might have occurred"); // This is a consequence of the target crashing or being in an invalid state // we cannot continue execution, but we can still read registers and memory Err(TargetError::NonFatal) } DebugResponse::ErrorOccurred => { - log::error!("Error occurred"); + tracing::error!("Error occurred"); Err(TargetError::NonFatal) } msg => { - log::error!("Unexpected message received: {:?}", msg); + tracing::error!("Unexpected message received: {:?}", msg); Err(TargetError::Fatal(GdbTargetError::UnexpectedMessage)) } } @@ -428,22 +428,22 @@ impl SwBreakpoint for HyperlightSandboxTarget { addr: ::Usize, _kind: ::BreakpointKind, ) -> TargetResult { - log::debug!("Remove sw breakpoint at address {:X}", addr); + tracing::debug!("Remove sw breakpoint at address {:X}", addr); match self.send_command(DebugMsg::RemoveSwBreakpoint(addr))? { DebugResponse::RemoveSwBreakpoint(rsp) => Ok(rsp), DebugResponse::NotAllowed => { - log::error!("Action not allowed at this time, crash might have occurred"); + tracing::error!("Action not allowed at this time, crash might have occurred"); // This is a consequence of the target crashing or being in an invalid state // we cannot continue execution, but we can still read registers and memory Err(TargetError::NonFatal) } DebugResponse::ErrorOccurred => { - log::error!("Error occurred"); + tracing::error!("Error occurred"); Err(TargetError::NonFatal) } msg => { - log::error!("Unexpected message received: {:?}", msg); + tracing::error!("Unexpected message received: {:?}", msg); Err(TargetError::Fatal(GdbTargetError::UnexpectedMessage)) } } @@ -454,7 +454,7 @@ impl SingleThreadResume for HyperlightSandboxTarget { /// Resumes the execution of the vCPU /// Note: We do not handle signals passed to this method fn resume(&mut self, _signal: Option) -> Result<(), Self::Error> { - log::debug!("Resume"); + tracing::debug!("Resume"); self.resume_vcpu() } fn support_single_step(&mut self) -> Option> { @@ -466,21 +466,21 @@ impl SingleThreadSingleStep for HyperlightSandboxTarget { /// Steps the vCPU execution by /// Note: We do not handle signals passed to this method fn step(&mut self, _signal: Option) -> Result<(), Self::Error> { - log::debug!("Step"); + tracing::debug!("Step"); match self.send_command(DebugMsg::Step)? { DebugResponse::Step => Ok(()), DebugResponse::ErrorOccurred => { - log::error!("Error occurred"); + tracing::error!("Error occurred"); Err(GdbTargetError::UnexpectedError) } DebugResponse::NotAllowed => { - log::error!("Action not allowed at this time, crash might have occurred"); + tracing::error!("Action not allowed at this time, crash might have occurred"); // This is a consequence of the target crashing or being in an invalid state // we cannot continue execution, but we can still read registers and memory Ok(()) } msg => { - log::error!("Unexpected message received: {:?}", msg); + tracing::error!("Unexpected message received: {:?}", msg); Err(GdbTargetError::UnexpectedMessage) } } diff --git a/src/hyperlight_host/src/hypervisor/hyperlight_vm/x86_64.rs b/src/hyperlight_host/src/hypervisor/hyperlight_vm/x86_64.rs index d82f2c58b..ec188b3f5 100644 --- a/src/hyperlight_host/src/hypervisor/hyperlight_vm/x86_64.rs +++ b/src/hyperlight_host/src/hypervisor/hyperlight_vm/x86_64.rs @@ -405,7 +405,7 @@ impl HyperlightVm { self.send_dbg_msg(DebugResponse::VcpuStopped(stop_reason))?; loop { - log::debug!("Debug wait for event to resume vCPU"); + tracing::debug!("Debug wait for event to resume vCPU"); // Wait for a message from gdb let req = self.recv_dbg_msg()?; @@ -447,7 +447,7 @@ impl HyperlightVm { _, ))) => DebugResponse::ErrorOccurred, Err(e) => { - log::error!("Error processing debug request: {:?}", e); + tracing::error!("Error processing debug request: {:?}", e); return Err(HandleDebugError::ProcessRequest(e)); } } @@ -478,7 +478,7 @@ impl HyperlightVm { self.send_dbg_msg(DebugResponse::VcpuStopped(stop_reason))?; loop { - log::debug!("Debug wait for event to resume vCPU"); + tracing::debug!("Debug wait for event to resume vCPU"); // Wait for a message from gdb let req = self.recv_dbg_msg()?; @@ -640,7 +640,7 @@ pub(super) mod debug { self.vm .add_hw_breakpoint(addr) .map_err(|e| { - log::error!("Failed to add hw breakpoint: {:?}", e); + tracing::error!("Failed to add hw breakpoint: {:?}", e); e }) @@ -649,7 +649,7 @@ pub(super) mod debug { DebugMsg::AddSwBreakpoint(addr) => Ok(DebugResponse::AddSwBreakpoint( self.add_sw_breakpoint(addr, mem_access) .map_err(|e| { - log::error!("Failed to add sw breakpoint: {:?}", e); + tracing::error!("Failed to add sw breakpoint: {:?}", e); e }) @@ -657,7 +657,7 @@ pub(super) mod debug { )), DebugMsg::Continue => { self.vm.set_single_step(false).map_err(|e| { - log::error!("Failed to continue execution: {:?}", e); + tracing::error!("Failed to continue execution: {:?}", e); e })?; @@ -666,7 +666,7 @@ pub(super) mod debug { } DebugMsg::DisableDebug => { self.vm.set_debug(false).map_err(|e| { - log::error!("Failed to disable debugging: {:?}", e); + tracing::error!("Failed to disable debugging: {:?}", e); e })?; @@ -686,7 +686,7 @@ pub(super) mod debug { let mut data = vec![0u8; len]; self.read_addrs(addr, &mut data, mem_access).map_err(|e| { - log::error!("Failed to read from address: {:?}", e); + tracing::error!("Failed to read from address: {:?}", e); e })?; @@ -702,7 +702,7 @@ pub(super) mod debug { self.vm .remove_hw_breakpoint(addr) .map_err(|e| { - log::error!("Failed to remove hw breakpoint: {:?}", e); + tracing::error!("Failed to remove hw breakpoint: {:?}", e); e }) @@ -711,7 +711,7 @@ pub(super) mod debug { DebugMsg::RemoveSwBreakpoint(addr) => Ok(DebugResponse::RemoveSwBreakpoint( self.remove_sw_breakpoint(addr, mem_access) .map_err(|e| { - log::error!("Failed to remove sw breakpoint: {:?}", e); + tracing::error!("Failed to remove sw breakpoint: {:?}", e); e }) @@ -719,7 +719,7 @@ pub(super) mod debug { )), DebugMsg::Step => { self.vm.set_single_step(true).map_err(|e| { - log::error!("Failed to enable step instruction: {:?}", e); + tracing::error!("Failed to enable step instruction: {:?}", e); e })?; @@ -728,7 +728,7 @@ pub(super) mod debug { } DebugMsg::WriteAddr(addr, data) => { self.write_addrs(addr, &data, mem_access).map_err(|e| { - log::error!("Failed to write to address: {:?}", e); + tracing::error!("Failed to write to address: {:?}", e); e })?; @@ -767,7 +767,7 @@ pub(super) mod debug { ) -> std::result::Result<(), super::SendDbgMsgError> { use super::SendDbgMsgError; - log::debug!("Sending {:?}", cmd); + tracing::debug!("Sending {:?}", cmd); let gdb_conn = self .gdb_conn @@ -784,7 +784,7 @@ pub(super) mod debug { mem_access: &DebugMemoryAccess, ) -> std::result::Result<(), ProcessDebugRequestError> { let data_len = data.len(); - log::debug!("Read addr: {:X} len: {:X}", gva, data_len); + tracing::debug!("Read addr: {:X} len: {:X}", gva, data_len); while !data.is_empty() { let gpa = self.vm.translate_gva(gva)?; @@ -812,7 +812,7 @@ pub(super) mod debug { mem_access: &DebugMemoryAccess, ) -> std::result::Result<(), ProcessDebugRequestError> { let data_len = data.len(); - log::debug!("Write addr: {:X} len: {:X}", gva, data_len); + tracing::debug!("Write addr: {:X} len: {:X}", gva, data_len); while !data.is_empty() { let gpa = self.vm.translate_gva(gva)?; diff --git a/src/hyperlight_host/src/sandbox/trace/context.rs b/src/hyperlight_host/src/sandbox/trace/context.rs index 62af150b9..fbf5817b3 100644 --- a/src/hyperlight_host/src/sandbox/trace/context.rs +++ b/src/hyperlight_host/src/sandbox/trace/context.rs @@ -113,7 +113,7 @@ impl TraceContext { if !hyperlight_guest_tracing::invariant_tsc::has_invariant_tsc() { // If the platform does not support invariant TSC, warn the user. // On Azure nested virtualization, the TSC invariant bit is not correctly reported, this is a known issue. - log::warn!( + tracing::warn!( "Invariant TSC is not supported on this platform, trace timestamps may be inaccurate" ); } @@ -153,7 +153,7 @@ impl TraceContext { // This is a fallback mechanism to ensure that we can still calculate, however it // should be noted that this may lead to inaccuracies in the TSC frequency. // The start time should be already set before running the guest for each sandbox. - log::error!( + tracing::error!( "Guest start TSC and time are not set. Calculating TSC frequency will use current time and TSC." ); ( @@ -169,7 +169,7 @@ impl TraceContext { let elapsed = end_time.duration_since(start_time).as_secs_f64(); let tsc_freq = ((end - start) as f64 / elapsed) as u64; - log::info!("Calculated TSC frequency: {} Hz", tsc_freq); + tracing::info!("Calculated TSC frequency: {} Hz", tsc_freq); self.tsc_freq = Some(tsc_freq); Ok(()) @@ -389,7 +389,7 @@ impl Drop for TraceContext { fn drop(&mut self) { for (k, mut v) in self.guest_spans.drain() { v.end(); - log::debug!("Dropped guest span with id {}", k); + tracing::debug!("Dropped guest span with id {}", k); } while let Some(entered) = self.host_spans.pop() { entered.exit(); diff --git a/src/hyperlight_host/src/sandbox/uninitialized_evolve.rs b/src/hyperlight_host/src/sandbox/uninitialized_evolve.rs index bbb759944..6e04ad2d9 100644 --- a/src/hyperlight_host/src/sandbox/uninitialized_evolve.rs +++ b/src/hyperlight_host/src/sandbox/uninitialized_evolve.rs @@ -162,7 +162,7 @@ pub(crate) fn set_up_hypervisor_partition( match gdb_conn { Ok(gdb_conn) => Some(gdb_conn), Err(e) => { - log::error!("Could not create gdb connection: {:#}", e); + tracing::error!("Could not create gdb connection: {:#}", e); None }