Fix VHD volume recovery#40750
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves WSLC named-volume recovery behavior so containers can still be opened/inspected/deleted when a referenced VHD-backed volume can’t be recovered, while preventing container start and surfacing actionable failure details (HRESULT + message) via status and localized user errors.
Changes:
- Track VHD-backed volumes that fail to attach/mount in an “errored/unavailable” state and surface the failure in
InspectVolumestatus. - Block
WSLCContainerImpl::Start()when referenced named volumes are unavailable, emitting per-volume warnings and returningWSLC_E_VOLUME_NOT_AVAILABLE. - Add new error code + localized strings, and update tests to validate the new behavior.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/windows/WSLCTests.cpp | Updates recovery tests to expect container open to succeed, start to fail with WSLC_E_VOLUME_NOT_AVAILABLE, and inspect/delete flows to work. |
| src/windows/wslcsession/WSLCVolumes.h | Replaces ContainsVolume() with GetVolumeStatus() API to report volume availability + reason. |
| src/windows/wslcsession/WSLCVolumes.cpp | Implements GetVolumeStatus() and enhances recovery warnings to include a reason string. |
| src/windows/wslcsession/WSLCVhdVolume.h | Adds persistent {HRESULT, message} status and new ctor params to represent failed recovery without throwing. |
| src/windows/wslcsession/WSLCVhdVolume.cpp | Makes Open() resilient: returns an errored volume on attach/mount failures and surfaces the error in Inspect(). |
| src/windows/wslcsession/WSLCSession.cpp | Threads WSLCVolumes into container creation/open paths (for start-time availability checks). |
| src/windows/wslcsession/WSLCContainer.h | Stores referenced named volume names + a WSLCVolumes& to validate availability at Start(). |
| src/windows/wslcsession/WSLCContainer.cpp | Adds start-time volume availability validation and new user-facing error/warning flow. |
| src/windows/wslcsession/IWSLCVolume.h | Adds a virtual Status() API (default OK) for volume implementations to report usability. |
| src/windows/WslcSDK/wslcsdk.h | Introduces WSLC_E_VOLUME_NOT_AVAILABLE. |
| src/windows/service/inc/wslc.idl | Exposes WSLC_E_VOLUME_NOT_AVAILABLE for COM clients. |
| src/windows/common/wslutil.cpp | Adds the new WSLC error code to the common error map. |
| localization/strings/en-US/Resources.resw | Updates/introduces localized strings for volume recovery failure and “volume not available” messaging. |
OneBlue
previously approved these changes
Jun 11, 2026
OneBlue
left a comment
Collaborator
There was a problem hiding this comment.
LGTM !
We might also want to add test coverage for warnings emitted when the session loads.
| if (FAILED(code)) | ||
| { | ||
| EMIT_USER_WARNING(Localization::MessageWslcVolumeNotAvailableReason( | ||
| wsl::shared::string::MultiByteToWide(volumeName), wsl::shared::string::MultiByteToWide(message))); |
Collaborator
There was a problem hiding this comment.
nit: These MultiByteToWide calls aren't needed
OneBlue
previously approved these changes
Jun 11, 2026
|
|
||
| auto warnings = warningCallback->GetWarnings(); | ||
| auto expectedWarning = std::format( | ||
| L"wsl: {}\n", wsl::shared::Localization::MessageWslcFailedToRecoverVolume(wsl::shared::string::MultiByteToWide(c_volumeName))); |
Collaborator
There was a problem hiding this comment.
nit: We skip the MultiByteToWide call here as well
OneBlue
approved these changes
Jun 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of the Pull Request
Enhance volume recovery by introducing error handling for unavailable volumes. The changes include new error messages and status reporting for VHD volumes that cannot be accessed/found/mounted/etc., ensuring users receive clear feedback when attempting to start containers with missing volumes and are able to inspect/delete the volume.
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed