Skip to content

Commit

Permalink
ui/console: fix crash when using gl context with non-gl listeners
Browse files Browse the repository at this point in the history
The commit 7cc712e ("ui: dispatch GL events to all listener")
mechanically replaced the dpy_gl calls with a dispatch loop, using the
same pre-conditions. However, it didn't take into account that all
listeners do not have to implement the GL callbacks.

Add the missing pre-conditions before calling the callbacks.

Fix crash when running a GL-enabled VM with "-device virtio-gpu-gl-pci
-display egl-headless -vnc :0".

Fixes: 7cc712e ("ui: dispatch GL events to all listener")
Reported-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20220214201337.1814787-2-marcandre.lureau@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
  • Loading branch information
elmarco authored and kraxel committed Mar 4, 2022
1 parent 0a2a40d commit a9fbce5
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions ui/console.c
Expand Up @@ -1860,7 +1860,9 @@ void dpy_gl_scanout_disable(QemuConsole *con)
con->scanout.kind = SCANOUT_NONE;
}
QLIST_FOREACH(dcl, &s->listeners, next) {
dcl->ops->dpy_gl_scanout_disable(dcl);
if (dcl->ops->dpy_gl_scanout_disable) {
dcl->ops->dpy_gl_scanout_disable(dcl);
}
}
}

Expand All @@ -1881,10 +1883,12 @@ void dpy_gl_scanout_texture(QemuConsole *con,
x, y, width, height
};
QLIST_FOREACH(dcl, &s->listeners, next) {
dcl->ops->dpy_gl_scanout_texture(dcl, backing_id,
backing_y_0_top,
backing_width, backing_height,
x, y, width, height);
if (dcl->ops->dpy_gl_scanout_texture) {
dcl->ops->dpy_gl_scanout_texture(dcl, backing_id,
backing_y_0_top,
backing_width, backing_height,
x, y, width, height);
}
}
}

Expand All @@ -1897,7 +1901,9 @@ void dpy_gl_scanout_dmabuf(QemuConsole *con,
con->scanout.kind = SCANOUT_DMABUF;
con->scanout.dmabuf = dmabuf;
QLIST_FOREACH(dcl, &s->listeners, next) {
dcl->ops->dpy_gl_scanout_dmabuf(dcl, dmabuf);
if (dcl->ops->dpy_gl_scanout_dmabuf) {
dcl->ops->dpy_gl_scanout_dmabuf(dcl, dmabuf);
}
}
}

Expand Down Expand Up @@ -1951,7 +1957,9 @@ void dpy_gl_update(QemuConsole *con,

graphic_hw_gl_block(con, true);
QLIST_FOREACH(dcl, &s->listeners, next) {
dcl->ops->dpy_gl_update(dcl, x, y, w, h);
if (dcl->ops->dpy_gl_update) {
dcl->ops->dpy_gl_update(dcl, x, y, w, h);
}
}
graphic_hw_gl_block(con, false);
}
Expand Down

0 comments on commit a9fbce5

Please sign in to comment.