Implement SDK inspect and VHD management#14545
Open
JohnMcPMS wants to merge 10 commits intomicrosoft:feature/wsl-for-appsfrom
Open
Implement SDK inspect and VHD management#14545JohnMcPMS wants to merge 10 commits intomicrosoft:feature/wsl-for-appsfrom
JohnMcPMS wants to merge 10 commits intomicrosoft:feature/wsl-for-appsfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR expands the WSLC SDK’s container/session storage capabilities by implementing container inspection, session VHD-backed volume creation, and support for mounting those named volumes into containers.
Changes:
- Implement
WslcInspectContainerby calling the underlying WSLA containerInspect()API and returning the JSON payload. - Implement
WslcCreateSessionVhdto create VHD-backed named volumes via the underlying session volume APIs. - Add
WslcSetContainerSettingsNamedVolumesto pass named session volumes through to container creation options, plus SDK tests covering inspect and VHD creation/mounting.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/windows/WslcSdkTests.cpp | Adds SDK tests validating container inspect output and VHD-backed named volume creation + mounting. |
| src/windows/WslcSDK/wslcsdk.h | Updates public SDK surface: struct size constants, new named-volume APIs/types, and WslcInspectContainer signature change. |
| src/windows/WslcSDK/wslcsdk.def | Exports the new WslcSetContainerSettingsNamedVolumes API. |
| src/windows/WslcSDK/wslcsdk.cpp | Implements WslcInspectContainer, WslcCreateSessionVhd, and named-volume handling during container creation. |
| src/windows/WslcSDK/WslcsdkPrivate.h | Extends internal container options layout to carry named volume settings and updates size/alignment asserts. |
OneBlue
reviewed
Mar 27, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
src/windows/WslcSDK/wslcsdk.h:41
- Bumping WSLC_SESSION_OPTIONS_SIZE / WSLC_CONTAINER_OPTIONS_SIZE changes the required size of the opaque settings structs. Any client binary built against the old header but running against the new DLL would pass smaller buffers, leading to out-of-bounds reads/writes when the DLL reinterprets the struct. If cross-version binary compatibility matters for this SDK, consider adding an explicit size/version field (or _Init functions that validate an incoming size) or versioning the DLL so mismatches are detectable.
// Session values
#define WSLC_SESSION_OPTIONS_SIZE 80
#define WSLC_SESSION_OPTIONS_ALIGNMENT 8
typedef struct WslcSessionSettings
{
__declspec(align(WSLC_SESSION_OPTIONS_ALIGNMENT)) BYTE _opaque[WSLC_SESSION_OPTIONS_SIZE];
} WslcSessionSettings;
DECLARE_HANDLE(WslcSession);
// Container values
#define WSLC_CONTAINER_OPTIONS_SIZE 96
#define WSLC_CONTAINER_OPTIONS_ALIGNMENT 8
typedef struct WslcContainerSettings
{
__declspec(align(WSLC_CONTAINER_OPTIONS_ALIGNMENT)) BYTE _opaque[WSLC_CONTAINER_OPTIONS_SIZE];
} WslcContainerSettings;
src/windows/WslcSDK/wslcsdk.cpp:447
- WslcSetSessionSettingsVhd treats a null vhdRequirements pointer as “clear” by assigning an all-zero WslcVhdRequirements. That sets sizeInBytes=0, and WslcCreateSession then passes MaximumStorageSizeMb=0 to the runtime, which later attempts to create a 0-byte storage.vhdx (WSLCSession.cpp multiplies by _1MB). Consider making nullptr a no-op, or resetting to the same defaults as WslcInitSessionSettings (default size + dynamic type), rather than zeroing the requirements.
if (vhdRequirements)
{
RETURN_HR_IF(E_INVALIDARG, vhdRequirements->sizeInBytes == 0);
RETURN_HR_IF(E_NOTIMPL, vhdRequirements->type != WSLC_VHD_TYPE_DYNAMIC);
internalType->vhdRequirements = *vhdRequirements;
}
else
{
internalType->vhdRequirements = {};
}
OneBlue
approved these changes
Mar 31, 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
Implements
WslcInspectContainerandWslcCreateSessionVhd; addsWslcSetContainerSettingsNamedVolumesso that the VHDs are useful.PR Checklist
Detailed Description of the Pull Request / Additional comments
WslcInspectContaineris a straightforward pass-through.WslcCreateSessionVhdWslcCreateSessionVhdVolumewas also relatively straightforward, except it required adding a name to the existing VHD struct. Fixed VHDs cannot be requested via the runtime API currently, so attempting to use them is an error. If we never plan to allow them I can simply remove the option.In order to actually use the created VHD, I had to add
WslcSetContainerSettingsNamedVolumesso that they could be mounted in a container. This is basically a copy of the Windows <-> container volume setting with the Windows path replaced by the VHD name. And to enable removal,WslcDeleteSessionVhdVolumewas added.Validation Steps Performed
Tests added for inspect and VHD creation/use.