Skip to content

Follow up #143: share hive state and protect nested repair handoffs - #148

Closed
Marcus Ferreira (mvaferreira) wants to merge 1 commit into
Azure:mainfrom
mvaferreira:rsl-foundation-followup
Closed

Follow up #143: share hive state and protect nested repair handoffs#148
Marcus Ferreira (mvaferreira) wants to merge 1 commit into
Azure:mainfrom
mvaferreira:rsl-foundation-followup

Conversation

@mvaferreira

Copy link
Copy Markdown

Why this follow-up exists

#143 merged as 1b2a597 while the additional #146/#147 review fixes were being validated.
This PR contains only the shared-foundation changes those reviews need; it does not alter the
approved/merged #143 history.

File Change
OfflineRepairCommon.ps1 Shared writable-hive depth/file bindings and default Windows drive; persistent nested-VM ownership marker and a reentrant cross-process lifecycle mutex
Get-OfflineWindowsDisk.ps1 Publishes the shared default; refuses active managed/unrelated guests before disk preparation; limits automatic shutdown to ProblemVM or an explicit custom Id
README.md Documents strict writers, persistent rollback records and verified guest hand-offs

No scenario or map.json entry is added. #146 and #147 use this shared contract; consuming
scenario PRs must wait until all three outstanding helper changes have merged.

Registry state across dot-source scopes

Set-OfflineWindowsDrive binds the selected root and publishes the default through
Get-OfflineRepairState. Scope-private variables are no longer independent sources of truth.
The same state owns hive depth and active file bindings, preventing an inner callback from
unloading its outer caller's hive or silently switching the file/default underneath it.

Nested-guest coordination

Discovery previously turned off every running Hyper-V guest. It now fails before any disk
preparation when another guest is active or #147's helper has marked a guest as managed. It does
not merely skip that guest and attempt to online its disk.

The persistent repair-script-library:nested-repair:v1 Notes line works across PowerShell
processes. A shared mutex serializes ownership/start/stop and disk-preparation transitions.
The owning flow must explicitly call Stop-NestedRepairVmGraceful, confirm Stopped, and
then rediscover the disk. Automatic unmanaged shutdown uses an exact VM object and verifies Off;
no wildcard-name shutdown or success-shaped enumeration failure remains.

Validation and limits

  • Existing 120/120 defect and 53/53 follow-up cases pass on PS5.1 and PS7.
  • Dedicated registry regressions pass 140/140 on both engines; PSScriptAnalyzer is zero
    across all eight helper files.
  • 87/87 nested lifecycle cases pass on both engines, including cross-process mutex exclusion.
  • 33 native assertions on a disposable VHD verify discovery/default-drive binding, real
    writable synthetic hives, strict selected-set writes, cross-scope calls and unwind/cleanup.
  • 93 native Hyper-V assertions use disposable Gen1/Gen2 guests with actual passthrough VHD
    disks. Fresh-process discovery refuses to interrupt them; disk return is verified. Five
    original guests and seven original disks remain unchanged.
  • The test guests are firmware-only and the hives are synthetic. These results are not
    presented as Windows guest boot/payload validation or a fresh --preview scenario matrix.

Local test tooling stays outside the contribution, as requested. No protection was disabled,
and no existing lab guest or original disk was repurposed for these checks.

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

Copilot-Session: cf64bab1-6099-4e7e-aef4-57ffea10ce6b
@mvaferreira

Copy link
Copy Markdown
Author

Closing this extra split to keep the review work in the two existing open PRs, #146 and #147. The tested shared-helper changes will be folded into those PRs; merged #143 remains unchanged. The branch is retained while that integration is completed.

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.

1 participant