Skip to content

Conversation

@stunes-ms
Copy link
Contributor

We want to leave a marker in a VMGS file that indicates that it was provisioned originally by HCL, with some diagnostic details (vTPM version, etc.) This is intended to be information-only.

@stunes-ms stunes-ms requested a review from a team as a code owner December 10, 2025 18:28
Copilot AI review requested due to automatic review settings December 10, 2025 18:28
@stunes-ms stunes-ms requested a review from a team as a code owner December 10, 2025 18:28
@stunes-ms stunes-ms requested review from mingweishih and tjones60 and removed request for Copilot December 10, 2025 18:28
Copilot AI review requested due to automatic review settings December 16, 2025 00:14
Copy link
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 RFC introduces a diagnostic provisioning marker to VMGS files that records metadata about how the file was initially provisioned. The marker captures information such as the provisioner entity (OpenHCL, HCL, etc.), vTPM version and configuration details, and the HCL commit hash.

Key changes:

  • New ProvisioningMarker struct and VmgsProvisioner enum in vmgs_format to define the diagnostic marker format
  • vTPM-related constants moved to tpm_protocol for reuse across components
  • Logic in OpenHCL to write the provisioning marker when a VMGS file is provisioned

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
vm/vmgs/vmgs_format/src/lib.rs Defines the ProvisioningMarker struct, VmgsProvisioner enum, and adds new file ID for the marker
vm/vmgs/vmgs_format/Cargo.toml Adds tpm_protocol dependency for TpmVersion type
vm/vmgs/vmgs/src/vmgs_impl.rs Tracks whether VMGS was formatted due to failure, adds accessor method
vm/vmgs/vmgs/Cargo.toml Reorders dependency (cosmetic change)
vm/devices/tpm/tpm_protocol/src/lib.rs Defines TpmVersion enum and default TPM configuration constants
vm/devices/tpm/tpm_protocol/Cargo.toml Adds dependencies needed for the new enum (open_enum, zerocopy)
openhcl/underhill_core/src/worker.rs Writes provisioning marker to VMGS when file is provisioned
openhcl/underhill_core/Cargo.toml Adds dependencies for tpm_protocol and vmgs_format

pub vtpm_nvram_size: u32,
pub vtpm_akcert_size: u32,
pub vtpm_akcert_attrs: u32,
pub hcl_version: [u8; 40], // OpenHCL: string representation of commit hash
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The comment 'OpenHCL: string representation of commit hash' is ambiguous about what happens when the provisioner is not OpenHCL. Consider clarifying whether this field is used by all provisioners or documenting the expected value for non-OpenHCL provisioners.

Suggested change
pub hcl_version: [u8; 40], // OpenHCL: string representation of commit hash
/// For provisioner == OPENHCL, this contains the string representation of the OpenHCL commit hash.
/// For all other provisioners, this field is zero-filled and should be ignored.
pub hcl_version: [u8; 40],

Copilot uses AI. Check for mistakes.

if let Some((_, ref mut vmgs)) = vmgs {
if vmgs.was_provisioned_this_boot() {
let mut rev: [u8; 40] = [0; 40];
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

The magic number 40 is duplicated here and in the ProvisioningMarker struct definition. Consider extracting it as a named constant (e.g., HCL_VERSION_MAX_LEN) in vmgs_format to ensure consistency and make future changes easier.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

this sounds like a good suggestion

Comment on lines +1759 to +1768
let marker = ProvisioningMarker {
marker_version: vmgs_format::PROVISIONING_MARKER_CURRENT_VERSION,
provisioner: VmgsProvisioner::OPENHCL,
reset_by_gsl_flag: (matches!(
dps.general.guest_state_lifetime,
GuestStateLifetime::Reprovision
) || (matches!(
dps.general.guest_state_lifetime,
GuestStateLifetime::ReprovisionOnFailure
) && vmgs.was_formatted_on_failure())) as u8,
Copy link

Copilot AI Dec 16, 2025

Choose a reason for hiding this comment

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

This complex boolean expression spanning multiple lines is difficult to read. Consider extracting it into a well-named helper function or variable (e.g., was_reset_by_gsl) to improve clarity.

Suggested change
let marker = ProvisioningMarker {
marker_version: vmgs_format::PROVISIONING_MARKER_CURRENT_VERSION,
provisioner: VmgsProvisioner::OPENHCL,
reset_by_gsl_flag: (matches!(
dps.general.guest_state_lifetime,
GuestStateLifetime::Reprovision
) || (matches!(
dps.general.guest_state_lifetime,
GuestStateLifetime::ReprovisionOnFailure
) && vmgs.was_formatted_on_failure())) as u8,
let was_reset_by_gsl = matches!(
dps.general.guest_state_lifetime,
GuestStateLifetime::Reprovision
) || (matches!(
dps.general.guest_state_lifetime,
GuestStateLifetime::ReprovisionOnFailure
) && vmgs.was_formatted_on_failure());
let marker = ProvisioningMarker {
marker_version: vmgs_format::PROVISIONING_MARKER_CURRENT_VERSION,
provisioner: VmgsProvisioner::OPENHCL,
reset_by_gsl_flag: was_reset_by_gsl as u8,

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants