Skip to content

Commit

Permalink
ui: check hw requirements during DCL registration
Browse files Browse the repository at this point in the history
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20210204105232.834642-14-marcandre.lureau@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
  • Loading branch information
elmarco authored and kraxel committed Feb 4, 2021
1 parent d0e137b commit 5983fdf
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions ui/console.c
Expand Up @@ -1476,12 +1476,37 @@ static bool displaychangelistener_has_dmabuf(DisplayChangeListener *dcl)
return false;
}

static bool dpy_compatible_with(QemuConsole *con,
DisplayChangeListener *dcl, Error **errp)
{
ERRP_GUARD();
int flags;

flags = con->hw_ops->get_flags ? con->hw_ops->get_flags(con->hw) : 0;

if (flags & GRAPHIC_FLAGS_GL &&
!console_has_gl(con)) {
error_setg(errp, "The console requires a GL context.");
return false;

}

if (flags & GRAPHIC_FLAGS_DMABUF &&
!displaychangelistener_has_dmabuf(dcl)) {
error_setg(errp, "The console requires display DMABUF support.");
return false;
}

return true;
}

void register_displaychangelistener(DisplayChangeListener *dcl)
{
static const char nodev[] =
"This VM has no graphic display device.";
static DisplaySurface *dummy;
QemuConsole *con;
Error *err = NULL;

assert(!dcl->ds);

Expand All @@ -1496,6 +1521,11 @@ void register_displaychangelistener(DisplayChangeListener *dcl)
dcl->con->gl = dcl;
}

if (dcl->con && !dpy_compatible_with(dcl->con, dcl, &err)) {
error_report_err(err);
exit(1);
}

trace_displaychangelistener_register(dcl, dcl->ops->dpy_name);
dcl->ds = get_alloc_displaystate();
QLIST_INSERT_HEAD(&dcl->ds->listeners, dcl, next);
Expand Down

0 comments on commit 5983fdf

Please sign in to comment.