Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
* **Breaking:** Generated libc bindings use `usize` for `size_t` arguments and return values, including `strlen` and `memcpy`. Rust callers that use `u64` or `c_ulong` need explicit conversions. The C ABI is unchanged.

### Removed
* **Breaking:** The `print_debug` cargo feature and the exported `hyperlight_host::debug!` macro. Use `tracing::debug!` with a subscriber.
* **Breaking:** The `build-metadata` cargo feature. A library should not log build details, and for crates.io users its git fields were always empty. Applications can log build details with their own tooling.

### Fixed

Expand Down
53 changes: 0 additions & 53 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ test-like-ci config=default-target hypervisor="kvm":
@# with default features
just test {{config}}

@# with only one driver enabled + build-metadata
just test {{config}} build-metadata,{{ if hypervisor == "mshv3" {"mshv3"} else {"kvm"} }}
@# with only one driver enabled
just test {{config}} {{ if hypervisor == "mshv3" {"mshv3"} else {"kvm"} }}

@# with hw-interrupts enabled (+ explicit driver on Linux)
{{ if os() == "linux" { if hypervisor == "mshv3" { "just test " + config + " mshv3,hw-interrupts" } else { "just test " + config + " kvm,hw-interrupts" } } else { "just test " + config + " hw-interrupts" } }}
Expand Down Expand Up @@ -375,7 +375,6 @@ miri-tests: (ensure-cargo-nextest) (ensure-nightly-miri)
check:
{{ cargo-cmd }} check {{ target-triple-flag }}
{{ cargo-cmd }} check -p hyperlight-host --features crashdump {{ target-triple-flag }}
{{ cargo-cmd }} check -p hyperlight-host --features print_debug {{ target-triple-flag }}
{{ cargo-cmd }} check -p hyperlight-host --features gdb {{ target-triple-flag }}
{{ cargo-cmd }} check -p hyperlight-host --features trace_guest,mem_profile {{ target-triple-flag }}
{{ cargo-cmd }} check -p hyperlight-host --features hw-interrupts {{ target-triple-flag }}
Expand Down Expand Up @@ -587,8 +586,8 @@ coverage-run hypervisor="kvm": ensure-cargo-llvm-cov
# tests with default features (all drivers; skip stress tests — too slow under instrumentation)
cargo +{{nightly-toolchain}} test {{ coverage-packages }} --tests -- --skip stress_test

# tests with single driver + build-metadata
cargo +{{nightly-toolchain}} test {{ coverage-packages }} --no-default-features --features build-metadata,{{ if hypervisor == "mshv3" { "mshv3" } else { "kvm" } }} --tests -- --skip stress_test
# tests with single driver
cargo +{{nightly-toolchain}} test {{ coverage-packages }} --no-default-features --features {{ if hypervisor == "mshv3" { "mshv3" } else { "kvm" } }} --tests -- --skip stress_test

# isolated tests (require running separately due to global state)
cargo +{{nightly-toolchain}} test -p hyperlight-host --lib -- sandbox::uninitialized::tests::test_log_trace --exact --ignored
Expand Down
4 changes: 2 additions & 2 deletions docs/how-to-run-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ We use [cargo-llvm-cov](https://github.com/taiki-e/cargo-llvm-cov) over alternat

The `coverage-run` recipe mirrors the `test-like-ci` + `run-examples-like-ci` workflows by running all test phases and examples with different feature combinations:

1. **Default features** — all drivers enabled (kvm + mshv3 + build-metadata)
2. **Single driver** — only one hypervisor driver + build-metadata
1. **Default features** — all drivers enabled (kvm + mshv3)
2. **Single driver** — only one hypervisor driver
3. **Isolated tests** — tests that require running separately due to global state
4. **Integration tests** — including `executable_heap` feature
5. **Crashdump** — tests + example with the `crashdump` feature enabled
Expand Down
2 changes: 1 addition & 1 deletion hack/clippy-package-features.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fi
EXCLUDED_FEATURES=("${REQUIRED_FEATURES[@]}")

if [[ -n "${TARGET_TRIPLE}" && "$TARGET_TRIPLE" =~ aarch64 ]] || [[ -z "${TARGET_TRIPLE}" && "$(uname -m)" = "aarch64" ]]; then
EXCLUDED_FEATURES+=("crashdump" "trace_guest" "mem_profile" "hw-interrupts" "gdb" "i686-guest" "nanvix-unstable")
EXCLUDED_FEATURES+=("crashdump" "trace_guest" "mem_profile" "hw-interrupts" "gdb")
fi

# Get all features for the package (excluding default and required features)
Expand Down
2 changes: 1 addition & 1 deletion src/hyperlight_common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
edition.workspace = true
rust-version.workspace = true
license.workspace = true
homepage.workspace = true

Check warning on line 7 in src/hyperlight_common/Cargo.toml

View workflow job for this annotation

GitHub Actions / miri (X64) / miri

`package.homepage` is redundant with `package.repository`

Check warning on line 7 in src/hyperlight_common/Cargo.toml

View workflow job for this annotation

GitHub Actions / miri (X64) / miri

`package.homepage` is redundant with `package.repository`

Check warning on line 7 in src/hyperlight_common/Cargo.toml

View workflow job for this annotation

GitHub Actions / miri (arm64) / miri

`package.homepage` is redundant with `package.repository`

Check warning on line 7 in src/hyperlight_common/Cargo.toml

View workflow job for this annotation

GitHub Actions / miri (arm64) / miri

`package.homepage` is redundant with `package.repository`
repository.workspace = true
readme.workspace = true
description = """
Expand Down Expand Up @@ -35,7 +35,7 @@
fuzzing = ["dep:arbitrary"]
trace_guest = []
mem_profile = []
std = ["thiserror/std", "log/std", "tracing/std"]
std = ["thiserror/std", "log/std", "tracing?/std"]

[dev-dependencies]
criterion = "0.8.1"
Expand Down
2 changes: 1 addition & 1 deletion src/hyperlight_guest_bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
edition.workspace = true
rust-version.workspace = true
license.workspace = true
homepage.workspace = true

Check warning on line 7 in src/hyperlight_guest_bin/Cargo.toml

View workflow job for this annotation

GitHub Actions / miri (X64) / miri

`package.homepage` is redundant with `package.repository`

Check warning on line 7 in src/hyperlight_guest_bin/Cargo.toml

View workflow job for this annotation

GitHub Actions / miri (arm64) / miri

`package.homepage` is redundant with `package.repository`
repository.workspace = true
readme.workspace = true
description = """
Expand All @@ -15,7 +15,7 @@
[features]
default = ["libc", "macros"]
libc = ["dep:hyperlight-libc"] # compile libc from picolibc
trace_guest = ["hyperlight-common/trace_guest", "hyperlight-guest/trace_guest", "hyperlight-guest-tracing/trace"]
trace_guest = ["hyperlight-guest/trace_guest", "hyperlight-guest-tracing/trace"]
mem_profile = ["hyperlight-common/mem_profile"]
macros = ["dep:hyperlight-guest-macro", "dep:linkme"]

Expand Down
6 changes: 1 addition & 5 deletions src/hyperlight_host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
edition.workspace = true
rust-version.workspace = true
license.workspace = true
homepage.workspace = true

Check warning on line 7 in src/hyperlight_host/Cargo.toml

View workflow job for this annotation

GitHub Actions / miri (X64) / miri

`package.homepage` is redundant with `package.repository`

Check warning on line 7 in src/hyperlight_host/Cargo.toml

View workflow job for this annotation

GitHub Actions / miri (arm64) / miri

`package.homepage` is redundant with `package.repository`
repository.workspace = true
readme.workspace = true
description = """
Expand Down Expand Up @@ -122,16 +122,13 @@
[build-dependencies]
anyhow = { version = "1.0.102" }
cfg_aliases = "0.2.1"
built = { version = "0.8.1", optional = true, features = ["chrono", "git2"] }
bindgen = { version = "0.72", features = ["prettyplease"] }
cc = "1.2"

[features]
default = ["kvm", "mshv3", "hvf", "build-metadata"]
default = ["kvm", "mshv3", "hvf"]
function_call_metrics = []
executable_heap = []
# This feature enables printing of debug information to stdout in debug builds
print_debug = []
# Dumps the VM state to a file on unexpected errors or crashes. The path of the file will be printed on stdout and logged.
crashdump = ["dep:chrono", "dep:elfcore"]
trace_guest = ["dep:opentelemetry", "dep:tracing-opentelemetry", "dep:hyperlight-guest-tracing", "hyperlight-common/trace_guest"]
Expand All @@ -143,7 +140,6 @@
# This enables easy debug in the guest
gdb = ["dep:gdbstub", "dep:gdbstub_arch"]
fuzzing = ["hyperlight-common/fuzzing"]
build-metadata = ["dep:built"]

[[bench]]
name = "benchmarks"
Expand Down
7 changes: 0 additions & 7 deletions src/hyperlight_host/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Copyright 2025 The Hyperlight Authors.

use anyhow::{Context, Result};
#[cfg(feature = "build-metadata")]
use built::write_built_file;

fn main() -> Result<()> {
// re-run the build if this script is changed (or deleted!),
Expand Down Expand Up @@ -155,8 +153,6 @@ fn main() -> Result<()> {
mshv3: { all(feature = "mshv3", target_os = "linux") },
hvf: { all(feature = "hvf", target_os = "macos") },
crashdump: { all(feature = "crashdump", target_arch = "x86_64") },
// print_debug feature is aliased with debug_assertions to make it only available in debug-builds.
print_debug: { all(feature = "print_debug", debug_assertions) },
// the gdb feature (only temporarily!) needs to use
// writable/un-shared snapshot memories.
unshared_snapshot_mem: { gdb },
Expand All @@ -176,8 +172,5 @@ fn main() -> Result<()> {
readable_shared_mem: { any(gdb, all(feature = "mem_profile", not(unshared_snapshot_mem))) },
}

#[cfg(feature = "build-metadata")]
write_built_file()?;

Ok(())
}
74 changes: 0 additions & 74 deletions src/hyperlight_host/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@
#![cfg_attr(not(any(test, debug_assertions)), warn(clippy::expect_used))]
#![cfg_attr(not(any(test, debug_assertions)), warn(clippy::unwrap_used))]

#[cfg(feature = "build-metadata")]
use std::sync::Once;

#[cfg(feature = "build-metadata")]
/// The `built` crate is used to generate a `built.rs` file that contains
/// information about the build environment. This information is used to
/// populate the `built_info` module, which is re-exported here.
pub(crate) mod built_info {
include!(concat!(env!("OUT_DIR"), "/built.rs"));
}
/// Dealing with errors, including errors across VM boundaries
pub mod error;
/// Wrappers for host and guest functions.
Expand Down Expand Up @@ -135,67 +125,3 @@ macro_rules! log_then_return {
return Err(__err);
};
}

/// 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)+);
tracing::debug!($($arg)+);
}
}

// LOG_ONCE is used to log information about the crate version once
#[cfg(feature = "build-metadata")]
static LOG_ONCE: Once = Once::new();

#[cfg(feature = "build-metadata")]
pub(crate) fn log_build_details() {
use tracing::info;
LOG_ONCE.call_once(|| {
info!("Package name: {}", built_info::PKG_NAME);
info!("Package version: {}", built_info::PKG_VERSION);
info!("Package features: {:?}", built_info::FEATURES);
info!("Target triple: {}", built_info::TARGET);
info!("Optimization level: {}", built_info::OPT_LEVEL);
info!("Profile: {}", built_info::PROFILE);
info!("Debug: {}", built_info::DEBUG);
info!("Rustc: {}", built_info::RUSTC);
info!("Built at: {}", built_info::BUILT_TIME_UTC);
match built_info::CI_PLATFORM.unwrap_or("") {
"" => info!("Not built on a CI platform"),
other => info!("Built on : {}", other),
}
match built_info::GIT_COMMIT_HASH.unwrap_or("") {
"" => info!("No git commit hash found"),
other => info!("Git commit hash: {}", other),
}

let git = match built_info::GIT_HEAD_REF.unwrap_or("") {
"" => {
info!("No git head ref found");
false
}
other => {
info!("Git head ref: {}", other);
true
}
};
match built_info::GIT_VERSION.unwrap_or("") {
"" => info!("No git version found"),
other => info!("Git version: {}", other),
}
match built_info::GIT_DIRTY.unwrap_or(false) {
true => info!("Repo had uncommitted changes"),
false => {
if git {
info!("Repo had no uncommitted changes")
} else {
info!("No git repo found")
}
}
}
});
}
2 changes: 1 addition & 1 deletion src/hyperlight_host/src/sandbox/trace/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ impl TraceContext {

pub(crate) fn setup_guest_trace(&mut self, ctx: Context) {
if self.start_instant.is_none() {
crate::debug!("Guest Start Epoch set");
tracing::debug!("Guest Start Epoch set");
self.start_wall = Some(SystemTime::now());
self.start_tsc = Some(hyperlight_guest_tracing::invariant_tsc::read_tsc());
self.start_instant = Some(std::time::Instant::now());
Expand Down
9 changes: 1 addition & 8 deletions src/hyperlight_host/src/sandbox/uninitialized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ use super::snapshot::Snapshot;
use super::uninitialized_evolve::initialize_sandbox;
use crate::func::host_functions::{HostFunction, register_host_function};
use crate::func::{ParameterTuple, SupportedReturnType};
#[cfg(feature = "build-metadata")]
use crate::log_build_details;
use crate::mem::memory_region::{DEFAULT_GUEST_BLOB_MEM_FLAGS, MemoryRegionFlags};
use crate::mem::mgr::SandboxMemoryManager;
use crate::mem::shared_mem::{ExclusiveSharedMemory, SharedMemory};
Expand Down Expand Up @@ -142,9 +140,6 @@ impl UninitializedSandbox {
//
// This is ok for now as this is not a public function
fn from_snapshot(snapshot: Arc<Snapshot>, cfg: Option<SandboxConfiguration>) -> Result<Self> {
#[cfg(feature = "build-metadata")]
log_build_details();

// hyperlight is only supported on Windows 11 and Windows Server 2022 and later
#[cfg(target_os = "windows")]
check_windows_version()?;
Expand All @@ -165,7 +160,7 @@ impl UninitializedSandbox {
pending_file_mappings: Vec::new(),
};

crate::debug!("Sandbox created: {:#?}", sandbox);
tracing::debug!("Sandbox created: {:#?}", sandbox);

Ok(sandbox)
}
Expand Down Expand Up @@ -794,7 +789,6 @@ mod tests {
/// our subscriber's `Interest::sometimes()`
/// 3. Clear recorded state and run the real test
#[test]
#[cfg(feature = "build-metadata")]
fn test_trace_trace() {
use hyperlight_testing::tracing_subscriber::TracingSubscriber;
use tracing::Level;
Expand Down Expand Up @@ -905,7 +899,6 @@ mod tests {
#[ignore]
// Tests that traces are emitted as log records when there is no trace
// subscriber configured.
#[cfg(feature = "build-metadata")]
fn test_log_trace() {
use std::path::PathBuf;

Expand Down
3 changes: 0 additions & 3 deletions src/hyperlight_libc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
edition.workspace = true
rust-version.workspace = true
license.workspace = true
homepage.workspace = true

Check warning on line 8 in src/hyperlight_libc/Cargo.toml

View workflow job for this annotation

GitHub Actions / miri (X64) / miri

`package.homepage` is redundant with `package.repository`

Check warning on line 8 in src/hyperlight_libc/Cargo.toml

View workflow job for this annotation

GitHub Actions / miri (arm64) / miri

`package.homepage` is redundant with `package.repository`
repository.workspace = true
readme = "README.md"
description = """
Expand All @@ -13,9 +13,6 @@
It builds the picolibc library and generates bindings to the libc types and functions.
"""

[features]
default = []

[dependencies]

[lints]
Expand Down
2 changes: 1 addition & 1 deletion src/tests/rust_guests/dummyguest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ hyperlight-common = { path = "../../../hyperlight_common", default-features = fa
[features]
default = []
trace_guest = ["hyperlight-guest-bin/trace_guest"]
mem_profile = ["hyperlight-common/mem_profile", "hyperlight-guest-bin/mem_profile"]
mem_profile = ["hyperlight-guest-bin/mem_profile"]
4 changes: 2 additions & 2 deletions src/tests/rust_guests/simpleguest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ tracing = { version = "0.1.41", default-features = false, features = ["log", "at

[features]
default = []
trace_guest = ["hyperlight-guest-bin/trace_guest", "hyperlight-guest/trace_guest", "hyperlight-guest-tracing/trace"]
mem_profile = ["hyperlight-common/mem_profile", "hyperlight-guest-bin/mem_profile"]
trace_guest = ["hyperlight-guest-bin/trace_guest"]
mem_profile = ["hyperlight-guest-bin/mem_profile"]

4 changes: 2 additions & 2 deletions src/tests/rust_guests/witguest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ spin = "0.12.0"

[features]
default = []
trace_guest = ["hyperlight-guest-bin/trace_guest", "hyperlight-guest/trace_guest"]
mem_profile = ["hyperlight-common/mem_profile", "hyperlight-guest-bin/mem_profile"]
trace_guest = ["hyperlight-guest-bin/trace_guest"]
mem_profile = ["hyperlight-guest-bin/mem_profile"]
Loading