From nobody Wed Oct 22 13:02:49 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519899283615575.11972423525; Thu, 1 Mar 2018 02:14:43 -0800 (PST) Received: from localhost ([::1]:55199 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1erLEO-0004Cb-So for importer@patchew.org; Thu, 01 Mar 2018 05:14:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42616) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1erL62-0005FN-Ho for qemu-devel@nongnu.org; Thu, 01 Mar 2018 05:05:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1erL5z-00052E-Ky for qemu-devel@nongnu.org; Thu, 01 Mar 2018 05:05:54 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42160 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1erL5z-00051h-H5 for qemu-devel@nongnu.org; Thu, 01 Mar 2018 05:05:51 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 261A417CEF3 for ; Thu, 1 Mar 2018 10:05:51 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-147.ams2.redhat.com [10.36.116.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id 841E89C04A; Thu, 1 Mar 2018 10:05:49 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 3DE3017539; Thu, 1 Mar 2018 11:05:48 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 1 Mar 2018 11:05:40 +0100 Message-Id: <20180301100547.18962-7-kraxel@redhat.com> In-Reply-To: <20180301100547.18962-1-kraxel@redhat.com> References: <20180301100547.18962-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 01 Mar 2018 10:05:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 01 Mar 2018 10:05:51 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kraxel@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 06/13] console: add and use qemu_display_find_default X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Markus Armbruster , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Using the new display registry instead of #ifdefs in vl.c. Signed-off-by: Gerd Hoffmann --- include/ui/console.h | 1 + ui/console.c | 19 +++++++++++++++++++ vl.c | 15 +++++---------- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 94726cf190..3a53db9360 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -441,6 +441,7 @@ struct QemuDisplay { }; =20 void qemu_display_register(QemuDisplay *ui); +bool qemu_display_find_default(DisplayOptions *opts); void qemu_display_early_init(DisplayOptions *opts); void qemu_display_init(DisplayState *ds, DisplayOptions *opts); =20 diff --git a/ui/console.c b/ui/console.c index a11b120fc8..25d342cdcb 100644 --- a/ui/console.c +++ b/ui/console.c @@ -2188,6 +2188,25 @@ void qemu_display_register(QemuDisplay *ui) dpys[ui->type] =3D ui; } =20 +bool qemu_display_find_default(DisplayOptions *opts) +{ + static DisplayType prio[] =3D { + DISPLAY_TYPE_GTK, + DISPLAY_TYPE_SDL, + DISPLAY_TYPE_COCOA + }; + int i; + + for (i =3D 0; i < ARRAY_SIZE(prio); i++) { + if (dpys[prio[i]] =3D=3D NULL) { + continue; + } + opts->type =3D prio[i]; + return true; + } + return false; +} + void qemu_display_early_init(DisplayOptions *opts) { assert(opts->type < DISPLAY_TYPE__MAX); diff --git a/vl.c b/vl.c index 47c953f8dc..59e56593f8 100644 --- a/vl.c +++ b/vl.c @@ -4285,17 +4285,12 @@ int main(int argc, char **argv, char **envp) } #endif if (dpy.type =3D=3D DISPLAY_TYPE_DEFAULT && !display_remote) { -#if defined(CONFIG_GTK) - dpy.type =3D DISPLAY_TYPE_GTK; -#elif defined(CONFIG_SDL) - dpy.type =3D DISPLAY_TYPE_SDL; -#elif defined(CONFIG_COCOA) - dpy.type =3D DISPLAY_TYPE_COCOA; -#elif defined(CONFIG_VNC) - vnc_parse("localhost:0,to=3D99,id=3Ddefault", &error_abort); -#else - dpy.type =3D DISPLAY_TYPE_NONE; + if (!qemu_display_find_default(&dpy)) { + dpy.type =3D DISPLAY_TYPE_NONE; +#if defined(CONFIG_VNC) + vnc_parse("localhost:0,to=3D99,id=3Ddefault", &error_abort); #endif + } } if (dpy.type =3D=3D DISPLAY_TYPE_DEFAULT) { dpy.type =3D DISPLAY_TYPE_NONE; --=20 2.9.3