[PATCH] ui/dbus: skip GL scanout dispatch for placeholder surfaces

Rick Vernam posted 1 patch 2 weeks, 4 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260907221838.519111-1-rtvernam@gmail.com
Maintainers: "Marc-André Lureau" <marcandre.lureau@redhat.com>
ui/dbus-listener.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] ui/dbus: skip GL scanout dispatch for placeholder surfaces
Posted by Rick Vernam 2 weeks, 4 days ago
When using -display dbus,gl=on together with a virgl-capable video
device (e.g. virtio-vga-gl), a guest-initiated reboot aborts QEMU
with "dbus_scanout_texture: Assertion `tex_id' failed"

virtio-gpu's device reset path blanks each console via
qemu_console_set_surface(con, NULL), qemu_console_set_surface()
in turn substitues a placeholder DisplaySurface.  The placeholder
DisplaySurface does not have a GL texture.

Other GL-capable UI backends already guard against this: both
sdl2_gl_switch() (ui/sdl2-gl.c) and the 2D SDL path (ui/sdl2-2d.c)
check surface_is_placeholder() before touching GL-texture state.

This patch adds an equivalent check in
ui/dbus-listener.c dbus_gl_gfx_switch().

Signed-off-by: Rick Vernam <rtvernam@gmail.com>
---
 ui/dbus-listener.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c
index 2e2f6ba418..5f627f6acf 100644
--- a/ui/dbus-listener.c
+++ b/ui/dbus-listener.c
@@ -861,6 +861,9 @@ static void dbus_gl_gfx_switch(DisplayChangeListener *dcl,
     trace_dbus_gl_gfx_switch(new_surface);
 
     ddl->ds = new_surface;
+    if (surface_is_placeholder(new_surface)) {
+        return;   /* nothing real to scan out; avoid dereferencing a non-GL surface */
+    }
     ddl->ds_share = SHARE_KIND_NONE;
     if (ddl->ds) {
         int width = surface_width(ddl->ds);
-- 
2.55.0
Re: [PATCH] ui/dbus: skip GL scanout dispatch for placeholder surfaces
Posted by Marc-André Lureau 2 weeks, 4 days ago
Hi

On Tue, Sep 8, 2026 at 2:18 AM Rick Vernam <rtvernam@gmail.com> wrote:
>
> When using -display dbus,gl=on together with a virgl-capable video
> device (e.g. virtio-vga-gl), a guest-initiated reboot aborts QEMU
> with "dbus_scanout_texture: Assertion `tex_id' failed"

I do not observe such crash. How did you configure QEMU? Can you
provide a backtrace?

>
> virtio-gpu's device reset path blanks each console via
> qemu_console_set_surface(con, NULL), qemu_console_set_surface()
> in turn substitues a placeholder DisplaySurface.  The placeholder
> DisplaySurface does not have a GL texture.

Before calling gfx_switch(), it calls gfx_create_texture()

>
> Other GL-capable UI backends already guard against this: both
> sdl2_gl_switch() (ui/sdl2-gl.c) and the 2D SDL path (ui/sdl2-2d.c)
> check surface_is_placeholder() before touching GL-texture state.

Not for this reason though, afaict. (for secondary/disabled screens)

>
> This patch adds an equivalent check in
> ui/dbus-listener.c dbus_gl_gfx_switch().
>
> Signed-off-by: Rick Vernam <rtvernam@gmail.com>
> ---
>  ui/dbus-listener.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c
> index 2e2f6ba418..5f627f6acf 100644
> --- a/ui/dbus-listener.c
> +++ b/ui/dbus-listener.c
> @@ -861,6 +861,9 @@ static void dbus_gl_gfx_switch(DisplayChangeListener *dcl,
>      trace_dbus_gl_gfx_switch(new_surface);
>
>      ddl->ds = new_surface;
> +    if (surface_is_placeholder(new_surface)) {
> +        return;   /* nothing real to scan out; avoid dereferencing a non-GL surface */
> +    }
>      ddl->ds_share = SHARE_KIND_NONE;
>      if (ddl->ds) {
>          int width = surface_width(ddl->ds);
> --
> 2.55.0
>