Skip to content

Fix VHD volume recovery#40750

Merged
kvega005 merged 8 commits into
microsoft:masterfrom
kvega005:vhdGoneNowWhat
Jun 12, 2026
Merged

Fix VHD volume recovery#40750
kvega005 merged 8 commits into
microsoft:masterfrom
kvega005:vhdGoneNowWhat

Conversation

@kvega005

@kvega005 kvega005 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

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

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Copilot AI review requested due to automatic review settings June 8, 2026 23:23
@kvega005 kvega005 requested a review from a team as a code owner June 8, 2026 23: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.

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 InspectVolume status.
  • Block WSLCContainerImpl::Start() when referenced named volumes are unavailable, emitting per-volume warnings and returning WSLC_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.

Comment thread src/windows/wslcsession/WSLCVhdVolume.cpp Outdated
Comment thread src/windows/wslcsession/WSLCContainer.cpp Outdated
Comment thread src/windows/wslcsession/WSLCVolumes.cpp Outdated
@kvega005 kvega005 marked this pull request as draft June 9, 2026 20:11
Copilot AI review requested due to automatic review settings June 9, 2026 20:13

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.

Pull request overview

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

Comment thread src/windows/wslcsession/WSLCContainer.cpp
@kvega005 kvega005 closed this Jun 9, 2026
@kvega005 kvega005 reopened this Jun 10, 2026
@kvega005 kvega005 marked this pull request as ready for review June 10, 2026 00:10
Copilot AI review requested due to automatic review settings June 10, 2026 00:10

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.

Pull request overview

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

Comment thread localization/strings/en-US/Resources.resw
Comment thread src/windows/wslcsession/WSLCSession.cpp
Comment thread src/windows/wslcsession/WSLCSession.cpp
OneBlue
OneBlue previously approved these changes Jun 11, 2026

@OneBlue OneBlue 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.

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)));

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.

nit: These MultiByteToWide calls aren't needed

Copilot AI review requested due to automatic review settings June 11, 2026 21:02

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.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Comment thread src/windows/wslcsession/WSLCVhdVolume.cpp
Comment thread src/windows/wslcsession/WSLCVolumes.cpp
OneBlue
OneBlue previously approved these changes Jun 11, 2026
Comment thread test/windows/WSLCTests.cpp Outdated

auto warnings = warningCallback->GetWarnings();
auto expectedWarning = std::format(
L"wsl: {}\n", wsl::shared::Localization::MessageWslcFailedToRecoverVolume(wsl::shared::string::MultiByteToWide(c_volumeName)));

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.

nit: We skip the MultiByteToWide call here as well

@kvega005 kvega005 merged commit aef5b0f into microsoft:master Jun 12, 2026
9 checks passed
@kvega005 kvega005 deleted the vhdGoneNowWhat branch June 12, 2026 21:56
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