Allocate: expose only the requested device's address per resource#191
Open
omniverse-devplat-leo wants to merge 1 commit into
Open
Allocate: expose only the requested device's address per resource#191omniverse-devplat-leo wants to merge 1 commit into
omniverse-devplat-leo wants to merge 1 commit into
Conversation
Allocate appended every function of a device's IOMMU group to the requested resource's PCI_RESOURCE_* env. KubeVirt assigns those addresses positionally to the consuming slots, so for a multi-function device a sibling function can occupy a slot meant for another requested device: when two of the same resource are requested, the first device's sibling fills the second slot and the guest sees only one device. Expose only the requested device's address. The full IOMMU group is still bound via the vfio DeviceSpecs, and each function is advertised as its own resource, so a workload that needs a sibling function requests it directly. This is symmetric across resources and keeps non-display functions usable. Adds a unit test covering a multi-function IOMMU group. Signed-off-by: Leo Hsieh <lhsieh@nvidia.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
b39db73 to
9d51c5c
Compare
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.
Problem
Allocateadds every function of a device's IOMMU group to the requestedresource's
PCI_RESOURCE_*env. KubeVirt consumes those addressespositionally, mapping them to the
gpus:/hostDevices:slots in requestorder. For a multi-function device this hands a sibling function (e.g. a
GPU's audio function) an address slot of its own — so when a VM requests two
of the same resource, the first device's sibling fills the second slot and
the guest sees only one device instead of two.
Fix
Expose only the requested device's address in its resource env. The full
IOMMU group is still bound via the vfio
DeviceSpecs, and each function isalready advertised as its own resource, so a workload that needs a sibling
function requests it explicitly via
hostDevices:. The change is symmetricacross resources and keeps non-display functions available.
Adds a unit test covering a multi-function IOMMU group.
Validation
Validated on a 2-GPU passthrough VM (KubeVirt v1.5.x): before the change the
guest saw a single GPU; after it sees both. Single-GPU and audio-passthrough
cases are unaffected;
go test ./pkg/device_plugin/passes.