User/askariv/virtiofs with vcpus#40758
Draft
asherkariv wants to merge 4 commits into
Draft
Conversation
Add a 'vcpus' token to the virtiofs mount options string for both wsl (WslCoreVm) and wslc (HcsVirtualMachine), mirroring the existing swiotlb token mechanism, so wsldevicehost.dll receives the VM's vCPU count.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR passes the WSL VM’s vCPU count to wsldevicehost.dll by appending a vcpus=<count> token (semicolon-delimited) to the virtiofs mount/device options string, reusing the existing device-options pathway (already used for swiotlb).
Changes:
wsl: Appendvcpus={ProcessorCount}to the effective virtiofs mount options inWslCoreVm::AddVirtioFsSharewhenProcessorCount != 0.wslc: Cache avcpus={CpuCount}token inHcsVirtualMachineand append it to the virtiofs device options inAddShare.- Introduce a new
m_vcpusOptionmember to carry the token through the wslc path similarly tom_swiotlbOption.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/windows/service/exe/WslCoreVm.cpp | Appends vcpus=<count> to virtiofs mount options in the core WSL VM virtiofs share path. |
| src/windows/service/exe/HcsVirtualMachine.h | Adds m_vcpusOption member to store the vCPU-count token for wsldevicehost. |
| src/windows/service/exe/HcsVirtualMachine.cpp | Initializes and appends the cached vcpus=<count> token when creating virtiofs shares. |
benhillis
reviewed
Jun 9, 2026
benhillis
reviewed
Jun 9, 2026
| effectiveOptions += m_swiotlbOption; | ||
| } | ||
|
|
||
| // Append the vcpus token here so it covers fixed-drive, dynamic add, and remount paths. |
Member
There was a problem hiding this comment.
Same here, maybe a lambda that handles the adding the ; and adding the option.
Member
There was a problem hiding this comment.
doesn't look like it was addressed, only difference here is a much longer comment.
Refactor HcsVirtualMachine::AddShare to append the swiotlb and vcpus tokens via a single appendOption lambda instead of duplicated empty-check/separator blocks.
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
Populate the WSL VM vCPU count into virtiofs mount options
Summary
Passes the number of vCPUs assigned to the WSL VM to wsldevicehost.dll by adding a vcpus token to the virtiofs mount-options string. This reuses the same device-options channel already used to pass the swiotlb information, so no new IPC path or message format is introduced.
The change is applied to both VM implementations:
wsl — WslCoreVm.cpp: AddVirtioFsShare appends vcpus={ProcessorCount} using the existing m_vmConfig.ProcessorCount.
wslc — HcsVirtualMachine.cpp / HcsVirtualMachine.h: caches vcpus={CpuCount} from WSLCSessionSettings->CpuCount in the constructor and appends it in AddShare.
Details
Token format is vcpus=, semicolon-separated, mirroring the existing swiotlb=... token.
In the wsl path the token is built inline from the already-parsed ProcessorCount config value (no new member added). In the wslc path the count is only available at construction time, so it is cached in m_vcpusOption, exactly as m_swiotlbOption is.
The token is appended in the shared virtiofs add-share path so it covers the fixed-drive, dynamic-add, and remount cases. Duplicate tokens are harmless because the options string is parsed into a map.
The token is only added when a processor count is present (ProcessorCount != 0).
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed