From nobody Tue Feb 10 09:58:54 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678737830; cv=none; d=zohomail.com; s=zohoarc; b=iOFCrxM/9ttKGpBER4TSuxmqBfouTMMY+T4tFv1C04BXx3JvVV8kyA+Oea+jk0QGIO/bV1t1tOD8XY7FtcvoGqAeIwF2q9N8Swv0s/HxEw5gbTTHgjDkYu1uAkQEdwKp1kQuhw2ZBhO9S6Ei8/4h3fn0RNQDlFzplxpD50/FRDM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678737830; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+w3m5MM/luTsDb4wGOiNxqG4mJgd+H3YJg6/JPwNn0Q=; b=EiIqrRcTXtSVZ8RU6O8wOT2BMQ56Uei/VMSqzGTZOcWa8LpcOLVGEnX3hlNBy5pJZU8QEWSmIGtCa1rkOWjSpIg5v8IPGqZnEKsQWdNuK+k4Jy7eYD0BelR993qYYT5hWz0+uCZBz2XTAMNrqSNCRVhqhWKpAiC00oDdZIoYh9Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1678737830809198.18316740957698; Mon, 13 Mar 2023 13:03:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pboNp-0003Vl-Di; Mon, 13 Mar 2023 16:03:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pboNn-0003Ms-FB for qemu-devel@nongnu.org; Mon, 13 Mar 2023 16:02:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pboNl-0004oZ-N7 for qemu-devel@nongnu.org; Mon, 13 Mar 2023 16:02:59 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-212-NgMqzaSfMoykmuk5llr4Hw-1; Mon, 13 Mar 2023 16:02:50 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 39EBB811E6E; Mon, 13 Mar 2023 20:02:50 +0000 (UTC) Received: from localhost (unknown [10.39.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0C65400F51; Mon, 13 Mar 2023 20:02:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678737777; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+w3m5MM/luTsDb4wGOiNxqG4mJgd+H3YJg6/JPwNn0Q=; b=drMK6Xi07wQLf4Jqq3q4ZslrHWNmIeASdicyYPWBNmblneAP0Y7aaYuqkanMeRgqecDm8i srmKsH8DpneSX14bbfiIqIUzWc9PukHD6VPp/3/yS0XDC6u3ptsxyLo4HKHZfPaipT/sZb t4rHvACTxvuRheslWJGcASiqgoNzliM= X-MC-Unique: NgMqzaSfMoykmuk5llr4Hw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Thomas Huth , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Gerd Hoffmann , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 16/18] ui: introduce egl_init() Date: Tue, 14 Mar 2023 00:01:32 +0400 Message-Id: <20230313200134.503083-17-marcandre.lureau@redhat.com> In-Reply-To: <20230313200134.503083-1-marcandre.lureau@redhat.com> References: <20230313200134.503083-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678737832090100002 From: Marc-Andr=C3=A9 Lureau Future patches will introduce EGL support on win32 (too late for 8.0 though). Having a common place for EGL initialization and error handling will make it simpler. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 --- include/ui/egl-helpers.h | 2 ++ ui/dbus.c | 7 +------ ui/egl-headless.c | 16 ++++++++-------- ui/egl-helpers.c | 24 ++++++++++++++++++++++++ ui/spice-core.c | 7 +------ 5 files changed, 36 insertions(+), 20 deletions(-) diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h index c92dd90e33..53d953ddf4 100644 --- a/include/ui/egl-helpers.h +++ b/include/ui/egl-helpers.h @@ -65,4 +65,6 @@ int qemu_egl_init_dpy_mesa(EGLNativeDisplayType dpy, Disp= layGLMode mode); EGLContext qemu_egl_init_ctx(void); bool qemu_egl_has_dmabuf(void); =20 +bool egl_init(const char *rendernode, DisplayGLMode mode, Error **errp); + #endif /* EGL_HELPERS_H */ diff --git a/ui/dbus.c b/ui/dbus.c index f529928f0b..ebf03bd84d 100644 --- a/ui/dbus.c +++ b/ui/dbus.c @@ -451,12 +451,7 @@ early_dbus_init(DisplayOptions *opts) DisplayGLMode mode =3D opts->has_gl ? opts->gl : DISPLAYGL_MODE_OFF; =20 if (mode !=3D DISPLAYGL_MODE_OFF) { - if (egl_rendernode_init(opts->u.dbus.rendernode, mode) < 0) { - error_report("dbus: render node init failed"); - exit(1); - } - - display_opengl =3D 1; + egl_init(opts->u.dbus.rendernode, mode, &error_fatal); } =20 type_register(&dbus_vc_type_info); diff --git a/ui/egl-headless.c b/ui/egl-headless.c index ae07e91302..ef70e6a18e 100644 --- a/ui/egl-headless.c +++ b/ui/egl-headless.c @@ -1,7 +1,7 @@ #include "qemu/osdep.h" #include "qemu/error-report.h" #include "qemu/module.h" -#include "sysemu/sysemu.h" +#include "qapi/error.h" #include "ui/console.h" #include "ui/egl-helpers.h" #include "ui/egl-context.h" @@ -191,21 +191,21 @@ static const DisplayGLCtxOps eglctx_ops =3D { =20 static void early_egl_headless_init(DisplayOptions *opts) { - display_opengl =3D 1; + DisplayGLMode mode =3D DISPLAYGL_MODE_ON; + + if (opts->has_gl) { + mode =3D opts->gl; + } + + egl_init(opts->u.egl_headless.rendernode, mode, &error_fatal); } =20 static void egl_headless_init(DisplayState *ds, DisplayOptions *opts) { - DisplayGLMode mode =3D opts->has_gl ? opts->gl : DISPLAYGL_MODE_ON; QemuConsole *con; egl_dpy *edpy; int idx; =20 - if (egl_rendernode_init(opts->u.egl_headless.rendernode, mode) < 0) { - error_report("egl: render node init failed"); - exit(1); - } - for (idx =3D 0;; idx++) { DisplayGLCtx *ctx; =20 diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index b11837415b..4203163ace 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -19,6 +19,8 @@ #include "qemu/error-report.h" #include "ui/console.h" #include "ui/egl-helpers.h" +#include "sysemu/sysemu.h" +#include "qapi/error.h" =20 EGLDisplay *qemu_egl_display; EGLConfig qemu_egl_config; @@ -569,3 +571,25 @@ EGLContext qemu_egl_init_ctx(void) =20 return ectx; } + +bool egl_init(const char *rendernode, DisplayGLMode mode, Error **errp) +{ + ERRP_GUARD(); + + if (mode =3D=3D DISPLAYGL_MODE_OFF) { + error_setg(errp, "egl: turning off GL doesn't make sense"); + return false; + } + +#ifdef CONFIG_GBM + if (egl_rendernode_init(rendernode, mode) < 0) { + error_setg(errp, "egl: render node init failed"); + return false; + } + display_opengl =3D 1; + return true; +#else + error_setg(errp, "egl: not available on this platform"); + return false; +#endif +} diff --git a/ui/spice-core.c b/ui/spice-core.c index 76f7c2bc3d..b05c830086 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -820,12 +820,7 @@ static void qemu_spice_init(void) "incompatible with -spice port/tls-port"); exit(1); } - if (egl_rendernode_init(qemu_opt_get(opts, "rendernode"), - DISPLAYGL_MODE_ON) !=3D 0) { - error_report("Failed to initialize EGL render node for SPICE G= L"); - exit(1); - } - display_opengl =3D 1; + egl_init(qemu_opt_get(opts, "rendernode"), DISPLAYGL_MODE_ON, &err= or_fatal); spice_opengl =3D 1; } #endif --=20 2.39.2