Add the vendor VFIO vGPU device backend - #364
Open
yummybomb wants to merge 8 commits into
Open
Conversation
This was referenced Aug 6, 2026
yummybomb
marked this pull request as ready for review
August 6, 2026 19:20
yummybomb
force-pushed
the
hypeship/vendor-vfio-backend
branch
from
August 6, 2026 19:26
2bb8e86 to
7fc3b49
Compare
yummybomb
force-pushed
the
hypeship/vendor-vfio-backend
branch
from
August 6, 2026 19:40
7fc3b49 to
f661e63
Compare
yummybomb
force-pushed
the
hypeship/vendor-vfio-backend
branch
from
August 7, 2026 14:02
f661e63 to
d1207d0
Compare
Linux 6.8 hosts with NVIDIA R580 drop the mdev interface: vGPUs are assigned by writing a type ID to a VF's nvidia/current_vgpu_type and passed to QEMU as a plain VFIO PCI device. Add a vendor VFIO backend behind the existing framework dispatch: profile discovery from the capacity-dependent creatable catalogs, least-loaded VF placement, create/verify/rollback, and release. Because the same VF path is reused across assignments (unlike mdev UUIDs), release is guarded: an in-process owner map covers the window before QEMU opens the device, and an open-VFIO-handle scan refuses to clear a VF a running VM still holds. Reconciliation clears orphaned assignments on startup, skipping VFs protected by the caller and failing closed when the protected set is unavailable. Branch the vGPU integration test by discovered framework and extend it to cover release on stop and reacquisition on start.
yummybomb
force-pushed
the
hypeship/vendor-vfio-backend
branch
from
August 7, 2026 15:04
d1207d0 to
5b47670
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5b47670. Configure here.
| framebuffer, ok := s.framebufferByType[vf.ProfileType] | ||
| if !ok { | ||
| return "", fmt.Errorf("framebuffer size for allocated vGPU type %s is unknown", vf.ProfileType) | ||
| } |
There was a problem hiding this comment.
Unknown type blocks placement
Medium Severity
selectLeastLoadedVF returns an error when an allocated VF’s ProfileType is missing from framebufferByType. That map is filled only from creatable catalogs, so an active assignment with an empty or stale creatable file can prevent any new vGPU creation on the host.
Reviewed by Cursor Bugbot for commit 5b47670. Configure here.
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
Layer 2 of the vendor VFIO vGPU stack (
generalize-vgpu-device←hypervisor-liveness← this ←vendor-vfio-vgpu). Self-contained inlib/devices+lib/resources; nothing in the instance lifecycle calls it yet (that's the top layer).Linux 6.8 hosts with NVIDIA R580 drop the mdev interface: vGPUs are assigned by writing a type ID to a VF's
nvidia/current_vgpu_typeand passed to QEMU as a plain VFIO PCI device. This adds that backend behind the framework dispatch introduced in #322:creatable_vgpu_typescatalogs, least-loaded-GPU VF selection, create/verify/rollback.Testing
go build ./...,go vetcleango test -race ./lib/devices/ ./lib/resources/passNote
High Risk
Changes sysfs vGPU assignment, release semantics, and startup reconciliation on production GPU hosts; incorrect release or reconcile logic could disrupt running VMs or clear another instance’s VF assignment.
Overview
Introduces vendor VFIO as a second vGPU path for SR-IOV hosts (e.g. Linux 6.8 / R580) where profiles are assigned by writing type IDs to each VF’s
nvidia/current_vgpu_typeinstead of creating mdevs. mdev remains preferred when usable VFs exist undermdev_bus; otherwise discovery falls back to PCI VFs that exposecreatable_vgpu_types.lib/devicescentralizes behavior behindDiscoverVGPU, framework-awareListGPUProfilesWithVFs,CreateVGPU/DestroyVGPU, andReconcileVGPUs. Vendor VFIO adds profile parsing, least-loaded-GPU placement, create verify/rollback, an in-process owner map plus open VFIO handle checks before release, and startup reconciliation that honors a protected device-path set. mdev VF discovery now skips VFs without realmdev_supported_typesentries.DetectHostGPUModeis removed in favor of vGPU discovery plus passthrough probing in resources.lib/resourcesGetGPUStatusnow takescontext.Context, routes vGPU status through the active framework, and falls back to passthrough if vGPU discovery fails so whole-GPU status is not hidden.Integration
TestVGPUis framework-aware (GPUFramework,GPUDevicePath), asserts sysfs assignment per framework, exercises mdev release on stop / reacquire on start vs vendor VFIO retention on stop, and cleans up vendor assignments on teardown. GPU.md documents both frameworks and updated lifecycle/troubleshooting.Reviewed by Cursor Bugbot for commit 5b47670. Bugbot is set up for automated code reviews on this repo. Configure here.