Force virtiofs devices to a single virtio queue (vcpus=1)#40758
Open
asherkariv wants to merge 1 commit into
Open
Force virtiofs devices to a single virtio queue (vcpus=1)#40758asherkariv wants to merge 1 commit into
asherkariv wants to merge 1 commit into
Conversation
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
Add a vcpus=1 token to the virtiofs device-options string so each device
exposes a single virtio queue. This bounds the number of concurrent
guest-memory apertures the device can request, avoiding the host VID's
512-aperture quota that wsldevicehost otherwise livelocks against when
servicing many parallel requests.
- Define a shared c_vcpusOption ("vcpus=1") constant in
GuestDeviceManager.h, with a TODO to revisit once the devicehost
supports multiple shares per device.
- HcsVirtualMachine::AddShare and WslCoreVm::AddVirtioFsShare append the
swiotlb and vcpus tokens via a small appendOption lambda, covering the
fixed-drive, dynamic-add, and remount paths. Both tokens are constant
for the VM's lifetime, so duplicates collapse to a single VirtioFsShare
map entry.
- Bump Microsoft.WSL.DeviceHost to 1.2.32-0.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
c848fdd to
e5f8b82
Compare
Comment on lines
+2189
to
+2193
| // Append swiotlb and vcpus here to cover the fixed-drive, dynamic add, and remount paths. | ||
| // Safe to duplicate: both tokens are constant per VM, and VirtioFsShare collapses repeats into one map entry. | ||
| std::wstring effectiveOptions(Options); | ||
| if (!m_swiotlbOption.empty()) | ||
| { | ||
| auto appendOption = [&effectiveOptions](const std::wstring& option) { | ||
| if (option.empty()) |
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
Force each virtiofs device to a single virtio queue by adding a
vcpus=1token to the virtiofs device-options string. This bounds the number of concurrent guest-memory apertures a device can request, avoiding the host VID's 512-aperture quota thatwsldevicehostotherwise livelocks against when servicing many parallel requests.The token reuses the existing device-options channel already used to pass the
swiotlbinformation, so no new IPC path or message format is introduced.Detailed Description of the Pull Request / Additional comments
c_vcpusOption("vcpus=1") constant inGuestDeviceManager.h, with a TODO to revisit once the devicehost supports multiple shares per device.HcsVirtualMachine::AddShare(wslc) andWslCoreVm::AddVirtioFsShare(wsl) append theswiotlbandvcpustokens via a smallappendOptionlambda, covering the fixed-drive, dynamic-add, and remount paths.VirtioFsShareparses the options into a map.Microsoft.WSL.DeviceHostto1.2.32-0.PR Checklist
Validation Steps Performed
Manually validated that virtiofs
/mnt/cshares come up with thevcpus=1option across fixed-drive, dynamic-add, and remount paths, and thatwsldevicehostno longer exhausts the host VID aperture quota under parallel load.