Skip to content

User/askariv/virtiofs with vcpus#40758

Draft
asherkariv wants to merge 4 commits into
masterfrom
user/askariv/virtiofs_with_vcpus
Draft

User/askariv/virtiofs with vcpus#40758
asherkariv wants to merge 4 commits into
masterfrom
user/askariv/virtiofs_with_vcpus

Conversation

@asherkariv

Copy link
Copy Markdown

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

  • 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

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.
Copilot AI review requested due to automatic review settings June 9, 2026 23:16

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 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: Append vcpus={ProcessorCount} to the effective virtiofs mount options in WslCoreVm::AddVirtioFsShare when ProcessorCount != 0.
  • wslc: Cache a vcpus={CpuCount} token in HcsVirtualMachine and append it to the virtiofs device options in AddShare.
  • Introduce a new m_vcpusOption member to carry the token through the wslc path similarly to m_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.

Comment thread src/windows/service/exe/WslCoreVm.cpp Outdated
Comment thread src/windows/service/exe/HcsVirtualMachine.cpp Outdated
Comment thread src/windows/service/exe/HcsVirtualMachine.cpp Outdated
effectiveOptions += m_swiotlbOption;
}

// Append the vcpus token here so it covers fixed-drive, dynamic add, and remount paths.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, maybe a lambda that handles the adding the ; and adding the option.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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