Harden vGPU release ordering in the instance lifecycle - #322
Open
yummybomb wants to merge 14 commits into
Open
Conversation
Contributor
Author
|
Trimmed over-engineering after an architectural review against the parent task (host kernel 6.8 / Ubuntu 24.04 support):
Kept as-is:
Tests: |
yummybomb
marked this pull request as ready for review
August 5, 2026 19:47
yummybomb
force-pushed
the
hypeship/generalize-vgpu-device
branch
from
August 5, 2026 19:47
8abb859 to
d489510
Compare
yummybomb
force-pushed
the
hypeship/generalize-vgpu-device
branch
from
August 5, 2026 20:24
d489510 to
186cbf3
Compare
yummybomb
changed the base branch from
main
to
hypeship/vgpu-framework-abstraction
August 6, 2026 19:16
yummybomb
force-pushed
the
hypeship/generalize-vgpu-device
branch
from
August 6, 2026 19:26
e458102 to
7e121c6
Compare
yummybomb
force-pushed
the
hypeship/generalize-vgpu-device
branch
2 times, most recently
from
August 7, 2026 14:02
7e10cf7 to
cf815e2
Compare
yummybomb
force-pushed
the
hypeship/generalize-vgpu-device
branch
from
August 7, 2026 20:52
8cf6df0 to
ffbcfbb
Compare
yummybomb
force-pushed
the
hypeship/generalize-vgpu-device
branch
from
August 9, 2026 07:52
8eae7ac to
2cdc587
Compare
This was referenced Aug 9, 2026
yummybomb
force-pushed
the
hypeship/generalize-vgpu-device
branch
from
August 10, 2026 18:26
2cdc587 to
99275ac
Compare
yummybomb
force-pushed
the
hypeship/generalize-vgpu-device
branch
from
August 10, 2026 18:58
3ec8640 to
e43b46f
Compare
yummybomb
force-pushed
the
hypeship/generalize-vgpu-device
branch
from
August 10, 2026 19:08
e43b46f to
a4e00be
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 7b1f995. Configure here.
yummybomb
force-pushed
the
hypeship/generalize-vgpu-device
branch
from
August 12, 2026 15:20
bb72152 to
fd80867
Compare
yummybomb
force-pushed
the
hypeship/generalize-vgpu-device
branch
2 times, most recently
from
August 13, 2026 18:28
d7cb958 to
d9fbf20
Compare
sjmiller609
approved these changes
Aug 14, 2026
yummybomb
force-pushed
the
hypeship/generalize-vgpu-device
branch
2 times, most recently
from
August 17, 2026 15:00
74862bf to
e22b845
Compare
…led release Start now releases any stored assignment before acquiring a new one and fails the start if that release fails. Stop and delete retain assignment metadata when release fails instead of clearing it, so a failed release can be retried later instead of leaking the device.
…ances retry a failed release
…ssignments to DestroyVGPU as a struct
Fork cloned the source's StoredMetadata wholesale, so an assignment retained by a failed release during stop was shared with the fork and either instance's later release could invalidate the other's. Clear the assignment fields on the fork while keeping GPUProfile; the fork acquires its own vGPU on start.
Start released a retained assignment but only saved metadata on the success path, so a failure later in start left on-disk metadata pointing at a device that was already released. Save right after the release, matching the retained-release retry on stop.
Restoring a snapshot rehydrated the vGPU assignment fields embedded in the snapshot metadata. A snapshot taken while an assignment was retained after a failed release could resurrect that claim after the release later succeeded, pointing the instance at a device that is gone or reused. Keep the instance's current assignment instead: device assignments are host state, not snapshot payload, and a claim retained at restore time must survive for the next release retry.
Delete goes back to the pre-refactor behavior: a failed vGPU release is logged and teardown continues, instead of failing the delete and retaining the instance. The release-side guards still never destroy a device they cannot prove is unowned, so continuing only tolerates a leaked slot until startup reconciliation recovers it - the same tradeoff the mdev path always made. The restart-policy block before teardown stays: a delete can still fail earlier when the hypervisor cannot be confirmed dead.
yummybomb
force-pushed
the
hypeship/generalize-vgpu-device
branch
from
August 18, 2026 14:42
e22b845 to
82e452f
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.

Summary
Layer 2 of the vendor VFIO vGPU stack (#366 ← this ← #363 ← #364 ← #321). Where #366 is a behavior-preserving refactor, this layer changes lifecycle semantics — release ordering and retention — still on mdev-era machinery, before the vendor VFIO backend lands above:
DestroyVGPUas a struct.Testing
go build ./...,go vetcleango test -racetargetedlib/instanceslifecycle suites passNote
Medium Risk
Changes ordering and persistence of GPU teardown and restart-policy blocking on delete; failures are mostly best-effort but incorrect behavior could leak vGPU slots or leave stale metadata until reconciliation.
Overview
Tightens vGPU assignment handling across instance lifecycle so metadata, forks, and snapshots cannot double-release or point at devices that are already gone.
Delete blocks restart policy before teardown (with a metadata reload so later saves keep that marker), then releases vGPU before network, devices, and volumes; successful release is persisted early, while failures stay best-effort and delete continues.
Stop no longer clears assignment fields on failed release—it retains metadata for retry. Stop on an already-stopped instance retries via
releaseRetainedVGPULocked. Start releases any stale retained assignment and persists cleared fields before the rest of start.Fork (instance and snapshot) strips live vGPU assignment from fork metadata while keeping
GPUProfile; restore snapshot keeps the instance’s current assignment instead of resurrecting the snapshot’s embedded copy.Adds
releaseRetainedVGPULockedand targeted lifecycle tests for ordering, persistence, and fork/restore behavior.Reviewed by Cursor Bugbot for commit 82e452f. Bugbot is set up for automated code reviews on this repo. Configure here.