From 82d7064f0422dea4080e8bbb0919287cbe1d44b2 Mon Sep 17 00:00:00 2001 From: Anees Iqbal Date: Wed, 2 Dec 2026 11:08:44 -0800 Subject: [PATCH] :bug: Release reims-graphics at a quit of a VM that was not running vendor/qemu moves to f8a1f0c5 on the fork's steelbrain/reims-vgpu-rebase-2 (a60aa2b3 before it). A quit of a VM that QEMU was not running (paused by QMP's stop or by a full disk, never started past -S, or paused by a shutdown whose action pauses) stopped no running VM, so the device's VM state handler never tore it down. The device stayed to the exit, the library's quiesce at the end of QEMU's cleanup answered that it still held a GPU device, and QEMU ended with _exit. reims-ctl's stop of a VM paused for a full disk quits such a VM. QEMU's cleanup notifier now first tears down each device no teardown ran for, BAR 2 out of the guest's address space first, as at a stop. The release lets go of the GPU device, the quiesce answers true, and QEMU ends with exit(). Only a device a display's read kept (a GPU that stopped answering) still ends QEMU with _exit. docs/qemu.md and docs/api.md say so. What changes for the host: such a quit ends by exit(), with its exit handlers run. The guest sees nothing: it no longer runs. --- docs/api.md | 8 +++++--- docs/qemu.md | 12 ++++++++---- vendor/qemu | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/docs/api.md b/docs/api.md index 26cd7d47d..d74485cf9 100644 --- a/docs/api.md +++ b/docs/api.md @@ -238,9 +238,11 @@ the degradation counts). After a true answer the exit gate's handler still runs writes the counts. QEMU calls it, with a bound of 5 s, at the end of its cleanup (`qemu_cleanup`, through a notifier of -its own run there, `qemu_add_cleanup_notifier`), on every quit that reaches it: a released device, -a device kept by a shutdown action that pauses, a quit of a stopped VM, and a read of a display -that kept it. That runs before `exit` itself, so before every exit handler. It lets the BQL go +its own run there, `qemu_add_cleanup_notifier`), on every quit that reaches it: a device released at +the VM's stop, and a device kept by a read of a display. The notifier first releases each device +whose VM was not running at the quit (a VM paused or stopped before it, a shutdown action that +pauses), so that its quiesce answers true too. That runs before `exit` itself, so before every exit +handler. It lets the BQL go around the call, as around the release. On a false answer it runs what `exit` would run of QEMU's own: its exit notifiers (usb-host's return of host devices to their drivers, a tap's down script, the pidfile's removal), the terminal's restore where a chardev took stdio, and the flush of the C diff --git a/docs/qemu.md b/docs/qemu.md index 7f0f994d4..2d368b05e 100644 --- a/docs/qemu.md +++ b/docs/qemu.md @@ -558,10 +558,14 @@ is its transport: handler tears the device down, BAR 2 out of the guest's address space first, so that the library's release of its last device lets go of the GPU device before the process exits (docs/api.md, "The process's exit"). - A shutdown whose action pauses the VM (`-action shutdown=pause`, - `-no-shutdown`), and a quit of a VM stopped before it, keep the device to - the exit, as before. So does a quit while a read of a display (a - console's, above) still waits for its draw on the GPU: the teardown waits + A quit of a VM that was not running (paused by QMP's `stop` or by a full + disk, never started past `-S`, or paused by a shutdown whose action pauses, + `-action shutdown=pause` or `-no-shutdown`) stops no running VM, so no + VM-state handler hears it: the end of QEMU's cleanup tears such a device + down (the cleanup notifier, `reims_graphics_pci_cleanup`), and QEMU then + ends with `exit()`, as after a running VM's quit. A quit while a read of a + display (a console's, above) still waits for its draw on the GPU keeps the + device to the exit, and QEMU ends with `_exit`: the teardown waits for every display's read at most 5 s, under the BQL, as the reads use the device. A screendump still waiting for the read is answered first, with what the diff --git a/vendor/qemu b/vendor/qemu index 0f7f65aea..21e663657 160000 --- a/vendor/qemu +++ b/vendor/qemu @@ -1 +1 @@ -Subproject commit 0f7f65aea19155ce8cd3b9500cea69308dd0d64b +Subproject commit 21e663657d8eb188de0ae295ab90ea9422db52e5