Commit f16d923557 for qemu.org

commit f16d9235571b97d5ceee5e6ae9bb8b037d014b93
Author: Marc-André Lureau <marcandre.lureau@redhat.com>
Date:   Thu Aug 20 23:55:21 2026 +0400

    virtio-gpu: release the dmabuf when a scanout is disabled

    Rather than waiting for the next set_scanout()/update_dmabuf() to
    replace it.

    Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
    Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index ecf3cbc489..bcde65b503 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -418,20 +418,31 @@ static void virtio_gpu_resource_create_blob(VirtIOGPU *g,
     QTAILQ_INSERT_HEAD(&g->reslist, res, next);
 }

-void virtio_gpu_disable_scanout(VirtIOGPU *g, int scanout_id)
+static void virtio_gpu_release_scanout_dmabuf(VirtIOGPU *g, int scanout_id)
 {
     struct virtio_gpu_scanout *scanout = &g->parent_obj.scanout[scanout_id];
-    struct virtio_gpu_simple_resource *res;
+    g_autoptr(QemuDmaBuf) dmabuf = scanout->dmabuf;

-    if (scanout->resource_id == 0) {
+    if (!dmabuf) {
         return;
     }

+    scanout->dmabuf = NULL;
+    qemu_console_gl_release_dmabuf(scanout->con, dmabuf);
+}
+
+void virtio_gpu_disable_scanout(VirtIOGPU *g, int scanout_id)
+{
+    struct virtio_gpu_scanout *scanout = &g->parent_obj.scanout[scanout_id];
+    struct virtio_gpu_simple_resource *res;
+
     res = virtio_gpu_find_resource(g, scanout->resource_id);
     if (res) {
         res->scanout_bitmask &= ~(1 << scanout_id);
     }

+    virtio_gpu_release_scanout_dmabuf(g, scanout_id);
+
     qemu_console_set_surface(scanout->con, NULL);
     scanout->resource_id = 0;
     scanout->ds = NULL;