nvpassthrough: keep a card's other functions bound across driver switches #130
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.43) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 379 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.355
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #130"
general
weight: 0.35
cdesiniotis
Follow-up to kubernetes-sigs/dra-driver-nvidia-gpu#1567, where the maintainers asked for the fix to go here.
Problem
Unbindunbinds the device and every other PCI function of the same card (HDMI audio, and since #115 also the VirtualLink USB functions), and clears theirdriver_override.BindToDriverthen binds only the device itself. So a caller that switches a GPU withUnbind+BindToDriver, as the DRA driver does, leaves the other functions without a driver after every switch, in both directions:vfio-pci, but its audio function is left unbound instead of moving to vfio with it.vfio-pcifor passthrough (for example viavfio_pci ids=, so that KubeVirt can pass it to a VM as a PCI host device) loses that binding on every VM start and stop.Fix
BindToDriverbinds the other functions of the card as well when the target is a vfio driver (vfio-pcior a variant), reusing the loop fromBindToVFIODriver(nowbindAuxDevices).Unbindonly unbinds the device it is given. The bind side already moves the other functions to vfio, and no API binds them back to a host driver, so unbinding them only left them driverless.With this,
Unbind+BindToDriver(vfio)moves the whole card to vfio, andUnbind+BindToDriver(nvidia)returns only the GPU and leaves the other functions where they are. The DRA driver needs no code change, only the dependency bump.The
Unbindchange is a behaviour change for callers that expect it to free the whole card. The only importer I could find is the DRA driver (k8s-driver-manager carries its own copy ininternal/nvpassthrough). If you would rather keepUnbindas it is, an alternative is a separate method that unbinds only the given function, which the DRA driver would then call.Tests
TestIsVFIODrivercovers the vfio driver check, including variant drivers and both_and-spellings.make assert-fmt vet check-vendor,go test ./pkg/nvpassthrough/andgolangci-lint run ./pkg/nvpassthrough/...pass.gpu-kubelet-plugintests pass with this branch via areplacedirective and no other change.vfio-pciviavfio_pci ids=), KubeVirt v1.9.0, running the DRA driver built against this branch with no DRA driver code change. Stopping the VM returned the GPU tonvidiaand left the audio function onvfio-pci; starting it again moved the GPU tovfio-pci, and the VM came up with the GPU and the audio function (as a KubeVirt PCI host device). With v0.12.0 and v0.13.0 the audio function is left without a driver after each switch. The vfio direction ofBindToDriverdid not have to move the audio function in that run, since it was already onvfio-pci; that path is the same loopBindToVFIODriveruses.