From e1aca22aec5ec7496576a0f2843c46e484a21b3a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 25 Nov 2025 19:06:06 +0000 Subject: [PATCH 1/4] Initial plan From 5d31424ab36e536377f1811c34d6a88e8af4af5d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 25 Nov 2025 19:36:24 +0000 Subject: [PATCH 2/4] Replace log crate with tracing in host and component_util Co-authored-by: dblnz <13020154+dblnz@users.noreply.github.com> --- Cargo.lock | 4 +- src/hyperlight_common/Cargo.toml | 5 +- .../src/flatbuffer_wrappers/function_call.rs | 9 ++- .../src/flatbuffer_wrappers/function_types.rs | 55 +++++++++---------- .../src/flatbuffer_wrappers/guest_error.rs | 5 +- .../src/flatbuffer_wrappers/guest_log_data.rs | 11 ++-- .../flatbuffer_wrappers/guest_log_level.rs | 34 ++++++------ .../host_function_definition.rs | 13 ++--- .../host_function_details.rs | 5 +- src/hyperlight_component_util/Cargo.toml | 2 +- src/hyperlight_component_util/src/emit.rs | 11 ++-- src/hyperlight_component_util/src/guest.rs | 3 +- src/hyperlight_component_util/src/hl.rs | 9 +-- src/hyperlight_component_util/src/host.rs | 5 +- src/hyperlight_component_util/src/rtypes.rs | 15 ++--- src/hyperlight_component_util/src/util.rs | 4 +- src/hyperlight_host/Cargo.toml | 1 - .../src/hypervisor/hyperv_linux.rs | 32 +++++------ .../src/hypervisor/hyperv_windows.rs | 34 ++++++------ src/hyperlight_host/src/hypervisor/kvm.rs | 36 ++++++------ src/hyperlight_host/src/hypervisor/mod.rs | 10 ++-- src/hyperlight_host/src/lib.rs | 14 ++--- src/hyperlight_host/src/sandbox/outb.rs | 16 +++++- .../src/sandbox/uninitialized.rs | 2 +- 24 files changed, 170 insertions(+), 165 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 47c997d2e..0f3f65940 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1367,7 +1367,6 @@ dependencies = [ "anyhow", "arbitrary", "flatbuffers", - "log", "spin 0.10.0", "tracing", ] @@ -1391,11 +1390,11 @@ name = "hyperlight-component-util" version = "0.11.0" dependencies = [ "itertools 0.14.0", - "log", "prettyplease", "proc-macro2", "quote", "syn", + "tracing", "wasmparser", ] @@ -1478,7 +1477,6 @@ dependencies = [ "kvm-ioctls", "lazy_static", "libc", - "log", "metrics", "metrics-exporter-prometheus", "metrics-util", diff --git a/src/hyperlight_common/Cargo.toml b/src/hyperlight_common/Cargo.toml index 9a0930fe3..2041191c0 100644 --- a/src/hyperlight_common/Cargo.toml +++ b/src/hyperlight_common/Cargo.toml @@ -17,13 +17,12 @@ workspace = true [dependencies] flatbuffers = { version = "25.9.23", default-features = false } anyhow = { version = "1.0.100", default-features = false } -log = "0.4.28" -tracing = { version = "0.1.41", optional = true } +tracing = { version = "0.1.41" } arbitrary = {version = "1.4.2", optional = true, features = ["derive"]} spin = "0.10.0" [features] -default = ["tracing"] +default = [] fuzzing = ["dep:arbitrary"] trace_guest = [] mem_profile = [] diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/function_call.rs b/src/hyperlight_common/src/flatbuffer_wrappers/function_call.rs index 056ced8e0..679b7577b 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/function_call.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/function_call.rs @@ -19,7 +19,6 @@ use alloc::vec::Vec; use anyhow::{Error, Result, bail}; use flatbuffers::{FlatBufferBuilder, WIPOffset, size_prefixed_root}; -#[cfg(feature = "tracing")] use tracing::{Span, instrument}; use super::function_types::{ParameterValue, ReturnType}; @@ -53,7 +52,7 @@ pub struct FunctionCall { } impl FunctionCall { - #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(skip_all, parent = Span::current(), level= "Trace")] pub fn new( function_name: String, parameters: Option>, @@ -214,7 +213,7 @@ impl FunctionCall { } } -#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] +#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] pub fn validate_guest_function_call_buffer(function_call_buffer: &[u8]) -> Result<()> { let guest_function_call_fb = size_prefixed_root::(function_call_buffer) .map_err(|e| anyhow::anyhow!("Error reading function call buffer: {:?}", e))?; @@ -226,7 +225,7 @@ pub fn validate_guest_function_call_buffer(function_call_buffer: &[u8]) -> Resul } } -#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] +#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] pub fn validate_host_function_call_buffer(function_call_buffer: &[u8]) -> Result<()> { let host_function_call_fb = size_prefixed_root::(function_call_buffer) .map_err(|e| anyhow::anyhow!("Error reading function call buffer: {:?}", e))?; @@ -240,7 +239,7 @@ pub fn validate_host_function_call_buffer(function_call_buffer: &[u8]) -> Result impl TryFrom<&[u8]> for FunctionCall { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: &[u8]) -> Result { let function_call_fb = size_prefixed_root::(value) .map_err(|e| anyhow::anyhow!("Error reading function call buffer: {:?}", e))?; diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/function_types.rs b/src/hyperlight_common/src/flatbuffer_wrappers/function_types.rs index 42c7ff823..8a08808c3 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/function_types.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/function_types.rs @@ -19,7 +19,6 @@ use alloc::vec::Vec; use anyhow::{Error, Result, anyhow, bail}; use flatbuffers::size_prefixed_root; -#[cfg(feature = "tracing")] use tracing::{Span, instrument}; use super::guest_error::GuestError; @@ -284,7 +283,7 @@ pub enum ReturnType { } impl From<&ParameterValue> for ParameterType { - #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(skip_all, parent = Span::current(), level= "Trace")] fn from(value: &ParameterValue) -> Self { match *value { ParameterValue::Int(_) => ParameterType::Int, @@ -303,7 +302,7 @@ impl From<&ParameterValue> for ParameterType { impl TryFrom> for ParameterValue { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(param: Parameter<'_>) -> Result { let value = param.value_type(); let result = match value { @@ -343,7 +342,7 @@ impl TryFrom> for ParameterValue { } impl From for FbParameterType { - #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(skip_all, parent = Span::current(), level= "Trace")] fn from(value: ParameterType) -> Self { match value { ParameterType::Int => FbParameterType::hlint, @@ -360,7 +359,7 @@ impl From for FbParameterType { } impl From for FbReturnType { - #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(skip_all, parent = Span::current(), level= "Trace")] fn from(value: ReturnType) -> Self { match value { ReturnType::Int => FbReturnType::hlint, @@ -379,7 +378,7 @@ impl From for FbReturnType { impl TryFrom for ParameterType { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: FbParameterType) -> Result { match value { FbParameterType::hlint => Ok(ParameterType::Int), @@ -400,7 +399,7 @@ impl TryFrom for ParameterType { impl TryFrom for ReturnType { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: FbReturnType) -> Result { match value { FbReturnType::hlint => Ok(ReturnType::Int), @@ -422,7 +421,7 @@ impl TryFrom for ReturnType { impl TryFrom for i32 { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: ParameterValue) -> Result { match value { ParameterValue::Int(v) => Ok(v), @@ -435,7 +434,7 @@ impl TryFrom for i32 { impl TryFrom for u32 { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: ParameterValue) -> Result { match value { ParameterValue::UInt(v) => Ok(v), @@ -448,7 +447,7 @@ impl TryFrom for u32 { impl TryFrom for i64 { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: ParameterValue) -> Result { match value { ParameterValue::Long(v) => Ok(v), @@ -461,7 +460,7 @@ impl TryFrom for i64 { impl TryFrom for u64 { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: ParameterValue) -> Result { match value { ParameterValue::ULong(v) => Ok(v), @@ -474,7 +473,7 @@ impl TryFrom for u64 { impl TryFrom for f32 { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: ParameterValue) -> Result { match value { ParameterValue::Float(v) => Ok(v), @@ -487,7 +486,7 @@ impl TryFrom for f32 { impl TryFrom for f64 { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: ParameterValue) -> Result { match value { ParameterValue::Double(v) => Ok(v), @@ -500,7 +499,7 @@ impl TryFrom for f64 { impl TryFrom for String { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: ParameterValue) -> Result { match value { ParameterValue::String(v) => Ok(v), @@ -513,7 +512,7 @@ impl TryFrom for String { impl TryFrom for bool { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: ParameterValue) -> Result { match value { ParameterValue::Bool(v) => Ok(v), @@ -526,7 +525,7 @@ impl TryFrom for bool { impl TryFrom for Vec { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: ParameterValue) -> Result { match value { ParameterValue::VecBytes(v) => Ok(v), @@ -539,7 +538,7 @@ impl TryFrom for Vec { impl TryFrom for i32 { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: ReturnValue) -> Result { match value { ReturnValue::Int(v) => Ok(v), @@ -552,7 +551,7 @@ impl TryFrom for i32 { impl TryFrom for u32 { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: ReturnValue) -> Result { match value { ReturnValue::UInt(v) => Ok(v), @@ -565,7 +564,7 @@ impl TryFrom for u32 { impl TryFrom for i64 { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: ReturnValue) -> Result { match value { ReturnValue::Long(v) => Ok(v), @@ -578,7 +577,7 @@ impl TryFrom for i64 { impl TryFrom for u64 { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: ReturnValue) -> Result { match value { ReturnValue::ULong(v) => Ok(v), @@ -591,7 +590,7 @@ impl TryFrom for u64 { impl TryFrom for f32 { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: ReturnValue) -> Result { match value { ReturnValue::Float(v) => Ok(v), @@ -604,7 +603,7 @@ impl TryFrom for f32 { impl TryFrom for f64 { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: ReturnValue) -> Result { match value { ReturnValue::Double(v) => Ok(v), @@ -617,7 +616,7 @@ impl TryFrom for f64 { impl TryFrom for String { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: ReturnValue) -> Result { match value { ReturnValue::String(v) => Ok(v), @@ -630,7 +629,7 @@ impl TryFrom for String { impl TryFrom for bool { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: ReturnValue) -> Result { match value { ReturnValue::Bool(v) => Ok(v), @@ -643,7 +642,7 @@ impl TryFrom for bool { impl TryFrom for Vec { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: ReturnValue) -> Result { match value { ReturnValue::VecBytes(v) => Ok(v), @@ -656,7 +655,7 @@ impl TryFrom for Vec { impl TryFrom for () { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: ReturnValue) -> Result { match value { ReturnValue::Void(()) => Ok(()), @@ -669,7 +668,7 @@ impl TryFrom for () { impl TryFrom> for ReturnValue { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(return_value_box: ReturnValueBox<'_>) -> Result { match return_value_box.value_type() { FbReturnValue::hlint => { @@ -740,7 +739,7 @@ impl TryFrom> for ReturnValue { impl TryFrom<&ReturnValue> for Vec { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: &ReturnValue) -> Result> { let mut builder = flatbuffers::FlatBufferBuilder::new(); let result_bytes = match value { diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/guest_error.rs b/src/hyperlight_common/src/flatbuffer_wrappers/guest_error.rs index b3d1f457e..9045a2c7a 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/guest_error.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/guest_error.rs @@ -18,7 +18,6 @@ extern crate flatbuffers; use alloc::string::{String, ToString}; -#[cfg(feature = "tracing")] use tracing::{Span, instrument}; use crate::flatbuffers::hyperlight::generated::ErrorCode as FbErrorCode; @@ -189,14 +188,14 @@ pub struct GuestError { } impl GuestError { - #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(skip_all, parent = Span::current(), level= "Trace")] pub fn new(code: ErrorCode, message: String) -> Self { Self { code, message } } } impl Default for GuestError { - #[cfg_attr(feature = "tracing", instrument(parent = Span::current(), level= "Trace"))] + #[instrument(parent = Span::current(), level= "Trace")] fn default() -> Self { Self { code: ErrorCode::NoError, diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_data.rs b/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_data.rs index cc27525a2..a307ec7b0 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_data.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_data.rs @@ -19,7 +19,6 @@ use alloc::vec::Vec; use anyhow::{Error, Result, anyhow}; use flatbuffers::size_prefixed_root; -#[cfg(feature = "tracing")] use tracing::{Span, instrument}; use super::guest_log_level::LogLevel; @@ -40,7 +39,7 @@ pub struct GuestLogData { } impl GuestLogData { - #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(skip_all, parent = Span::current(), level= "Trace")] pub fn new( message: String, source: String, @@ -62,7 +61,7 @@ impl GuestLogData { impl TryFrom<&[u8]> for GuestLogData { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(raw_bytes: &[u8]) -> Result { let gld_gen = size_prefixed_root::(raw_bytes) .map_err(|e| anyhow!("Error while reading GuestLogData: {:?}", e))?; @@ -86,7 +85,7 @@ impl TryFrom<&[u8]> for GuestLogData { impl TryFrom<&GuestLogData> for Vec { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: &GuestLogData) -> Result> { let mut builder = flatbuffers::FlatBufferBuilder::new(); let message = builder.create_string(&value.message); @@ -115,13 +114,13 @@ impl TryFrom<&GuestLogData> for Vec { impl TryFrom for Vec { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: GuestLogData) -> Result> { (&value).try_into() } } -#[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] +#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn convert_generated_option(field_name: &str, opt: Option<&str>) -> Result { opt.map(|s| s.to_string()) .ok_or_else(|| anyhow!("Missing field: {}", field_name)) diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_level.rs b/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_level.rs index deec57070..1f837a440 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_level.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_level.rs @@ -15,9 +15,7 @@ limitations under the License. */ use anyhow::{Error, Result, bail}; -use log::Level; -#[cfg(feature = "tracing")] -use tracing::{Span, instrument}; +use tracing::{Level, Span, instrument}; use crate::flatbuffers::hyperlight::generated::LogLevel as FbLogLevel; @@ -34,7 +32,7 @@ pub enum LogLevel { } impl From for LogLevel { - #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(skip_all, parent = Span::current(), level= "Trace")] fn from(val: u8) -> LogLevel { match val { 0 => LogLevel::Trace, @@ -50,7 +48,7 @@ impl From for LogLevel { impl TryFrom<&FbLogLevel> for LogLevel { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(val: &FbLogLevel) -> Result { match *val { FbLogLevel::Trace => Ok(LogLevel::Trace), @@ -68,7 +66,7 @@ impl TryFrom<&FbLogLevel> for LogLevel { } impl From<&LogLevel> for FbLogLevel { - #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(skip_all, parent = Span::current(), level= "Trace")] fn from(val: &LogLevel) -> FbLogLevel { match val { LogLevel::Critical => FbLogLevel::Critical, @@ -89,14 +87,14 @@ impl From<&LogLevel> for Level { //TODO: instrument this once we fix the test fn from(val: &LogLevel) -> Level { match val { - LogLevel::Trace => Level::Trace, - LogLevel::Debug => Level::Debug, - LogLevel::Information => Level::Info, - LogLevel::Warning => Level::Warn, - LogLevel::Error => Level::Error, - LogLevel::Critical => Level::Error, + LogLevel::Trace => Level::TRACE, + LogLevel::Debug => Level::DEBUG, + LogLevel::Information => Level::INFO, + LogLevel::Warning => Level::WARN, + LogLevel::Error => Level::ERROR, + LogLevel::Critical => Level::ERROR, // If the log level is None then we will log as trace - LogLevel::None => Level::Trace, + LogLevel::None => Level::TRACE, } } } @@ -104,11 +102,11 @@ impl From<&LogLevel> for Level { impl From for LogLevel { fn from(val: Level) -> LogLevel { match val { - Level::Trace => LogLevel::Trace, - Level::Debug => LogLevel::Debug, - Level::Info => LogLevel::Information, - Level::Warn => LogLevel::Warning, - Level::Error => LogLevel::Error, + Level::TRACE => LogLevel::Trace, + Level::DEBUG => LogLevel::Debug, + Level::INFO => LogLevel::Information, + Level::WARN => LogLevel::Warning, + Level::ERROR => LogLevel::Error, } } } diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/host_function_definition.rs b/src/hyperlight_common/src/flatbuffer_wrappers/host_function_definition.rs index edd447f4d..4537bb50e 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/host_function_definition.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/host_function_definition.rs @@ -19,7 +19,6 @@ use alloc::vec::Vec; use anyhow::{Error, Result, anyhow}; use flatbuffers::{FlatBufferBuilder, WIPOffset}; -#[cfg(feature = "tracing")] use tracing::{Span, instrument}; use super::function_types::{ParameterType, ReturnType}; @@ -41,7 +40,7 @@ pub struct HostFunctionDefinition { impl HostFunctionDefinition { /// Create a new `HostFunctionDefinition`. - #[cfg_attr(feature = "tracing", instrument(skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(skip_all, parent = Span::current(), level= "Trace")] pub fn new( function_name: String, parameter_types: Option>, @@ -55,7 +54,7 @@ impl HostFunctionDefinition { } /// Convert this `HostFunctionDefinition` into a `WIPOffset`. - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] pub(crate) fn convert_to_flatbuffer_def<'a>( &self, builder: &mut FlatBufferBuilder<'a>, @@ -89,7 +88,7 @@ impl HostFunctionDefinition { } /// Verify that the function call has the correct parameter types. - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] pub fn verify_equal_parameter_types( &self, function_call_parameter_types: &[ParameterType], @@ -107,7 +106,7 @@ impl HostFunctionDefinition { impl TryFrom<&FbHostFunctionDefinition<'_>> for HostFunctionDefinition { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: &FbHostFunctionDefinition) -> Result { let function_name = value.function_name().to_string(); let return_type = value.return_type().try_into().map_err(|_| { @@ -140,7 +139,7 @@ impl TryFrom<&FbHostFunctionDefinition<'_>> for HostFunctionDefinition { impl TryFrom<&[u8]> for HostFunctionDefinition { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: &[u8]) -> Result { let fb_host_function_definition = flatbuffers::root::>(value) .map_err(|e| anyhow!("Error while reading HostFunctionDefinition: {:?}", e))?; @@ -150,7 +149,7 @@ impl TryFrom<&[u8]> for HostFunctionDefinition { impl TryFrom<&HostFunctionDefinition> for Vec { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(hfd: &HostFunctionDefinition) -> Result> { let mut builder = flatbuffers::FlatBufferBuilder::new(); let host_function_definition = hfd.convert_to_flatbuffer_def(&mut builder)?; diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/host_function_details.rs b/src/hyperlight_common/src/flatbuffer_wrappers/host_function_details.rs index 2c18a584b..ccea1cb31 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/host_function_details.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/host_function_details.rs @@ -18,7 +18,6 @@ use alloc::vec::Vec; use anyhow::{Error, Result}; use flatbuffers::{WIPOffset, size_prefixed_root}; -#[cfg(feature = "tracing")] use tracing::{Span, instrument}; use super::host_function_definition::HostFunctionDefinition; @@ -37,7 +36,7 @@ pub struct HostFunctionDetails { impl TryFrom<&[u8]> for HostFunctionDetails { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: &[u8]) -> Result { let host_function_details_fb = size_prefixed_root::(value) .map_err(|e| anyhow::anyhow!("Error while reading HostFunctionDetails: {:?}", e))?; @@ -66,7 +65,7 @@ impl TryFrom<&[u8]> for HostFunctionDetails { impl TryFrom<&HostFunctionDetails> for Vec { type Error = Error; - #[cfg_attr(feature = "tracing", instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace"))] + #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] fn try_from(value: &HostFunctionDetails) -> Result> { let mut builder = flatbuffers::FlatBufferBuilder::new(); let vec_host_function_definitions = match &value.host_functions { diff --git a/src/hyperlight_component_util/Cargo.toml b/src/hyperlight_component_util/Cargo.toml index 5a340974b..feb9f726b 100644 --- a/src/hyperlight_component_util/Cargo.toml +++ b/src/hyperlight_component_util/Cargo.toml @@ -21,4 +21,4 @@ proc-macro2 = { version = "1.0.103" } syn = { version = "2.0.111" } itertools = { version = "0.14.0" } prettyplease = { version = "0.2.37" } -log = { version = "0.4" } \ No newline at end of file +tracing = { version = "0.1.41" } \ No newline at end of file diff --git a/src/hyperlight_component_util/src/emit.rs b/src/hyperlight_component_util/src/emit.rs index 1b3545813..d623da4b9 100644 --- a/src/hyperlight_component_util/src/emit.rs +++ b/src/hyperlight_component_util/src/emit.rs @@ -21,6 +21,7 @@ use std::vec::Vec; use proc_macro2::TokenStream; use quote::{format_ident, quote}; use syn::Ident; +use tracing::debug; use crate::etypes::{BoundedTyvar, Defined, Handleable, ImportExport, TypeBound, Tyvar}; @@ -416,7 +417,7 @@ impl<'a, 'b> State<'a, 'b> { let Some(ref mut cnvs) = self.cur_needs_vars else { return; }; - log::debug!("debug varref: recording {:?} for var {:?}", cnvs.iter(), un); + debug!("debug varref: recording {:?} for var {:?}", cnvs.iter(), un); self.vars_needs_vars[un].extend(cnvs.iter()); } /// Get a list of all the variables needed by a var, given its absolute @@ -426,7 +427,7 @@ impl<'a, 'b> State<'a, 'b> { if self.vars_needs_vars.len() < un + 1 { return BTreeSet::new(); }; - log::debug!( + debug!( "debug varref: looking up {:?} for var {:?}", self.vars_needs_vars[un].iter(), un @@ -559,7 +560,7 @@ impl<'a, 'b> State<'a, 'b> { Defined::Handleable(Handleable::Var(tv)) => match tv { Tyvar::Bound(n) => { let bv = &self.bound_vars[self.var_offset + (*n as usize)]; - log::debug!("checking an origin {:?} {:?}", bv.origin, self.origin); + debug!("checking an origin {:?} {:?}", bv.origin, self.origin); if bv.origin.matches(self.origin.iter()) { Some((*n, bv.bound.clone())) } else { @@ -588,7 +589,7 @@ impl<'a, 'b> State<'a, 'b> { /// /// Precondition: all named traits/modules must exist pub fn resolve_trait_immut(&self, absolute: bool, path: &[Ident]) -> &Trait { - log::debug!("resolving trait {:?} {:?}", absolute, path); + debug!("resolving trait {:?} {:?}", absolute, path); let mut m = if absolute { &*self.root_mod } else { @@ -611,7 +612,7 @@ impl<'a, 'b> State<'a, 'b> { .enumerate() .for_each(|(i, vs)| { *vs = vs.iter().map(|v| v + n).collect(); - log::debug!("updated {:?} to {:?}", i, *vs); + debug!("updated {:?} to {:?}", i, *vs); }); for _ in 0..n { self.vars_needs_vars.push_front(BTreeSet::new()); diff --git a/src/hyperlight_component_util/src/guest.rs b/src/hyperlight_component_util/src/guest.rs index 09e909034..5d00e95bf 100644 --- a/src/hyperlight_component_util/src/guest.rs +++ b/src/hyperlight_component_util/src/guest.rs @@ -16,6 +16,7 @@ limitations under the License. use proc_macro2::TokenStream; use quote::{format_ident, quote}; +use tracing::debug; use crate::emit::{ FnName, ResolvedBoundVar, ResourceItemName, State, WitName, kebab_to_exports_name, kebab_to_fn, @@ -344,7 +345,7 @@ fn emit_component<'a, 'b, 'c>( /// - functions when given a type that implements the `Guest` trait pub fn emit_toplevel<'a, 'b, 'c>(s: &'c mut State<'a, 'b>, n: &str, ct: &'c Component<'b>) { s.is_impl = true; - log::debug!("\n\n=== starting guest emit ===\n"); + debug!("\n\n=== starting guest emit ===\n"); let wn = split_wit_name(n); let ns = wn.namespace_path(); diff --git a/src/hyperlight_component_util/src/hl.rs b/src/hyperlight_component_util/src/hl.rs index d58eb7aaf..b5e0c89d9 100644 --- a/src/hyperlight_component_util/src/hl.rs +++ b/src/hyperlight_component_util/src/hl.rs @@ -17,6 +17,7 @@ limitations under the License. use itertools::Itertools; use proc_macro2::{Ident, TokenStream}; use quote::{format_ident, quote}; +use tracing::debug; use crate::emit::{ResolvedBoundVar, State, kebab_to_cons, kebab_to_var}; use crate::etypes::{self, Defined, Handleable, Tyvar, Value}; @@ -298,7 +299,7 @@ pub fn emit_hl_unmarshal_value(s: &mut State, id: Ident, vt: &Value) -> TokenStr } Value::Own(ht) => { let vi = resolve_handleable_to_resource(s, ht); - log::debug!("resolved ht to r (1) {:?} {:?}", ht, vi); + debug!("resolved ht to r (1) {:?} {:?}", ht, vi); if s.is_guest { let rid = format_ident!("HostResource{}", vi); if s.is_wasmtime_guest { @@ -326,7 +327,7 @@ pub fn emit_hl_unmarshal_value(s: &mut State, id: Ident, vt: &Value) -> TokenStr } Value::Borrow(ht) => { let vi = resolve_handleable_to_resource(s, ht); - log::debug!("resolved ht to r (2) {:?} {:?}", ht, vi); + debug!("resolved ht to r (2) {:?} {:?}", ht, vi); if s.is_guest { let rid = format_ident!("HostResource{}", vi); if s.is_wasmtime_guest { @@ -624,7 +625,7 @@ pub fn emit_hl_marshal_value(s: &mut State, id: Ident, vt: &Value) -> TokenStrea } Value::Own(ht) => { let vi = resolve_handleable_to_resource(s, ht); - log::debug!("resolved ht to r (3) {:?} {:?}", ht, vi); + debug!("resolved ht to r (3) {:?} {:?}", ht, vi); if s.is_guest { let call = if s.is_wasmtime_guest { quote! { () } @@ -645,7 +646,7 @@ pub fn emit_hl_marshal_value(s: &mut State, id: Ident, vt: &Value) -> TokenStrea } Value::Borrow(ht) => { let vi = resolve_handleable_to_resource(s, ht); - log::debug!("resolved ht to r (6) {:?} {:?}", ht, vi); + debug!("resolved ht to r (6) {:?} {:?}", ht, vi); if s.is_guest { let call = if s.is_wasmtime_guest { quote! { () } diff --git a/src/hyperlight_component_util/src/host.rs b/src/hyperlight_component_util/src/host.rs index 0f6bca65b..f79b6f80a 100644 --- a/src/hyperlight_component_util/src/host.rs +++ b/src/hyperlight_component_util/src/host.rs @@ -16,6 +16,7 @@ limitations under the License. use proc_macro2::{Ident, TokenStream}; use quote::{format_ident, quote}; +use tracing::debug; use crate::emit::{ FnName, ResourceItemName, State, WitName, kebab_to_exports_name, kebab_to_fn, kebab_to_getter, @@ -202,7 +203,7 @@ fn emit_import_extern_decl<'a, 'b, 'c>( ExternDesc::CoreModule(_) => panic!("core module (im/ex)ports are not supported"), ExternDesc::Func(ft) => { let hln = emit_fn_hl_name(s, ed.kebab_name); - log::debug!("providing host function {}", hln); + debug!("providing host function {}", hln); let (pds, pus) = ft .params .iter() @@ -382,7 +383,7 @@ fn emit_component<'a, 'b, 'c>(s: &'c mut State<'a, 'b>, wn: WitName, ct: &'c Com /// See [`emit_component`] pub fn emit_toplevel<'a, 'b, 'c>(s: &'c mut State<'a, 'b>, n: &str, ct: &'c Component<'b>) { s.is_impl = true; - log::debug!("\n\n=== starting host emit ===\n"); + debug!("\n\n=== starting host emit ===\n"); let wn = split_wit_name(n); emit_component(s, wn, ct) } diff --git a/src/hyperlight_component_util/src/rtypes.rs b/src/hyperlight_component_util/src/rtypes.rs index 18665db31..eac577443 100644 --- a/src/hyperlight_component_util/src/rtypes.rs +++ b/src/hyperlight_component_util/src/rtypes.rs @@ -22,6 +22,7 @@ use std::vec::Vec; use proc_macro2::TokenStream; use quote::{format_ident, quote}; use syn::Ident; +use tracing::debug; use crate::emit::{ FnName, ResourceItemName, State, WitName, kebab_to_cons, kebab_to_exports_name, kebab_to_fn, @@ -164,7 +165,7 @@ fn try_find_local_var_id( return Some(emit_resource_ref(s, n, path)); } } - log::debug!("path is {:?}\n", path); + debug!("path is {:?}\n", path); let mut path = path.iter().rev(); let name = kebab_to_type(path.next().unwrap().name()); let owner = path.next(); @@ -216,7 +217,7 @@ pub fn emit_var_ref_value(s: &mut State, tv: &Tyvar) -> TokenStream { /// the bound variable being referenced /// - `is_value`: whether this is a value (e.g. constructor) or type context. pub fn emit_var_ref_noff(s: &mut State, n: u32, is_value: bool) -> TokenStream { - log::debug!("var_ref {:?} {:?}", &s.bound_vars[n as usize], s.origin); + debug!("var_ref {:?} {:?}", &s.bound_vars[n as usize], s.origin); // if the variable was defined locally, try to reference it directly let id = try_find_local_var_id(s, n); let id = match id { @@ -317,7 +318,7 @@ pub fn emit_value(s: &mut State, vt: &Value) -> TokenStream { wrap(emit_var_ref(s, tv)) } else { let n = crate::hl::resolve_handleable_to_resource(s, ht); - log::debug!("resolved ht to r (4) {:?} {:?}", ht, n); + debug!("resolved ht to r (4) {:?} {:?}", ht, n); let id = format_ident!("HostResource{}", n); wrap(quote! { #id }) } @@ -339,7 +340,7 @@ pub fn emit_value(s: &mut State, vt: &Value) -> TokenStream { wrap(emit_var_ref(s, tv)) } else { let n = crate::hl::resolve_handleable_to_resource(s, ht); - log::debug!("resolved ht to r (5) {:?} {:?}", ht, n); + debug!("resolved ht to r (5) {:?} {:?}", ht, n); let id = format_ident!("HostResource{}", n); wrap(quote! { #id }) } @@ -619,7 +620,7 @@ fn emit_extern_decl<'a, 'b, 'c>( s: &'c mut State<'a, 'b>, ed: &'c ExternDecl<'b>, ) -> TokenStream { - log::debug!(" emitting decl {:?}", ed.kebab_name); + debug!(" emitting decl {:?}", ed.kebab_name); match &ed.desc { ExternDesc::CoreModule(_) => panic!("core module (im/ex)ports are not supported"), ExternDesc::Func(ft) => { @@ -749,7 +750,7 @@ fn emit_extern_decl<'a, 'b, 'c>( /// Emit (via mutating `s`) a Rust trait declaration corresponding to /// this instance type fn emit_instance<'a, 'b, 'c>(s: &'c mut State<'a, 'b>, wn: WitName, it: &'c Instance<'b>) { - log::debug!("emitting instance {:?}", wn); + debug!("emitting instance {:?}", wn); let mut s = s.with_cursor(wn.namespace_idents()); let name = kebab_to_type(wn.name); @@ -801,7 +802,7 @@ fn emit_instance<'a, 'b, 'c>(s: &'c mut State<'a, 'b>, wn: WitName, it: &'c Inst } drop(sv); - log::debug!("after exports, ncur_needs_vars is {:?}", needs_vars); + debug!("after exports, ncur_needs_vars is {:?}", needs_vars); for v in needs_vars { let id = s.noff_var_id(v); s.cur_trait().tvs.insert(id, (Some(v), TokenStream::new())); diff --git a/src/hyperlight_component_util/src/util.rs b/src/hyperlight_component_util/src/util.rs index 8f9b853ae..de517ee4e 100644 --- a/src/hyperlight_component_util/src/util.rs +++ b/src/hyperlight_component_util/src/util.rs @@ -15,6 +15,8 @@ limitations under the License. */ //! General utilities for bindgen macros +use tracing::debug; + use crate::etypes; /// Read and parse a WIT type encapsulated in a wasm file from the @@ -46,7 +48,7 @@ pub fn read_wit_type_from_file R>( let ExternDesc::Component(ct) = &export.desc else { panic!("malformed component type container: does not contain component type"); }; - log::debug!("hcm: considering component type {:?}", ct); + debug!("hcm: considering component type {:?}", ct); cb(export.kebab_name.to_string(), ct) } diff --git a/src/hyperlight_host/Cargo.toml b/src/hyperlight_host/Cargo.toml index d40f5180e..3e963228b 100644 --- a/src/hyperlight_host/Cargo.toml +++ b/src/hyperlight_host/Cargo.toml @@ -34,7 +34,6 @@ blake3 = "1.8.2" page_size = "0.6.0" termcolor = "1.2.0" bitflags = "2.10.0" -log = "0.4.28" opentelemetry = { version = "0.31.0", optional = true } tracing = { version = "0.1.41", features = ["log"] } tracing-log = "0.2.0" diff --git a/src/hyperlight_host/src/hypervisor/hyperv_linux.rs b/src/hyperlight_host/src/hypervisor/hyperv_linux.rs index 88c27edc3..08cb50329 100644 --- a/src/hyperlight_host/src/hypervisor/hyperv_linux.rs +++ b/src/hyperlight_host/src/hypervisor/hyperv_linux.rs @@ -21,7 +21,8 @@ use std::fmt::{Debug, Formatter}; use std::sync::atomic::{AtomicBool, AtomicU8, AtomicU64}; use std::sync::{Arc, Mutex}; -use log::{LevelFilter, error}; +use tracing::{Span, error, info, instrument}; +use tracing::log::LevelFilter; use mshv_bindings::{ FloatingPointUnit, SpecialRegisters, StandardRegisters, hv_message_type, hv_message_type_HVMSG_GPA_INTERCEPT, hv_message_type_HVMSG_UNMAPPED_GPA, @@ -37,7 +38,6 @@ use mshv_bindings::{ mshv_install_intercept, }; use mshv_ioctls::{Mshv, VcpuFd, VmFd}; -use tracing::{Span, instrument}; #[cfg(feature = "trace_guest")] use tracing_opentelemetry::OpenTelemetrySpanExt; #[cfg(crashdump)] @@ -109,7 +109,7 @@ mod debug { debug .add_hw_breakpoint(&self.vcpu_fd, addr) .map_err(|e| { - log::error!("Failed to add hw breakpoint: {:?}", e); + error!("Failed to add hw breakpoint: {:?}", e); e }) @@ -119,7 +119,7 @@ mod debug { debug .add_sw_breakpoint(&self.vcpu_fd, addr, mem_access) .map_err(|e| { - log::error!("Failed to add sw breakpoint: {:?}", e); + error!("Failed to add sw breakpoint: {:?}", e); e }) @@ -127,7 +127,7 @@ mod debug { )), DebugMsg::Continue => { debug.set_single_step(&self.vcpu_fd, false).map_err(|e| { - log::error!("Failed to continue execution: {:?}", e); + error!("Failed to continue execution: {:?}", e); e })?; @@ -136,7 +136,7 @@ mod debug { } DebugMsg::DisableDebug => { self.disable_debug().map_err(|e| { - log::error!("Failed to disable debugging: {:?}", e); + error!("Failed to disable debugging: {:?}", e); e })?; @@ -165,7 +165,7 @@ mod debug { DebugMsg::ReadRegisters => debug .read_regs(&self.vcpu_fd) .map_err(|e| { - log::error!("Failed to read registers: {:?}", e); + error!("Failed to read registers: {:?}", e); e }) @@ -174,7 +174,7 @@ mod debug { debug .remove_hw_breakpoint(&self.vcpu_fd, addr) .map_err(|e| { - log::error!("Failed to remove hw breakpoint: {:?}", e); + error!("Failed to remove hw breakpoint: {:?}", e); e }) @@ -184,7 +184,7 @@ mod debug { debug .remove_sw_breakpoint(&self.vcpu_fd, addr, mem_access) .map_err(|e| { - log::error!("Failed to remove sw breakpoint: {:?}", e); + error!("Failed to remove sw breakpoint: {:?}", e); e }) @@ -192,7 +192,7 @@ mod debug { )), DebugMsg::Step => { debug.set_single_step(&self.vcpu_fd, true).map_err(|e| { - log::error!("Failed to enable step instruction: {:?}", e); + error!("Failed to enable step instruction: {:?}", e); e })?; @@ -209,7 +209,7 @@ mod debug { debug .write_regs(&self.vcpu_fd, regs, fpu) .map_err(|e| { - log::error!("Failed to write registers: {:?}", e); + error!("Failed to write registers: {:?}", e); e }) @@ -237,7 +237,7 @@ mod debug { } pub(crate) fn send_dbg_msg(&mut self, cmd: DebugResponse) -> Result<()> { - log::debug!("Sending {:?}", cmd); + debug!("Sending {:?}", cmd); let gdb_conn = self .gdb_conn @@ -258,7 +258,7 @@ pub(crate) fn is_hypervisor_present() -> bool { match Mshv::new() { Ok(_) => true, Err(_) => { - log::info!("MSHV is not available on this system"); + info!("MSHV is not available on this system"); false } } @@ -850,7 +850,7 @@ impl Hypervisor for HypervLinuxDriver { })?; loop { - log::debug!("Debug wait for event to resume vCPU"); + debug!("Debug wait for event to resume vCPU"); // Wait for a message from gdb let req = self.recv_dbg_msg()?; @@ -889,7 +889,7 @@ impl Hypervisor for HypervLinuxDriver { DebugResponse::ErrorOccurred } Err(e) => { - log::error!("Error processing debug request: {:?}", e); + error!("Error processing debug request: {:?}", e); return Err(e); } } @@ -925,7 +925,7 @@ impl Hypervisor for HypervLinuxDriver { })?; loop { - log::debug!("Debug wait for event to resume vCPU"); + debug!("Debug wait for event to resume vCPU"); // Wait for a message from gdb let req = self.recv_dbg_msg()?; diff --git a/src/hyperlight_host/src/hypervisor/hyperv_windows.rs b/src/hyperlight_host/src/hypervisor/hyperv_windows.rs index d3bd95f88..18eac3636 100644 --- a/src/hyperlight_host/src/hypervisor/hyperv_windows.rs +++ b/src/hyperlight_host/src/hypervisor/hyperv_windows.rs @@ -20,8 +20,8 @@ use std::string::String; use std::sync::atomic::{AtomicBool, AtomicU8}; use std::sync::{Arc, Mutex}; -use log::LevelFilter; -use tracing::{Span, instrument}; +use tracing::{Level, Span, error, debug, instrument}; +use tracing::log::LevelFilter; #[cfg(feature = "trace_guest")] use tracing_opentelemetry::OpenTelemetrySpanExt; use windows::Win32::System::Hypervisor::{WHV_MEMORY_ACCESS_TYPE, WHV_RUN_VP_EXIT_REASON}; @@ -102,7 +102,7 @@ mod debug { debug .add_hw_breakpoint(&self.processor, addr) .map_err(|e| { - log::error!("Failed to add hw breakpoint: {:?}", e); + error!("Failed to add hw breakpoint: {:?}", e); e }) @@ -112,7 +112,7 @@ mod debug { debug .add_sw_breakpoint(&self.processor, addr, mem_access) .map_err(|e| { - log::error!("Failed to add sw breakpoint: {:?}", e); + error!("Failed to add sw breakpoint: {:?}", e); e }) @@ -120,7 +120,7 @@ mod debug { )), DebugMsg::Continue => { debug.set_single_step(&self.processor, false).map_err(|e| { - log::error!("Failed to continue execution: {:?}", e); + error!("Failed to continue execution: {:?}", e); e })?; @@ -129,7 +129,7 @@ mod debug { } DebugMsg::DisableDebug => { self.disable_debug().map_err(|e| { - log::error!("Failed to disable debugging: {:?}", e); + error!("Failed to disable debugging: {:?}", e); e })?; @@ -154,7 +154,7 @@ mod debug { debug .read_addrs(&self.processor, addr, &mut data, mem_access) .map_err(|e| { - log::error!("Failed to read from address: {:?}", e); + error!("Failed to read from address: {:?}", e); e })?; @@ -164,7 +164,7 @@ mod debug { DebugMsg::ReadRegisters => debug .read_regs(&self.processor) .map_err(|e| { - log::error!("Failed to read registers: {:?}", e); + error!("Failed to read registers: {:?}", e); e }) @@ -173,7 +173,7 @@ mod debug { debug .remove_hw_breakpoint(&self.processor, addr) .map_err(|e| { - log::error!("Failed to remove hw breakpoint: {:?}", e); + error!("Failed to remove hw breakpoint: {:?}", e); e }) @@ -183,7 +183,7 @@ mod debug { debug .remove_sw_breakpoint(&self.processor, addr, mem_access) .map_err(|e| { - log::error!("Failed to remove sw breakpoint: {:?}", e); + error!("Failed to remove sw breakpoint: {:?}", e); e }) @@ -191,7 +191,7 @@ mod debug { )), DebugMsg::Step => { debug.set_single_step(&self.processor, true).map_err(|e| { - log::error!("Failed to enable step instruction: {:?}", e); + error!("Failed to enable step instruction: {:?}", e); e })?; @@ -202,7 +202,7 @@ mod debug { debug .write_addrs(&self.processor, addr, &data, mem_access) .map_err(|e| { - log::error!("Failed to write to address: {:?}", e); + error!("Failed to write to address: {:?}", e); e })?; @@ -214,7 +214,7 @@ mod debug { debug .write_regs(&self.processor, regs, fpu) .map_err(|e| { - log::error!("Failed to write registers: {:?}", e); + error!("Failed to write registers: {:?}", e); e }) @@ -242,7 +242,7 @@ mod debug { } pub(crate) fn send_dbg_msg(&mut self, cmd: DebugResponse) -> Result<()> { - log::debug!("Sending {:?}", cmd); + debug!("Sending {:?}", cmd); let gdb_conn = self .gdb_conn @@ -745,7 +745,7 @@ impl Hypervisor for HypervWindowsDriver { })?; loop { - log::debug!("Debug wait for event to resume vCPU"); + debug!("Debug wait for event to resume vCPU"); // Wait for a message from gdb let req = self.recv_dbg_msg()?; @@ -784,7 +784,7 @@ impl Hypervisor for HypervWindowsDriver { DebugResponse::ErrorOccurred } Err(e) => { - log::error!("Error processing debug request: {:?}", e); + error!("Error processing debug request: {:?}", e); return Err(e); } } @@ -820,7 +820,7 @@ impl Hypervisor for HypervWindowsDriver { })?; loop { - log::debug!("Debug wait for event to resume vCPU"); + debug!("Debug wait for event to resume vCPU"); // Wait for a message from gdb let req = self.recv_dbg_msg()?; diff --git a/src/hyperlight_host/src/hypervisor/kvm.rs b/src/hyperlight_host/src/hypervisor/kvm.rs index df0fd655b..b3f0fe6d8 100644 --- a/src/hyperlight_host/src/hypervisor/kvm.rs +++ b/src/hyperlight_host/src/hypervisor/kvm.rs @@ -21,8 +21,8 @@ use std::sync::{Arc, Mutex}; use kvm_bindings::{kvm_fpu, kvm_regs, kvm_sregs, kvm_userspace_memory_region}; use kvm_ioctls::Cap::UserMemory; use kvm_ioctls::{Kvm, VcpuExit, VcpuFd, VmFd}; -use log::LevelFilter; -use tracing::{Span, instrument}; +use tracing::{Span, info, instrument}; +use tracing::log::LevelFilter; #[cfg(feature = "trace_guest")] use tracing_opentelemetry::OpenTelemetrySpanExt; #[cfg(crashdump)] @@ -59,16 +59,16 @@ pub(crate) fn is_hypervisor_present() -> bool { match api_version { version if version == 12 && kvm.check_extension(UserMemory) => true, 12 => { - log::info!("KVM does not have KVM_CAP_USER_MEMORY capability"); + info!("KVM does not have KVM_CAP_USER_MEMORY capability"); false } version => { - log::info!("KVM GET_API_VERSION returned {}, expected 12", version); + info!("KVM GET_API_VERSION returned {}, expected 12", version); false } } } else { - log::info!("KVM is not available on this system"); + info!("KVM is not available on this system"); false } } @@ -119,7 +119,7 @@ mod debug { debug .add_hw_breakpoint(&self.vcpu_fd, addr) .map_err(|e| { - log::error!("Failed to add hw breakpoint: {:?}", e); + error!("Failed to add hw breakpoint: {:?}", e); e }) @@ -129,7 +129,7 @@ mod debug { debug .add_sw_breakpoint(&self.vcpu_fd, addr, mem_access) .map_err(|e| { - log::error!("Failed to add sw breakpoint: {:?}", e); + error!("Failed to add sw breakpoint: {:?}", e); e }) @@ -137,7 +137,7 @@ mod debug { )), DebugMsg::Continue => { debug.set_single_step(&self.vcpu_fd, false).map_err(|e| { - log::error!("Failed to continue execution: {:?}", e); + error!("Failed to continue execution: {:?}", e); e })?; @@ -146,7 +146,7 @@ mod debug { } DebugMsg::DisableDebug => { self.disable_debug().map_err(|e| { - log::error!("Failed to disable debugging: {:?}", e); + error!("Failed to disable debugging: {:?}", e); e })?; @@ -175,7 +175,7 @@ mod debug { DebugMsg::ReadRegisters => debug .read_regs(&self.vcpu_fd) .map_err(|e| { - log::error!("Failed to read registers: {:?}", e); + error!("Failed to read registers: {:?}", e); e }) @@ -184,7 +184,7 @@ mod debug { debug .remove_hw_breakpoint(&self.vcpu_fd, addr) .map_err(|e| { - log::error!("Failed to remove hw breakpoint: {:?}", e); + error!("Failed to remove hw breakpoint: {:?}", e); e }) @@ -194,7 +194,7 @@ mod debug { debug .remove_sw_breakpoint(&self.vcpu_fd, addr, mem_access) .map_err(|e| { - log::error!("Failed to remove sw breakpoint: {:?}", e); + error!("Failed to remove sw breakpoint: {:?}", e); e }) @@ -202,7 +202,7 @@ mod debug { )), DebugMsg::Step => { debug.set_single_step(&self.vcpu_fd, true).map_err(|e| { - log::error!("Failed to enable step instruction: {:?}", e); + error!("Failed to enable step instruction: {:?}", e); e })?; @@ -219,7 +219,7 @@ mod debug { debug .write_regs(&self.vcpu_fd, regs, fpu) .map_err(|e| { - log::error!("Failed to write registers: {:?}", e); + error!("Failed to write registers: {:?}", e); e }) @@ -246,7 +246,7 @@ mod debug { } pub(crate) fn send_dbg_msg(&mut self, cmd: DebugResponse) -> Result<()> { - log::debug!("Sending {:?}", cmd); + debug!("Sending {:?}", cmd); let gdb_conn = self .gdb_conn @@ -807,7 +807,7 @@ impl Hypervisor for KVMDriver { })?; loop { - log::debug!("Debug wait for event to resume vCPU"); + debug!("Debug wait for event to resume vCPU"); // Wait for a message from gdb let req = self.recv_dbg_msg()?; @@ -846,7 +846,7 @@ impl Hypervisor for KVMDriver { DebugResponse::ErrorOccurred } Err(e) => { - log::error!("Error processing debug request: {:?}", e); + error!("Error processing debug request: {:?}", e); return Err(e); } } @@ -882,7 +882,7 @@ impl Hypervisor for KVMDriver { })?; loop { - log::debug!("Debug wait for event to resume vCPU"); + debug!("Debug wait for event to resume vCPU"); // Wait for a message from gdb let req = self.recv_dbg_msg()?; diff --git a/src/hyperlight_host/src/hypervisor/mod.rs b/src/hyperlight_host/src/hypervisor/mod.rs index d4eeeef75..57f3d18f7 100644 --- a/src/hyperlight_host/src/hypervisor/mod.rs +++ b/src/hyperlight_host/src/hypervisor/mod.rs @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ -use log::{LevelFilter, debug}; -use tracing::{Span, instrument}; +use tracing::{Span, debug, info, instrument}; +use tracing::log::LevelFilter; use crate::HyperlightError::StackOverflow; use crate::error::HyperlightError::ExecutionCanceledByHost; @@ -301,7 +301,7 @@ pub(crate) trait Hypervisor: Debug + Send { val.split(',').find(|s| !s.contains("=")).unwrap_or("") }; - log::info!("Determined guest log level: {}", level); + info!("Determined guest log level: {}", level); // Convert the log level string to a LevelFilter // If no value is found, default to Error LevelFilter::from_str(level).unwrap_or(LevelFilter::Error) as u32 @@ -403,7 +403,7 @@ impl VirtualCPU { if let Err(e) = tc.handle_trace(®s, mem_mgr) { // If no trace data is available, we just log a message and continue // Is this the right thing to do? - log::debug!("Error handling guest trace: {:?}", e); + debug!("Error handling guest trace: {:?}", e); } } @@ -649,7 +649,7 @@ impl LinuxInterruptHandle { break; } - log::info!("Sending signal to kill vcpu thread..."); + info!("Sending signal to kill vcpu thread..."); sent_signal = true; // Acquire ordering to synchronize with the Release store in set_tid() // This ensures we see the correct tid value for the currently running vcpu diff --git a/src/hyperlight_host/src/lib.rs b/src/hyperlight_host/src/lib.rs index 5f034dc79..62695a19b 100644 --- a/src/hyperlight_host/src/lib.rs +++ b/src/hyperlight_host/src/lib.rs @@ -109,33 +109,33 @@ macro_rules! log_then_return { None => std::format!($msg), }; let __err = $crate::HyperlightError::Error(__err_msg); - log::error!("{}", __err); + tracing::error!("{}", __err); return Err(__err); }}; ($err:expr $(,)?) => { - log::error!("{}", $err); + tracing::error!("{}", $err); return Err($err); }; ($err:stmt $(,)?) => { - log::error!("{}", $err); + tracing::error!("{}", $err); return Err($err); }; ($fmtstr:expr, $($arg:tt)*) => { let __err_msg = std::format!($fmtstr, $($arg)*); let __err = $crate::error::HyperlightError::Error(__err_msg); - log::error!("{}", __err); + tracing::error!("{}", __err); return Err(__err); }; } -/// Same as log::debug!, but will additionally print to stdout if the print_debug feature is enabled +/// Same as tracing::debug!, but will additionally print to stdout if the print_debug feature is enabled #[macro_export] macro_rules! debug { ($($arg:tt)+) => { #[cfg(print_debug)] println!($($arg)+); - log::debug!($($arg)+); + tracing::debug!($($arg)+); } } @@ -145,7 +145,7 @@ static LOG_ONCE: Once = Once::new(); #[cfg(feature = "build-metadata")] pub(crate) fn log_build_details() { - use log::info; + use tracing::info; LOG_ONCE.call_once(|| { info!("Package name: {}", built_info::PKG_NAME); info!("Package version: {}", built_info::PKG_VERSION); diff --git a/src/hyperlight_host/src/sandbox/outb.rs b/src/hyperlight_host/src/sandbox/outb.rs index 087162a4a..3629369ed 100644 --- a/src/hyperlight_host/src/sandbox/outb.rs +++ b/src/hyperlight_host/src/sandbox/outb.rs @@ -20,7 +20,7 @@ use hyperlight_common::flatbuffer_wrappers::function_types::{FunctionCallResult, use hyperlight_common::flatbuffer_wrappers::guest_error::{ErrorCode, GuestError}; use hyperlight_common::flatbuffer_wrappers::guest_log_data::GuestLogData; use hyperlight_common::outb::{Exception, OutBAction}; -use log::{Level, Record}; +use tracing::log::{Level, Record}; use tracing::{Span, instrument}; use tracing_log::format_trace; @@ -44,7 +44,17 @@ pub(super) fn outb_log(mgr: &mut SandboxMemoryManager) -> Resu let log_data: GuestLogData = mgr.read_guest_log_data()?; - let record_level: Level = (&log_data.level).into(); + // Convert from our LogLevel to tracing::Level + let tracing_level: tracing::Level = (&log_data.level).into(); + + // Convert tracing::Level to log::Level for the Record API + let record_level: Level = match tracing_level { + tracing::Level::TRACE => Level::Trace, + tracing::Level::DEBUG => Level::Debug, + tracing::Level::INFO => Level::Info, + tracing::Level::WARN => Level::Warn, + tracing::Level::ERROR => Level::Error, + }; // Work out if we need to log or trace // this API is marked as follows but it is the easiest way to work out if we should trace or log @@ -80,7 +90,7 @@ pub(super) fn outb_log(mgr: &mut SandboxMemoryManager) -> Resu )?; } else { // Create a log record for the GuestLogData - log::logger().log( + tracing::log::logger().log( &Record::builder() .args(format_args!("{}", log_data.message)) .level(record_level) diff --git a/src/hyperlight_host/src/sandbox/uninitialized.rs b/src/hyperlight_host/src/sandbox/uninitialized.rs index cd7077062..05da9c128 100644 --- a/src/hyperlight_host/src/sandbox/uninitialized.rs +++ b/src/hyperlight_host/src/sandbox/uninitialized.rs @@ -19,8 +19,8 @@ use std::option::Option; use std::path::Path; use std::sync::{Arc, Mutex}; -use log::LevelFilter; use tracing::{Span, instrument}; +use tracing::log::LevelFilter; use super::host_funcs::{FunctionRegistry, default_writer_func}; use super::uninitialized_evolve::evolve_impl_multi_use; From d56aabf0fe1cc91bbaac45af2cd768014794960b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 25 Nov 2025 19:46:04 +0000 Subject: [PATCH 3/4] Fix test code to use tracing::log for compatibility layer Co-authored-by: dblnz <13020154+dblnz@users.noreply.github.com> --- .../src/hypervisor/hyperv_linux.rs | 4 ++-- .../src/hypervisor/hyperv_windows.rs | 2 +- src/hyperlight_host/src/hypervisor/kvm.rs | 2 +- src/hyperlight_host/src/hypervisor/mod.rs | 3 ++- src/hyperlight_host/src/sandbox/outb.rs | 18 +++++++++++++----- .../src/sandbox/uninitialized.rs | 11 ++++++----- src/hyperlight_host/tests/integration_test.rs | 8 ++++---- 7 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/hyperlight_host/src/hypervisor/hyperv_linux.rs b/src/hyperlight_host/src/hypervisor/hyperv_linux.rs index 08cb50329..b53e940ec 100644 --- a/src/hyperlight_host/src/hypervisor/hyperv_linux.rs +++ b/src/hyperlight_host/src/hypervisor/hyperv_linux.rs @@ -21,8 +21,6 @@ use std::fmt::{Debug, Formatter}; use std::sync::atomic::{AtomicBool, AtomicU8, AtomicU64}; use std::sync::{Arc, Mutex}; -use tracing::{Span, error, info, instrument}; -use tracing::log::LevelFilter; use mshv_bindings::{ FloatingPointUnit, SpecialRegisters, StandardRegisters, hv_message_type, hv_message_type_HVMSG_GPA_INTERCEPT, hv_message_type_HVMSG_UNMAPPED_GPA, @@ -38,6 +36,8 @@ use mshv_bindings::{ mshv_install_intercept, }; use mshv_ioctls::{Mshv, VcpuFd, VmFd}; +use tracing::log::LevelFilter; +use tracing::{Span, error, info, instrument}; #[cfg(feature = "trace_guest")] use tracing_opentelemetry::OpenTelemetrySpanExt; #[cfg(crashdump)] diff --git a/src/hyperlight_host/src/hypervisor/hyperv_windows.rs b/src/hyperlight_host/src/hypervisor/hyperv_windows.rs index 18eac3636..b3d041b94 100644 --- a/src/hyperlight_host/src/hypervisor/hyperv_windows.rs +++ b/src/hyperlight_host/src/hypervisor/hyperv_windows.rs @@ -20,8 +20,8 @@ use std::string::String; use std::sync::atomic::{AtomicBool, AtomicU8}; use std::sync::{Arc, Mutex}; -use tracing::{Level, Span, error, debug, instrument}; use tracing::log::LevelFilter; +use tracing::{Level, Span, debug, error, instrument}; #[cfg(feature = "trace_guest")] use tracing_opentelemetry::OpenTelemetrySpanExt; use windows::Win32::System::Hypervisor::{WHV_MEMORY_ACCESS_TYPE, WHV_RUN_VP_EXIT_REASON}; diff --git a/src/hyperlight_host/src/hypervisor/kvm.rs b/src/hyperlight_host/src/hypervisor/kvm.rs index b3f0fe6d8..355391230 100644 --- a/src/hyperlight_host/src/hypervisor/kvm.rs +++ b/src/hyperlight_host/src/hypervisor/kvm.rs @@ -21,8 +21,8 @@ use std::sync::{Arc, Mutex}; use kvm_bindings::{kvm_fpu, kvm_regs, kvm_sregs, kvm_userspace_memory_region}; use kvm_ioctls::Cap::UserMemory; use kvm_ioctls::{Kvm, VcpuExit, VcpuFd, VmFd}; -use tracing::{Span, info, instrument}; use tracing::log::LevelFilter; +use tracing::{Span, info, instrument}; #[cfg(feature = "trace_guest")] use tracing_opentelemetry::OpenTelemetrySpanExt; #[cfg(crashdump)] diff --git a/src/hyperlight_host/src/hypervisor/mod.rs b/src/hyperlight_host/src/hypervisor/mod.rs index 57f3d18f7..5ad834b9d 100644 --- a/src/hyperlight_host/src/hypervisor/mod.rs +++ b/src/hyperlight_host/src/hypervisor/mod.rs @@ -885,6 +885,7 @@ pub(crate) mod tests { use crate::mem::ptr::RawPtr; use crate::sandbox::host_funcs::FunctionRegistry; + use tracing::log::LevelFilter; let filename = dummy_guest_as_string().map_err(|e| new_error!("{}", e))?; @@ -907,7 +908,7 @@ pub(crate) mod tests { let seed = 12345u64; // Random seed let page_size = 4096u32; // Standard page size let host_funcs = Arc::new(Mutex::new(FunctionRegistry::default())); - let guest_max_log_level = Some(log::LevelFilter::Error); + let guest_max_log_level = Some(LevelFilter::Error); #[cfg(gdb)] let dbg_mem_access_fn = Arc::new(Mutex::new(mem_mgr.clone())); diff --git a/src/hyperlight_host/src/sandbox/outb.rs b/src/hyperlight_host/src/sandbox/outb.rs index 3629369ed..c6c4b1245 100644 --- a/src/hyperlight_host/src/sandbox/outb.rs +++ b/src/hyperlight_host/src/sandbox/outb.rs @@ -46,7 +46,7 @@ pub(super) fn outb_log(mgr: &mut SandboxMemoryManager) -> Resu // Convert from our LogLevel to tracing::Level let tracing_level: tracing::Level = (&log_data.level).into(); - + // Convert tracing::Level to log::Level for the Record API let record_level: Level = match tracing_level { tracing::Level::TRACE => Level::Trace, @@ -207,7 +207,7 @@ pub(crate) fn handle_outb( mod tests { use hyperlight_common::flatbuffer_wrappers::guest_log_level::LogLevel; use hyperlight_testing::logger::{LOGGER, Logger}; - use log::Level; + use tracing::log::{Level, LevelFilter}; use tracing_core::callsite::rebuild_interest_cache; use super::outb_log; @@ -234,7 +234,7 @@ mod tests { #[ignore] fn test_log_outb_log() { Logger::initialize_test_logger(); - LOGGER.set_max_level(log::LevelFilter::Off); + LOGGER.set_max_level(LevelFilter::Off); let sandbox_cfg = SandboxConfiguration::default(); @@ -281,7 +281,7 @@ mod tests { } { // now, test logging - LOGGER.set_max_level(log::LevelFilter::Trace); + LOGGER.set_max_level(LevelFilter::Trace); let mut mgr = new_mgr(); LOGGER.clear_log_calls(); @@ -314,7 +314,15 @@ mod tests { outb_log(&mut mgr).unwrap(); LOGGER.test_log_records(|log_calls| { - let expected_level: Level = (&level).into(); + // Convert through tracing::Level first + let tracing_level: tracing::Level = (&level).into(); + let expected_level: Level = match tracing_level { + tracing::Level::TRACE => Level::Trace, + tracing::Level::DEBUG => Level::Debug, + tracing::Level::INFO => Level::Info, + tracing::Level::WARN => Level::Warn, + tracing::Level::ERROR => Level::Error, + }; assert!( log_calls diff --git a/src/hyperlight_host/src/sandbox/uninitialized.rs b/src/hyperlight_host/src/sandbox/uninitialized.rs index 05da9c128..5cfbab997 100644 --- a/src/hyperlight_host/src/sandbox/uninitialized.rs +++ b/src/hyperlight_host/src/sandbox/uninitialized.rs @@ -19,8 +19,8 @@ use std::option::Option; use std::path::Path; use std::sync::{Arc, Mutex}; -use tracing::{Span, instrument}; use tracing::log::LevelFilter; +use tracing::{Span, instrument}; use super::host_funcs::{FunctionRegistry, default_writer_func}; use super::uninitialized_evolve::evolve_impl_multi_use; @@ -906,12 +906,13 @@ mod tests { use std::path::PathBuf; use hyperlight_testing::logger::{LOGGER as TEST_LOGGER, Logger as TestLogger}; - use log::Level; + use tracing::log::Level; + use tracing::log::LevelFilter; use tracing_core::callsite::rebuild_interest_cache; { TestLogger::initialize_test_logger(); - TEST_LOGGER.set_max_level(log::LevelFilter::Trace); + TEST_LOGGER.set_max_level(LevelFilter::Trace); // This makes sure that the metadata interest cache is rebuilt so that // the log records are emitted for the trace records @@ -983,7 +984,7 @@ mod tests { { // test to ensure an invalid binary logs & traces properly TEST_LOGGER.clear_log_calls(); - TEST_LOGGER.set_max_level(log::LevelFilter::Info); + TEST_LOGGER.set_max_level(LevelFilter::Info); let mut valid_binary_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); valid_binary_path.push("src"); @@ -1022,7 +1023,7 @@ mod tests { } { TEST_LOGGER.clear_log_calls(); - TEST_LOGGER.set_max_level(log::LevelFilter::Error); + TEST_LOGGER.set_max_level(LevelFilter::Error); let sbox = { let res = UninitializedSandbox::new( diff --git a/src/hyperlight_host/tests/integration_test.rs b/src/hyperlight_host/tests/integration_test.rs index fc735974b..b4ac739ea 100644 --- a/src/hyperlight_host/tests/integration_test.rs +++ b/src/hyperlight_host/tests/integration_test.rs @@ -25,7 +25,7 @@ use hyperlight_host::sandbox::SandboxConfiguration; use hyperlight_host::{GuestBinary, HyperlightError, MultiUseSandbox, UninitializedSandbox}; use hyperlight_testing::simplelogger::{LOGGER, SimpleLogger}; use hyperlight_testing::{c_simple_guest_as_string, simple_guest_as_string}; -use log::LevelFilter; +use tracing::log::LevelFilter; pub mod common; // pub to disable dead_code warning use crate::common::{new_uninit, new_uninit_c, new_uninit_rust}; @@ -774,10 +774,10 @@ fn log_message() { assert_eq!(1, LOGGER.num_log_calls()); } -fn log_test_messages(levelfilter: Option) { +fn log_test_messages(levelfilter: Option) { LOGGER.clear_log_calls(); assert_eq!(0, LOGGER.num_log_calls()); - for level in log::LevelFilter::iter() { + for level in LevelFilter::iter() { let mut sbox = new_uninit().unwrap(); if let Some(levelfilter) = levelfilter { sbox.set_max_guest_log_level(levelfilter); @@ -903,7 +903,7 @@ fn interrupt_random_kill_stress_test() { use std::sync::atomic::AtomicUsize; use hyperlight_host::sandbox::snapshot::Snapshot; - use log::{error, trace}; + use tracing::log::{error, trace}; const POOL_SIZE: usize = 100; const NUM_THREADS: usize = 100; From f4dd6d21f45600d6343f4b4a5be77ead3d6a9276 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 26 Nov 2025 01:29:52 +0000 Subject: [PATCH 4/4] Remove redundant parent = Span::current() from instrument attributes Co-authored-by: jsturtevant <648372+jsturtevant@users.noreply.github.com> --- .../src/flatbuffer_wrappers/function_call.rs | 10 ++-- .../src/flatbuffer_wrappers/function_types.rs | 56 +++++++++---------- .../src/flatbuffer_wrappers/guest_error.rs | 6 +- .../src/flatbuffer_wrappers/guest_log_data.rs | 12 ++-- .../flatbuffer_wrappers/guest_log_level.rs | 8 +-- .../host_function_definition.rs | 14 ++--- .../host_function_details.rs | 6 +- src/hyperlight_host/src/hypervisor/mod.rs | 5 +- .../src/sandbox/uninitialized.rs | 3 +- 9 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/function_call.rs b/src/hyperlight_common/src/flatbuffer_wrappers/function_call.rs index 679b7577b..d62262c36 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/function_call.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/function_call.rs @@ -19,7 +19,7 @@ use alloc::vec::Vec; use anyhow::{Error, Result, bail}; use flatbuffers::{FlatBufferBuilder, WIPOffset, size_prefixed_root}; -use tracing::{Span, instrument}; +use tracing::instrument; use super::function_types::{ParameterValue, ReturnType}; use crate::flatbuffers::hyperlight::generated::{ @@ -52,7 +52,7 @@ pub struct FunctionCall { } impl FunctionCall { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] + #[instrument(skip_all, level = "Trace")] pub fn new( function_name: String, parameters: Option>, @@ -213,7 +213,7 @@ impl FunctionCall { } } -#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] +#[instrument(err(Debug), skip_all, level = "Trace")] pub fn validate_guest_function_call_buffer(function_call_buffer: &[u8]) -> Result<()> { let guest_function_call_fb = size_prefixed_root::(function_call_buffer) .map_err(|e| anyhow::anyhow!("Error reading function call buffer: {:?}", e))?; @@ -225,7 +225,7 @@ pub fn validate_guest_function_call_buffer(function_call_buffer: &[u8]) -> Resul } } -#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] +#[instrument(err(Debug), skip_all, level = "Trace")] pub fn validate_host_function_call_buffer(function_call_buffer: &[u8]) -> Result<()> { let host_function_call_fb = size_prefixed_root::(function_call_buffer) .map_err(|e| anyhow::anyhow!("Error reading function call buffer: {:?}", e))?; @@ -239,7 +239,7 @@ pub fn validate_host_function_call_buffer(function_call_buffer: &[u8]) -> Result impl TryFrom<&[u8]> for FunctionCall { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: &[u8]) -> Result { let function_call_fb = size_prefixed_root::(value) .map_err(|e| anyhow::anyhow!("Error reading function call buffer: {:?}", e))?; diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/function_types.rs b/src/hyperlight_common/src/flatbuffer_wrappers/function_types.rs index 8a08808c3..9b9f768b1 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/function_types.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/function_types.rs @@ -19,7 +19,7 @@ use alloc::vec::Vec; use anyhow::{Error, Result, anyhow, bail}; use flatbuffers::size_prefixed_root; -use tracing::{Span, instrument}; +use tracing::instrument; use super::guest_error::GuestError; use crate::flatbuffers::hyperlight::generated::{ @@ -283,7 +283,7 @@ pub enum ReturnType { } impl From<&ParameterValue> for ParameterType { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] + #[instrument(skip_all, level = "Trace")] fn from(value: &ParameterValue) -> Self { match *value { ParameterValue::Int(_) => ParameterType::Int, @@ -302,7 +302,7 @@ impl From<&ParameterValue> for ParameterType { impl TryFrom> for ParameterValue { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(param: Parameter<'_>) -> Result { let value = param.value_type(); let result = match value { @@ -342,7 +342,7 @@ impl TryFrom> for ParameterValue { } impl From for FbParameterType { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] + #[instrument(skip_all, level = "Trace")] fn from(value: ParameterType) -> Self { match value { ParameterType::Int => FbParameterType::hlint, @@ -359,7 +359,7 @@ impl From for FbParameterType { } impl From for FbReturnType { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] + #[instrument(skip_all, level = "Trace")] fn from(value: ReturnType) -> Self { match value { ReturnType::Int => FbReturnType::hlint, @@ -378,7 +378,7 @@ impl From for FbReturnType { impl TryFrom for ParameterType { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: FbParameterType) -> Result { match value { FbParameterType::hlint => Ok(ParameterType::Int), @@ -399,7 +399,7 @@ impl TryFrom for ParameterType { impl TryFrom for ReturnType { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: FbReturnType) -> Result { match value { FbReturnType::hlint => Ok(ReturnType::Int), @@ -421,7 +421,7 @@ impl TryFrom for ReturnType { impl TryFrom for i32 { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: ParameterValue) -> Result { match value { ParameterValue::Int(v) => Ok(v), @@ -434,7 +434,7 @@ impl TryFrom for i32 { impl TryFrom for u32 { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: ParameterValue) -> Result { match value { ParameterValue::UInt(v) => Ok(v), @@ -447,7 +447,7 @@ impl TryFrom for u32 { impl TryFrom for i64 { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: ParameterValue) -> Result { match value { ParameterValue::Long(v) => Ok(v), @@ -460,7 +460,7 @@ impl TryFrom for i64 { impl TryFrom for u64 { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: ParameterValue) -> Result { match value { ParameterValue::ULong(v) => Ok(v), @@ -473,7 +473,7 @@ impl TryFrom for u64 { impl TryFrom for f32 { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: ParameterValue) -> Result { match value { ParameterValue::Float(v) => Ok(v), @@ -486,7 +486,7 @@ impl TryFrom for f32 { impl TryFrom for f64 { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: ParameterValue) -> Result { match value { ParameterValue::Double(v) => Ok(v), @@ -499,7 +499,7 @@ impl TryFrom for f64 { impl TryFrom for String { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: ParameterValue) -> Result { match value { ParameterValue::String(v) => Ok(v), @@ -512,7 +512,7 @@ impl TryFrom for String { impl TryFrom for bool { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: ParameterValue) -> Result { match value { ParameterValue::Bool(v) => Ok(v), @@ -525,7 +525,7 @@ impl TryFrom for bool { impl TryFrom for Vec { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: ParameterValue) -> Result { match value { ParameterValue::VecBytes(v) => Ok(v), @@ -538,7 +538,7 @@ impl TryFrom for Vec { impl TryFrom for i32 { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: ReturnValue) -> Result { match value { ReturnValue::Int(v) => Ok(v), @@ -551,7 +551,7 @@ impl TryFrom for i32 { impl TryFrom for u32 { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: ReturnValue) -> Result { match value { ReturnValue::UInt(v) => Ok(v), @@ -564,7 +564,7 @@ impl TryFrom for u32 { impl TryFrom for i64 { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: ReturnValue) -> Result { match value { ReturnValue::Long(v) => Ok(v), @@ -577,7 +577,7 @@ impl TryFrom for i64 { impl TryFrom for u64 { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: ReturnValue) -> Result { match value { ReturnValue::ULong(v) => Ok(v), @@ -590,7 +590,7 @@ impl TryFrom for u64 { impl TryFrom for f32 { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: ReturnValue) -> Result { match value { ReturnValue::Float(v) => Ok(v), @@ -603,7 +603,7 @@ impl TryFrom for f32 { impl TryFrom for f64 { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: ReturnValue) -> Result { match value { ReturnValue::Double(v) => Ok(v), @@ -616,7 +616,7 @@ impl TryFrom for f64 { impl TryFrom for String { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: ReturnValue) -> Result { match value { ReturnValue::String(v) => Ok(v), @@ -629,7 +629,7 @@ impl TryFrom for String { impl TryFrom for bool { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: ReturnValue) -> Result { match value { ReturnValue::Bool(v) => Ok(v), @@ -642,7 +642,7 @@ impl TryFrom for bool { impl TryFrom for Vec { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: ReturnValue) -> Result { match value { ReturnValue::VecBytes(v) => Ok(v), @@ -655,7 +655,7 @@ impl TryFrom for Vec { impl TryFrom for () { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: ReturnValue) -> Result { match value { ReturnValue::Void(()) => Ok(()), @@ -668,7 +668,7 @@ impl TryFrom for () { impl TryFrom> for ReturnValue { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(return_value_box: ReturnValueBox<'_>) -> Result { match return_value_box.value_type() { FbReturnValue::hlint => { @@ -739,7 +739,7 @@ impl TryFrom> for ReturnValue { impl TryFrom<&ReturnValue> for Vec { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: &ReturnValue) -> Result> { let mut builder = flatbuffers::FlatBufferBuilder::new(); let result_bytes = match value { diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/guest_error.rs b/src/hyperlight_common/src/flatbuffer_wrappers/guest_error.rs index 9045a2c7a..d01cc948b 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/guest_error.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/guest_error.rs @@ -18,7 +18,7 @@ extern crate flatbuffers; use alloc::string::{String, ToString}; -use tracing::{Span, instrument}; +use tracing::instrument; use crate::flatbuffers::hyperlight::generated::ErrorCode as FbErrorCode; @@ -188,14 +188,14 @@ pub struct GuestError { } impl GuestError { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] + #[instrument(skip_all, level = "Trace")] pub fn new(code: ErrorCode, message: String) -> Self { Self { code, message } } } impl Default for GuestError { - #[instrument(parent = Span::current(), level= "Trace")] + #[instrument(level = "Trace")] fn default() -> Self { Self { code: ErrorCode::NoError, diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_data.rs b/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_data.rs index a307ec7b0..67c77631e 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_data.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_data.rs @@ -19,7 +19,7 @@ use alloc::vec::Vec; use anyhow::{Error, Result, anyhow}; use flatbuffers::size_prefixed_root; -use tracing::{Span, instrument}; +use tracing::instrument; use super::guest_log_level::LogLevel; use crate::flatbuffers::hyperlight::generated::{ @@ -39,7 +39,7 @@ pub struct GuestLogData { } impl GuestLogData { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] + #[instrument(skip_all, level = "Trace")] pub fn new( message: String, source: String, @@ -61,7 +61,7 @@ impl GuestLogData { impl TryFrom<&[u8]> for GuestLogData { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(raw_bytes: &[u8]) -> Result { let gld_gen = size_prefixed_root::(raw_bytes) .map_err(|e| anyhow!("Error while reading GuestLogData: {:?}", e))?; @@ -85,7 +85,7 @@ impl TryFrom<&[u8]> for GuestLogData { impl TryFrom<&GuestLogData> for Vec { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: &GuestLogData) -> Result> { let mut builder = flatbuffers::FlatBufferBuilder::new(); let message = builder.create_string(&value.message); @@ -114,13 +114,13 @@ impl TryFrom<&GuestLogData> for Vec { impl TryFrom for Vec { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: GuestLogData) -> Result> { (&value).try_into() } } -#[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] +#[instrument(err(Debug), skip_all, level = "Trace")] fn convert_generated_option(field_name: &str, opt: Option<&str>) -> Result { opt.map(|s| s.to_string()) .ok_or_else(|| anyhow!("Missing field: {}", field_name)) diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_level.rs b/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_level.rs index 1f837a440..b375054b6 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_level.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/guest_log_level.rs @@ -15,7 +15,7 @@ limitations under the License. */ use anyhow::{Error, Result, bail}; -use tracing::{Level, Span, instrument}; +use tracing::{Level, instrument}; use crate::flatbuffers::hyperlight::generated::LogLevel as FbLogLevel; @@ -32,7 +32,7 @@ pub enum LogLevel { } impl From for LogLevel { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] + #[instrument(skip_all, level = "Trace")] fn from(val: u8) -> LogLevel { match val { 0 => LogLevel::Trace, @@ -48,7 +48,7 @@ impl From for LogLevel { impl TryFrom<&FbLogLevel> for LogLevel { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(val: &FbLogLevel) -> Result { match *val { FbLogLevel::Trace => Ok(LogLevel::Trace), @@ -66,7 +66,7 @@ impl TryFrom<&FbLogLevel> for LogLevel { } impl From<&LogLevel> for FbLogLevel { - #[instrument(skip_all, parent = Span::current(), level= "Trace")] + #[instrument(skip_all, level = "Trace")] fn from(val: &LogLevel) -> FbLogLevel { match val { LogLevel::Critical => FbLogLevel::Critical, diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/host_function_definition.rs b/src/hyperlight_common/src/flatbuffer_wrappers/host_function_definition.rs index 4537bb50e..1741dbeae 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/host_function_definition.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/host_function_definition.rs @@ -19,7 +19,7 @@ use alloc::vec::Vec; use anyhow::{Error, Result, anyhow}; use flatbuffers::{FlatBufferBuilder, WIPOffset}; -use tracing::{Span, instrument}; +use tracing::instrument; use super::function_types::{ParameterType, ReturnType}; use crate::flatbuffers::hyperlight::generated::{ @@ -40,7 +40,7 @@ pub struct HostFunctionDefinition { impl HostFunctionDefinition { /// Create a new `HostFunctionDefinition`. - #[instrument(skip_all, parent = Span::current(), level= "Trace")] + #[instrument(skip_all, level = "Trace")] pub fn new( function_name: String, parameter_types: Option>, @@ -54,7 +54,7 @@ impl HostFunctionDefinition { } /// Convert this `HostFunctionDefinition` into a `WIPOffset`. - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] pub(crate) fn convert_to_flatbuffer_def<'a>( &self, builder: &mut FlatBufferBuilder<'a>, @@ -88,7 +88,7 @@ impl HostFunctionDefinition { } /// Verify that the function call has the correct parameter types. - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] pub fn verify_equal_parameter_types( &self, function_call_parameter_types: &[ParameterType], @@ -106,7 +106,7 @@ impl HostFunctionDefinition { impl TryFrom<&FbHostFunctionDefinition<'_>> for HostFunctionDefinition { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: &FbHostFunctionDefinition) -> Result { let function_name = value.function_name().to_string(); let return_type = value.return_type().try_into().map_err(|_| { @@ -139,7 +139,7 @@ impl TryFrom<&FbHostFunctionDefinition<'_>> for HostFunctionDefinition { impl TryFrom<&[u8]> for HostFunctionDefinition { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: &[u8]) -> Result { let fb_host_function_definition = flatbuffers::root::>(value) .map_err(|e| anyhow!("Error while reading HostFunctionDefinition: {:?}", e))?; @@ -149,7 +149,7 @@ impl TryFrom<&[u8]> for HostFunctionDefinition { impl TryFrom<&HostFunctionDefinition> for Vec { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(hfd: &HostFunctionDefinition) -> Result> { let mut builder = flatbuffers::FlatBufferBuilder::new(); let host_function_definition = hfd.convert_to_flatbuffer_def(&mut builder)?; diff --git a/src/hyperlight_common/src/flatbuffer_wrappers/host_function_details.rs b/src/hyperlight_common/src/flatbuffer_wrappers/host_function_details.rs index ccea1cb31..3b0315487 100644 --- a/src/hyperlight_common/src/flatbuffer_wrappers/host_function_details.rs +++ b/src/hyperlight_common/src/flatbuffer_wrappers/host_function_details.rs @@ -18,7 +18,7 @@ use alloc::vec::Vec; use anyhow::{Error, Result}; use flatbuffers::{WIPOffset, size_prefixed_root}; -use tracing::{Span, instrument}; +use tracing::instrument; use super::host_function_definition::HostFunctionDefinition; use crate::flatbuffers::hyperlight::generated::{ @@ -36,7 +36,7 @@ pub struct HostFunctionDetails { impl TryFrom<&[u8]> for HostFunctionDetails { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: &[u8]) -> Result { let host_function_details_fb = size_prefixed_root::(value) .map_err(|e| anyhow::anyhow!("Error while reading HostFunctionDetails: {:?}", e))?; @@ -65,7 +65,7 @@ impl TryFrom<&[u8]> for HostFunctionDetails { impl TryFrom<&HostFunctionDetails> for Vec { type Error = Error; - #[instrument(err(Debug), skip_all, parent = Span::current(), level= "Trace")] + #[instrument(err(Debug), skip_all, level = "Trace")] fn try_from(value: &HostFunctionDetails) -> Result> { let mut builder = flatbuffers::FlatBufferBuilder::new(); let vec_host_function_definitions = match &value.host_functions { diff --git a/src/hyperlight_host/src/hypervisor/mod.rs b/src/hyperlight_host/src/hypervisor/mod.rs index 5ad834b9d..495bd84a6 100644 --- a/src/hyperlight_host/src/hypervisor/mod.rs +++ b/src/hyperlight_host/src/hypervisor/mod.rs @@ -14,8 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ -use tracing::{Span, debug, info, instrument}; use tracing::log::LevelFilter; +use tracing::{Span, debug, info, instrument}; use crate::HyperlightError::StackOverflow; use crate::error::HyperlightError::ExecutionCanceledByHost; @@ -883,9 +883,10 @@ pub(crate) mod tests { return Ok(()); } + use tracing::log::LevelFilter; + use crate::mem::ptr::RawPtr; use crate::sandbox::host_funcs::FunctionRegistry; - use tracing::log::LevelFilter; let filename = dummy_guest_as_string().map_err(|e| new_error!("{}", e))?; diff --git a/src/hyperlight_host/src/sandbox/uninitialized.rs b/src/hyperlight_host/src/sandbox/uninitialized.rs index 5cfbab997..dc82f4727 100644 --- a/src/hyperlight_host/src/sandbox/uninitialized.rs +++ b/src/hyperlight_host/src/sandbox/uninitialized.rs @@ -906,8 +906,7 @@ mod tests { use std::path::PathBuf; use hyperlight_testing::logger::{LOGGER as TEST_LOGGER, Logger as TestLogger}; - use tracing::log::Level; - use tracing::log::LevelFilter; + use tracing::log::{Level, LevelFilter}; use tracing_core::callsite::rebuild_interest_cache; {