Skip to content

Add slot-owned MSHV servicing - #934

Merged
bfjelds (bfjelds) merged 82 commits into
mainfrom
user/bfjelds/mshv-slot-servicing
Nov 18, 2026
Merged

bfjelds (bfjelds) merged 82 commits into
mainfrom
user/bfjelds/mshv-slot-servicing

Conversation

@bfjelds

@bfjelds bfjelds (bfjelds) commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Description

Implements #924: keep MSHV boot components and supporting bootloaders with their OS slot so an A/B update does not replace the retained OS's hypervisor files.

  • Select MSHV servicing from COSI bootloader metadata and stage slot-owned files during installation and updates.
  • Reuse ordinary bootloader discovery and copying. Select second.efi through uses_efitreeloader(), require MSHV loaders through uses_mshv(), and handle UKIs independently. Preserve additional MSHV files and their nested paths. Without MSHV metadata, unrelated MSHV files are ignored.
  • Copy complete installed boot trees for slot-to-BOOT fallback and BOOT-to-AZLA bootstrap. Extend .new/.old replacement to directories, preserve retry recovery, and retire destination-only entries inside the owned boot tree without touching other slots.
  • Validate source files before target-slot UKI cleanup, preserving retained-slot files and addons. All copying relies on actual write errors rather than capacity estimates; fallback and bootstrap publish only after copying succeeds.
  • Validate retained-slot MSHV compatibility before file-based A/B staging. Preserve health-check recovery against the retained configuration and report orchestrator success only after successful provisioning.
  • Use walkdir for traversal and copying, rejecting source links and special files. Keep reusable filesystem mechanics in osutils::files and boot-specific validation/publication/recovery in ESP.

Rationale

The retained slot must keep a matching OS, bootloader chain and MSHV boot components. Capability-specific source validation and format-independent installed-tree copying keep those responsibilities separate without an exhaustive relocation filename list.

Limitations

  • File-based MSHV deployment requires x86-64 ACL UKI images and the matching efitreeloader prefix resolver. TPM/PCR-bound encryption and updates between ordinary and MSHV layouts are rejected.
  • Initialization applies generic tree-structure checks when seeding a missing AZLA from BOOT; it does not validate loader completeness or inspect/refresh an existing AZLA.
  • Runtime hypervisor identity validation is not implemented. Commit and rollback do not detect mixed hypervisor/OS boots; root-device validation and health checks still apply.
  • Staging failure may leave partial inactive-slot files and does not restore old target-slot UKIs/addons removed for staging. Fallback publication is not atomic across top-level entries.

Validation

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@bfjelds bfjelds (bfjelds) changed the title Add experimental slot-owned MSHV servicing Add slot-owned MSHV servicing Nov 11, 2026
@bfjelds
bfjelds (bfjelds) requested a balanced review from Copilot November 11, 2026 02:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Capacity preflight can delete inactive files without reserving enough space for the retained fallback and commit-time overlap, while stale publication files can block retries or cause copies to run out of space.

2 open issues
What changed in this PR

Adds experimental slot-owned MSHV boot payload servicing for ACL UKI images, integrating deployment and recovery with Trident’s existing A/B lifecycle. Hypervisor identity validation remains an explicit success stub; boot and Secure Boot validation are not claimed.

Changes:

  • Deploys complete nested payload bundles per slot, with fallback copying and ESP capacity checks.
  • Adds configuration guards and a distinct hypervisor-failure recovery state.
  • Extends unit coverage, status serialization, and feature documentation.
File Description
proto/​trident/​v1preview/​status_service.proto Exposes the hypervisor-failure state.
docs/​Explanation/​Bootloader-Configuration.md Documents experimental support and limitations.
crates/​trident/​src/​subsystems/​esp/​mshv/​slot.rs Implements bundle validation, copying, capacity checks, and tests.
crates/​trident/​src/​subsystems/​esp/​mshv.rs Registers the slot payload module.
crates/​trident/​src/​subsystems/​esp.rs Integrates slot deployment and nested fallback copying.
crates/​trident/​src/​server/​tridentserver/​datastore.rs Maps and tests the new protocol state.
crates/​trident/​src/​lib.rs Handles recovery outcomes and preserves failure details.
crates/​trident/​src/​init/​offline/​mod.rs Rejects unsupported offline adoption.
crates/​trident/​src/​engine/​update.rs Validates MSHV mode transitions before updates.
crates/​trident/​src/​engine/​rollback.rs Adds hypervisor validation hooks and recovery handling.
crates/​trident/​src/​engine/​mshv.rs Defines configuration guards and the identity-check stub.
crates/​trident/​src/​engine/​mod.rs Registers the MSHV engine module.
crates/​trident/​src/​engine/​manual_rollback/​utils.rs Recognizes hypervisor auto-rollback history.
crates/​trident/​src/​engine/​manual_rollback/​mod.rs Guards rollback mode transitions.
crates/​trident/​src/​engine/​boot/​uki.rs Separates UKI cleanup planning from deletion.
crates/​trident_api/​src/​status.rs Adds the persisted recovery state.
crates/​trident_api/​src/​error.rs Adds a structured hypervisor mismatch error.
crates/​trident_api/​src/​constants.rs Defines the experimental feature flag.

Review effort: Balanced

Comment thread crates/trident/src/engine/boot/mshv.rs Resolved
Comment thread crates/trident/src/engine/boot/mshv.rs Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The free-space preflight ignores reclaimable space in a stale EFI/AZLA.bootstrap-tmp directory, potentially blocking every retry on a nearly full ESP before cleanup can occur.

3 open issues

Review effort: Balanced

Comment thread crates/trident/src/engine/boot/mshv.rs Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Boot-critical EFI payload and rollback changes need human integration review because VM boot, firmware recovery, COSI, and Secure Boot lack validation, while hypervisor identity checking remains a success stub.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

@bfjelds
bfjelds (bfjelds) force-pushed the user/bfjelds/mshv-slot-servicing branch from 19835a1 to 1bb710f Compare November 11, 2026 20:22
@bfjelds
bfjelds (bfjelds) requested a balanced review from Copilot November 11, 2026 20:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The test unconditionally expects success even though configuration validation rejects non-x86-64 targets, causing it to fail on ARM64 unless the expectation is architecture-dependent or gated to x86-64.

1 open issue

Review effort: Balanced

Comment thread crates/trident/src/engine/mshv.rs Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Boot-critical firmware deployment and recovery require human review because validation with a produced COSI, VM boot, and Secure Boot is missing, while the hypervisor identity hook deliberately assumes success.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@bfjelds
bfjelds (bfjelds) marked this pull request as ready for review November 12, 2026 01:10
@bfjelds
bfjelds (bfjelds) requested a review from a team as a code owner November 12, 2026 01:10
Comment thread crates/trident_api/src/status.rs Resolved
Copilot AI balanced review requested due to automatic review settings November 12, 2026 16:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Boot-critical EFI/MSHV payload and recovery changes require human review because VM boot and Secure Boot behavior remain unvalidated, and runtime hypervisor identity verification is still a success stub.

No open issues 🎉

Review effort: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 9785dfd5-6919-4af4-a4ec-1c9a74f3918a

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Boot-critical ESP relocation and A/B recovery require human runtime validation with the matching efitreeloader, since VM boot, rollback, and ENOSPC tests were not run on this head and hypervisor identity validation still assumes success.

No open issues 🎉

Review effort: Balanced

Validate layout transitions before staging and inline single-use helpers. Remove the placeholder hypervisor check and unused failure-state plumbing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 88854ec6-204f-40de-bbfe-03a7ab8052b0

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The PR description still claims recovery, client integration, and validation behavior that this revision does not implement, creating misleading expectations for callers.

1 open issue

Review effort: Balanced

Comment thread crates/trident/src/engine/rollback.rs Resolved
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 88854ec6-204f-40de-bbfe-03a7ab8052b0

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Boot-critical MSHV relocation depends on a matching efitreeloader resolver, and the lack of VM boot, rollback, and ENOSPC testing leaves firmware compatibility and recovery behavior requiring human runtime validation.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 88854ec6-204f-40de-bbfe-03a7ab8052b0
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 88854ec6-204f-40de-bbfe-03a7ab8052b0

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Boot-critical MSHV relocation depends on a matching external path resolver, while current-head boot, update, rollback, and ENOSPC paths remain untested and require human end-to-end validation.

No open issues 🎉

Review effort: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 88854ec6-204f-40de-bbfe-03a7ab8052b0
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 88854ec6-204f-40de-bbfe-03a7ab8052b0

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human assessment is needed to evaluate a retry-path risk where abandoned staging entries can cause repeated out-of-space failures before cleanup runs.

No open issues 🎉

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Boot-critical slot/fallback publication depends on a matching external efitreeloader resolver, with current-head VM boot, rollback, and ENOSPC behavior still requiring human validation.

No open issues 🎉

Review effort: Balanced

Comment thread crates/osutils/src/files.rs Resolved
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 88854ec6-204f-40de-bbfe-03a7ab8052b0

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Boot-critical relocation depends on an external efitreeloader resolver unavailable for inspection, leaving slot-specific hypervisor fallback, rollback, and interrupted VFAT publication recovery requiring human verification.

No open issues 🎉

Review effort: Balanced

@frhuelsz Paco Huelsz (frhuelsz) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Three observations about copy_recursively, posted at the author's request.

Comment thread crates/osutils/src/files.rs Resolved
Comment thread crates/osutils/src/files.rs Resolved
Comment thread crates/osutils/src/files.rs Resolved
Comment thread crates/trident/src/lib.rs Resolved
Clarify unchecked copy preconditions and add path-aware errors. Move ACL detection into osrelease, name the MSHV test fixture, and remove leftover error-preservation churn.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 51df658f-200d-426f-aa83-68c76a76e4a3
Comment thread crates/osutils/src/osrelease.rs Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Boot-critical MSHV changes depend on matching external efitreeloader binaries, and reported update checks leave interrupted-publication, rollback, and UEFI fallback safety unverified, requiring human integration validation.

No open issues 🎉

Review effort: Balanced

Limit tree replacement helpers to ESP, construct validation errors at their failure sites, and reuse os-release read context.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 51df658f-200d-426f-aa83-68c76a76e4a3

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Boot-critical changes depend on matching external efitreeloader and signed MSHV artifacts, while reported manual-update tests leave fallback, rollback, and recovery boot behavior requiring human confirmation.

No open issues 🎉

Review effort: Balanced

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