Uh oh!
There was an error while loading. Please reload this page.
Harden vGPU release ordering in the instance lifecycle - #322
Conversation
yummybomb
commented
Aug 4, 2026
Trimmed over-engineering after an architectural review against the parent task (host kernel 6.8 / Ubuntu 24.04 support):
Kept as-is:
Tests: |
8abb859 to
d489510CompareUh oh!
There was an error while loading. Please reload this page.
d489510 to
186cbf3CompareUh oh!
There was an error while loading. Please reload this page.
e458102 to
7e121c6Compare7e10cf7 to
cf815e2CompareUh oh!
There was an error while loading. Please reload this page.
8cf6df0 to
ffbcfbbCompareUh oh!
There was an error while loading. Please reload this page.
8eae7ac to
2cdc587Compare2cdc587 to
99275acCompareUh oh!
There was an error while loading. Please reload this page.
3ec8640 to
e43b46fCompareUh oh!
There was an error while loading. Please reload this page.
e43b46f to
a4e00beComparebb72152 to
fd80867Compared7cb958 to
d9fbf20Compare74862bf to
e22b845Compare82e452f to
7681ba1Compare…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.
7681ba1 to
c1048a4Compare
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 GPU device teardown and metadata persistence on start/stop/delete/fork. Incorrect ordering could leak or double-destroy vGPUs, but failed releases remain best-effort and are covered by new lifecycle tests.
Overview
Tightens vGPU assignment ownership so a failed release cannot leak a device to another instance or leave stale host paths in metadata.
Stop now retains assignment metadata when destroy fails (instead of clearing it anyway). A later stop of an already-stopped instance retries that release without breaking the no-op contract.
Start releases any retained assignment and persists the cleared fields before recreating a vGPU, so a later start failure cannot point at a device that is already gone.
Delete releases the vGPU immediately after the VMM is dead (before network/device/volume teardown) and persists a successful clear. Failed release still continues teardown. Restart policy is blocked and metadata reloaded first so later saves do not wipe the block.
Fork/restore never share a live assignment: forks strip device path/UUID (profile is kept); snapshot restore keeps the instance’s current assignment instead of resurrecting the snapshot copy.
Reviewed by Cursor Bugbot for commit c1048a4. Bugbot is set up for automated code reviews on this repo. Configure here.