Skip to content

vmgs: clean up errors and add tracing to vmgstool#2815

Merged
tjones60 merged 7 commits intomicrosoft:mainfrom
tjones60:vmgstool_tracing
Feb 24, 2026
Merged

vmgs: clean up errors and add tracing to vmgstool#2815
tjones60 merged 7 commits intomicrosoft:mainfrom
tjones60:vmgstool_tracing

Conversation

@tjones60
Copy link
Copy Markdown
Contributor

  • Replace any remaining anyhow errors in the VMGS implementation and remove any unnecessarily duplicate errors in VmgsTool.
  • Adds a tracing subscriber to VmgsTool and converts (almost) all stderr output to use it.
    • This gets us timestamps and logs from internal crates with the new verbose mode enabled.
  • Removes the word "Error" from any VmgsTool logs that may not actually indicate an error.

@tjones60 tjones60 requested a review from a team as a code owner February 18, 2026 00:50
Copilot AI review requested due to automatic review settings February 18, 2026 00:50
@tjones60 tjones60 requested a review from a team as a code owner February 18, 2026 00:50
@github-actions github-actions Bot added the unsafe Related to unsafe code label Feb 18, 2026
@github-actions
Copy link
Copy Markdown

⚠️ Unsafe Code Detected

This PR modifies files containing unsafe Rust code. Extra scrutiny is required during review.

For more on why we check whole files, instead of just diffs, check out the Rustonomicon

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves error handling and observability in the VMGS (VM Guest State) implementation by replacing generic anyhow errors with strongly-typed errors and adding comprehensive tracing support to VmgsTool.

Changes:

  • Replaces anyhow::Error with specific typed errors in the VMGS library, including new error variants like NeedsUnlock, DecryptMetadataKey, UnexpectedLength, and InvalidArgument
  • Adds tracing subscriber to VmgsTool with configurable verbosity levels and converts all eprintln! calls to appropriate tracing levels (info, warn, error)
  • Renames methods for clarity: is_encrypted()encrypted(), is_encrypted_and_unlocked()encrypted_and_unlocked()
  • Updates FileInfoNotAllocated error variant to include the FileId for better error messages
  • Adds Display implementation for FileId to improve log output

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
vm/vmgs/vmgs/src/error.rs Removes anyhow dependency, adds new typed error variants, updates error messages
vm/vmgs/vmgs/src/vmgs_impl.rs Replaces anyhow! with typed errors, renames encryption check methods, updates error propagation
vm/vmgs/vmgs/src/encrypt/win.rs Replaces anyhow with typed BCrypt error variant
vm/vmgs/vmgs/src/encrypt/ossl.rs Replaces String with &'static str in OpenSSL error messages
vm/vmgs/vmgs/Cargo.toml Removes anyhow dependency, adds windows-result for BCrypt errors
vm/vmgs/vmgstool/src/main.rs Adds tracing initialization, converts error handling to use tracing, improves exit code handling
vm/vmgs/vmgstool/src/uefi_nvram.rs Converts eprintln! to tracing::info!, updates method calls
vm/vmgs/vmgstool/src/test.rs Converts eprintln! to tracing::info!
vm/vmgs/vmgstool/src/storage_backend.rs Updates FileInfoNotAllocated pattern match for new signature
vm/vmgs/vmgstool/Cargo.toml Adds tracing dependencies
vm/vmgs/vmgs_format/src/lib.rs Adds Display implementation for FileId
vm/vmgs/vmgs_broker/src/broker.rs Updates FileInfoNotAllocated pattern match
openhcl/underhill_attestation/* Updates all call sites for renamed methods and error patterns
Cargo.toml & Cargo.lock Adds windows-result workspace dependency

Comment thread vm/vmgs/vmgs/src/error.rs Outdated
stunes-ms
stunes-ms previously approved these changes Feb 24, 2026
Comment thread vm/vmgs/vmgs/src/vmgs_impl.rs
Comment thread vm/vmgs/vmgstool/src/main.rs
@tjones60 tjones60 merged commit a314e74 into microsoft:main Feb 24, 2026
56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

unsafe Related to unsafe code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants