Add VHD mounts as named volumes#14362
Add VHD mounts as named volumes#14362kvega005 merged 62 commits intomicrosoft:feature/wsl-for-appsfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds session-scoped named volume support backed by VHDs, integrates named volume mounts into container create/open flows, persists mount metadata, and introduces Windows tests verifying the new behavior.
Changes:
- Introduces
CreateVolume/DeleteVolumeonIWSLASessionand session state tracking for named volumes - Implements VHD-backed volume creation (VHD create → attach → ext4 format → mount in guest) and container mount injection via bind mounts
- Extends container metadata serialization to persist named volume mounts and adds an end-to-end
NamedVolumesTest
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| test/windows/WSLATests.cpp | Adds a new integration test covering named volume creation, mount behavior, validation, and delete semantics |
| src/windows/wslasession/WSLAVirtualMachine.h | Exposes Ext4Format on the VM abstraction |
| src/windows/wslasession/WSLAVirtualMachine.cpp | Implements Ext4Format using mkfs.ext4 inside the guest |
| src/windows/wslasession/WSLAVhdVolume.h | Adds internal VHD volume implementation class definition |
| src/windows/wslasession/WSLAVhdVolume.cpp | Implements VHD-backed named volume create/mount/delete logic |
| src/windows/wslasession/WSLASession.h | Wires volume management into the session interface and adds a m_volumes map |
| src/windows/wslasession/WSLASession.cpp | Implements CreateVolume / DeleteVolume and passes session volumes into container creation |
| src/windows/wslasession/WSLAContainerMetadata.h | Adds named volume mounts to persisted container metadata |
| src/windows/wslasession/WSLAContainer.h | Tracks referenced named volumes per container and extends Create signature |
| src/windows/wslasession/WSLAContainer.cpp | Validates duplicate mount targets across bind/named volumes and injects named mounts into Docker create request |
| src/windows/wslasession/CMakeLists.txt | Adds new VHD volume sources/headers to the build |
| src/windows/wslaservice/inc/wslaservice.idl | Adds IDL structs for volume options and named volume mounts; extends session interface; adds new HRESULTs |
| src/windows/common/WSLAContainerLauncher.h | Adds named volume mount support to the test/container launcher |
| src/windows/common/WSLAContainerLauncher.cpp | Implements named volume mount wiring into WSLA_CONTAINER_OPTIONS |
…olumes-merge-20260305-115914
…4' of https://github.com/kvega005/WSL into feature/wsl-for-apps-named-volumes-merge-20260305-115914
…4' of https://github.com/kvega005/WSL into feature/wsl-for-apps-named-volumes-merge-20260305-115914
…re/wsl-for-apps-named-volumes-merge-20260305-115914
…olumes-merge-20260305-115914
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 18 changed files in this pull request and generated 7 comments.
Comments suppressed due to low confidence (1)
src/windows/wslasession/WSLAContainer.cpp:1084
- The null-check for
volume.ContainerPathis duplicated: it’s checked withTHROW_HR_IF_MSG(... volume.ContainerPath == nullptr ...)and then immediately again withTHROW_HR_IF_NULL_MSG(... volume.ContainerPath ...). Dropping one of these would reduce redundancy without changing behavior.
THROW_HR_IF_MSG(E_INVALIDARG, volume.ContainerPath == nullptr, "Volume at index %lu has null ContainerPath", i);
THROW_HR_IF_MSG(
HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS),
!containerMountTargets.insert(volume.ContainerPath).second,
"Duplicate container mount path '%hs'",
volume.ContainerPath);
THROW_HR_IF_NULL_MSG(E_INVALIDARG, volume.HostPath, "Volumes[%lu].HostPath is null", i);
THROW_HR_IF_NULL_MSG(E_INVALIDARG, volume.ContainerPath, "Volumes[%lu].ContainerPath is null", i);
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
src/windows/wslasession/WSLASession.cpp:1
- The new user-facing error text is now the generic “Invalid name”، which is ambiguous in APIs that operate on different entities (container name vs volume name). If this is intended to cover both, consider including the entity type in the message (e.g., “Invalid container name” / “Invalid volume name”) or adding separate localized strings to keep errors actionable.
/*++
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…4' of https://github.com/kvega005/WSL into feature/wsl-for-apps-named-volumes-merge-20260305-115914
…olumes-merge-20260305-115914
…olumes-merge-20260305-115914
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| const auto it = options.find("SizeBytes"); | ||
| THROW_HR_WITH_USER_ERROR_IF(E_INVALIDARG, Localization::MessageWslaInvalidVolumeOptions(Options.Options), it == options.end()); | ||
|
|
||
| auto sizeBytes = wsl::shared::FromJson<ULONGLONG>(it->second.c_str()); |
There was a problem hiding this comment.
Ah I didn't know we could even do that !
…re/wsl-for-apps-named-volumes-merge-20260305-115914
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 18 out of 18 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
src/windows/wslasession/WSLASession.cpp:1
- ValidateName is now used for both container names and volume names, but it still enforces WSLA_MAX_CONTAINER_NAME_LENGTH. If the intent is a shared constraint, consider renaming the constant (or introducing a separate WSLA_MAX_NAME_LENGTH) to avoid container-specific semantics leaking into a generic validator.
/*++
…re/wsl-for-apps-named-volumes-merge-20260305-115914
Summary of the Pull Request
This PR adds named volume support to WSLA containers and wires it through session, container create/open, metadata persistence, and tests.
PR Checklist
Detailed Description of the Pull Request / Additional comments
CreateVolumeandDeleteVolumein session API/implementation./mnt/wsla-volumes/{name}.DeleteVolumeblocks when any container still references the named volume.Name,ContainerPath,ReadOnly).ERROR_ALREADY_EXISTS.Validation Steps Performed
NamedVolumesTest: