Match docker's keyset for wslc volume list --format json - #41413
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the internal wslc volume listing pipeline so wslc volume list --format json emits the same 10-key JSON shape as docker volume ls --format json, switching the session/CLI boundary from a fixed-size struct array to a JSON string payload and introducing a transport schema for volume list entries.
Changes:
- Change
IWSLCSession::ListVolumesto return a JSON string (LPSTR*) rather than an out-array ofWSLCVolumeInformation, and plumb that through the CLI/service layers. - Add
wslc_schema::VolumeListEntry(transport) plus a CLI-layerVolumeOutputInformation(all-string JSON output), including mountpoint/labels support. - Update and extend unit/E2E tests to parse NDJSON output and assert the full 10-key field set.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/windows/WSLCTests.cpp | Updates volume-list test helpers to consume JSON output and validate new fields (mountpoint/scope). |
| test/windows/wslc/WSLCCLIExecutionUnitTests.cpp | Adjusts CLI execution test data mappings for the new VolumeListEntry type. |
| test/windows/wslc/e2e/WSLCE2EVolumeListTests.cpp | Switches parsing to the new output shape and adds an E2E assertion for the 10-key JSON field set. |
| test/windows/wslc/e2e/WSLCE2EHelpers.h | Introduces VolumeListOutput struct mirroring the JSON output keys for E2E parsing. |
| test/windows/wslc/e2e/WSLCE2EHelpers.cpp | Updates helper parsing to use VolumeListOutput for JSON volume list output. |
| src/windows/wslcsession/WSLCVolumes.h | Changes WSLCVolumes::ListVolumes return type to wslc_schema::VolumeListEntry. |
| src/windows/wslcsession/WSLCVolumes.cpp | Builds VolumeListEntry results including mountpoint, scope, and labels. |
| src/windows/wslcsession/WSLCVhdVolume.h | Exposes Mountpoint() via IWSLCVolume for VHD-backed volumes. |
| src/windows/wslcsession/WSLCGuestVolume.h | Exposes Mountpoint() via IWSLCVolume for guest volumes. |
| src/windows/wslcsession/IWSLCVolume.h | Adds the Mountpoint() accessor to the volume interface. |
| src/windows/wslcsession/WSLCSession.h | Updates the COM method signature for ListVolumes to return LPSTR* Output. |
| src/windows/wslcsession/WSLCSession.cpp | Implements ListVolumes as JSON serialization to a COM-allocated ANSI string. |
| src/windows/wslc/tasks/VolumeTasks.cpp | Converts list JSON output to the docker-matching 10-key, all-string JSON object per line. |
| src/windows/wslc/services/VolumeService.h | Updates VolumeService::List return type to VolumeListEntry. |
| src/windows/wslc/services/VolumeService.cpp | Calls session ListVolumes JSON API and deserializes to std::vector<VolumeListEntry>. |
| src/windows/wslc/services/VolumeModel.h | Adds VolumeOutputInformation defining the 10-key all-string JSON output schema. |
| src/windows/wslc/core/ExecutionContextData.h | Updates the execution context mapping for volumes to VolumeListEntry. |
| src/windows/service/inc/wslc.idl | Changes IWSLCSession::ListVolumes IDL signature to [out] LPSTR* Output. |
| src/windows/inc/wslc_schema.h | Adds wslc_schema::VolumeListEntry transport schema for volume list. |
| src/shared/inc/JsonUtils.h | Removes the now-unused WSLCVolumeInformation JSON serializer. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
ggarzia-MSFT
marked this pull request as ready for review
August 24, 2026 18:25
Blue (OneBlue)
approved these changes
Aug 24, 2026
ggarzia-MSFT
enabled auto-merge (squash)
August 24, 2026 19:15
David Bennett (dkbennett)
approved these changes
Aug 24, 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
wslc volume list --format jsonemitted only two keys,NameandDriver, whiledocker volume ls --format jsonemits ten. This reshapes the volume list path so the JSON keyset matches docker's.The blocker was that
WSLCVolumeInformationis two fixedchar[]arrays and cannot carry a label map. This applies the same fix already used fornetwork listin #41377:IWSLCSession::ListVolumesnow returns a JSON string via[out] LPSTR*instead of a struct array.ListVolumesis not part ofWSLCCompat.idl, so no SDK-facing or public ABI surface changes.PR Checklist
Detailed Description of the Pull Request / Additional comments
The command now outputs:
{"Availability":"N/A","Driver":"guest","Group":"N/A","Labels":"env=prod","Links":"N/A","Mountpoint":"/var/lib/docker/volumes/parity-check-vol/_data","Name":"parity-check-vol","Scope":"local","Size":"N/A","Status":"N/A"}The keyset is derived from
volumeContextincli/command/formatter/volume.go, whoseMarshalJSONcallsformatter.MarshalJSON. Percli/command/formatter/reflect.go, that reflects over exported methods taking no arguments and returning a single value, which yields exactlyAvailability, Driver, Group, Labels, Links, Mountpoint, Name, Scope, Size, Status. Note that docker's header map for volumes also listsID, butvolumeContexthas noID()method, soIDis reachable only from Go templates and never appears in JSON.LinksandSizereportN/Abecause docker only populates them whenUsageDatais set, andGroup,Availability, andStatusreportN/Abecause docker only populates those for swarm cluster volumes. Both conditions are permanently false here, matching what docker prints outside a cluster.Layering follows the existing image and network pattern, where a session-layer transport struct with native types is converted by a CLI-layer helper into an all-string output struct that is what actually gets serialized:
wslc_schema::VolumeListEntryis the new transport struct:Name,Driver,Mountpoint,Scope,Labels.IWSLCVolumegains aMountpoint()accessor. BothWSLCGuestVolumeImplandWSLCVhdVolumeImplalready storedm_mountpoint; this just exposes it.models::VolumeOutputInformationis the new CLI output struct, converted byToVolumeOutput()inVolumeTasks.cpp.WSLCVolumeInformationis retained forCreateVolume, which still uses it. Its now-unusedadl_serializerinJsonUtils.his removed, since the volume list path was its only consumer.Validation Steps Performed
Built clean, deployed with
tools\deploy\deploy-to-host.ps1, and ranbin\x64\Debug\test.bat /name:*Volume*: Total=106, Passed=106, Failed=0, Blocked=0, Not Run=0, Skipped=0.Added
WSLCE2E_Volume_List_ReportsFullFieldSet, which asserts the field count is exactly 10 and checks every key and value, so an accidental added or dropped key fails the test instead of silently passing.Updated the existing tests that consumed the old shape:
WSLCTests::ListVolumesFiltersand the volume lifecycle tests now go through a newListVolumeEntries()helper that parses the JSON, mirroring the existingListNetworks()test helper. The lifecycle test additionally assertsMountpointis non-empty andScopeislocal.WSLCE2EVolumeListTestsparse into a newVolumeListOutputmirror struct, matching howNetworkListOutputis already handled.Also manually confirmed the rendered output shown above, and that
volume list(table) andvolume list --quietare unaffected