← Back to Pull requests

Give a PCI function to a Pod through vfio-pci behind the VFIODriverRebind gate #420

Open
unknown opened this pull request with 611 lines diff across 7 files
View on GitHub
unknown unknown commented on Nov 14, 2026 14:10 UTC
Author

What type of PR is this?

/kind feature
/kind api-change

What this PR does / why we need it:

This implements the design discussed in #375: a claim can ask for the whole PCI function through VFIO instead of its netdev. It is behind a new alpha feature gate, VFIODriverRebind, off by default.

How it follows the points raised in #375:

| Point from the issue | How the PR handles it |
|---|---|
| DRANET stays the allocator, no separate pool | One device per PCI function, published on its kernel driver as today. With the gate on it also gets dra.net/vfio and the standard resource.kubernetes.io/pciBusID. The function is bound to vfio-pci only in prepare, for a claim with a vfio: {} config. |
| Never rebind without knowing the original driver | The original driver is written to the checkpoint before the first sysfs write. Functions already on vfio-pci at scan time are not published and never touched. |
| Restore the original driver, including across restarts and PF reloads | Unprepare sets driver_override to the recorded driver, unbinds, probes, checks it, and clears the override (naming the driver also covers a VF whose PF has sriov_drivers_autoprobe off). If that fails, the checkpoint is kept and the error goes back to kubelet, which retries. A function that no longer exists (PF reload, VF count change) counts as restored. The daemon refuses to start with the gate on and no --db-path. |
| Don't advertise what would fail at prepare | dra.net/vfio is false when vfio-pci is not loaded, the function has no IOMMU group or shares it with a device on another driver (unbound, pcieport and pci-stub members are fine), it is a PF with VFs, its netdev is part of a bond/bridge/VLAN, or it has host IP addresses. Prepare checks the same conditions again. |
| The only new host operation is the rebind | No netns work for a VFIO device. The NRI hook adds /dev/vfio/<group> and /dev/vfio/vfio (plus the cdev and /dev/iommu when the kernel provides both), the same way it adds RDMA char devices. |
| PCI address for the workload | The standard resource.kubernetes.io/pciBusID attribute of the allocated device in the ResourceSlice. No CDI or KEP-5304 device metadata. |
| Behind a flag | With the gate off, the ResourceSlice and PrepareResult are unchanged, and a vfio claim fails prepare with a message naming the gate. |

Commits are split by area to help review: API and gate, inventory, driver and NRI, deploy and e2e, docs.

Which issue(s) this PR is related to:

Fixes #375

Special notes for your reviewer:

  • Restarts: there is no separate reconcile at startup. A prepare interrupted after the record is written is resumed when kubelet retries it, and release always works from the checkpoint record, so a daemon restart while a claim is allocated still binds the original driver back on unprepare. The table in site/content/docs/concepts/vfio.md lists each case.

  • DeleteClaim drops every device entry of the pods that use the claim, so unprepare first restores every VFIO function those pods hold, and returns before any DHCP or profile release if a restore fails.

  • A vfio claim does not merge cloud-provider or profile configs, since those describe a netdev. Validation rejects any interface, route, rule, neighbor, ethtool, or profile setting together with vfio.

  • install.yaml and the Helm chart now mount /dev/vfio, for the char device numbers.

  • Testing done:

  • - Unit tests with -race for the bind order, rollback, restore, resume after an interrupted prepare, gate off, refused devices, unprepare with several claims, and NRI injection. A fake binder simulates the kernel's driver_override/probe behaviour. I also mutated the key invariants (record before the first write, error returned on a failed restore, pod-wide restore, each safety check) and confirmed the tests catch them.
    - A new bats test covers what kind can show: a vfio claim is refused with the gate off and for a non-PCI device, and netdev claims keep working with the gate on. Locally the test's assertions passed, but its final DaemonSet rollout (restoring the original args) timed out under emulation, as did the existing "allocated device in ResourceSlice remains unchanged" test, so I'd like to confirm both in CI.
  • Not done yet: validation on real hardware with an IOMMU and SR-IOV VFs, and the KubeVirt VM passthrough scenario. I'm keeping this as a draft until I can add those results.
  • Does this PR introduce a user-facing change?

    ``release-note
    Add the alpha
    VFIODriverRebind feature gate. With it, a claim with a vfio: {} config gets the PCI function bound to vfio-pci and its VFIO device nodes, and the original driver is bound back on release. Devices that can be given this way have the dra.net/vfio attribute set to true.
    ``

    🤖 Generated with Claude Code

    Diff: 611 lines (+458 / -153) across 7 files Reviewer: aojea Review duration: 4379m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.50) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 611 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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.384
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #420"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 50.2% (MEDIUM) · Higher = larger blast radius
    50.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 26.8% · Safe to merge
    26.8%