From patchwork Tue Feb 27 08:07:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10244473 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0AA0360211 for ; Tue, 27 Feb 2018 08:13:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EEA2D2937D for ; Tue, 27 Feb 2018 08:13:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1F302A43B; Tue, 27 Feb 2018 08:13:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 83F9F2937D for ; Tue, 27 Feb 2018 08:13:43 +0000 (UTC) Received: from localhost ([::1]:35426 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqaOM-0007Cf-Pz for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Feb 2018 03:13:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46298) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqaIL-0001db-F5 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 03:07:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqaIJ-0003E4-UC for qemu-devel@nongnu.org; Tue, 27 Feb 2018 03:07:29 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38130 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 1eqaIJ-0003Dg-Lu for qemu-devel@nongnu.org; Tue, 27 Feb 2018 03:07:27 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6209E4040073 for ; Tue, 27 Feb 2018 08:07:27 +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 6E60A111DCFE; Tue, 27 Feb 2018 08:07:26 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E71CE17539; Tue, 27 Feb 2018 09:07:24 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 27 Feb 2018 09:07:18 +0100 Message-Id: <20180227080724.13585-7-kraxel@redhat.com> In-Reply-To: <20180227080724.13585-1-kraxel@redhat.com> References: <20180227080724.13585-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 27 Feb 2018 08:07:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 27 Feb 2018 08:07:27 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.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] [PULL 06/12] 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 , Gerd Hoffmann Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Using the new display registry instead of #ifdefs in vl.c. Signed-off-by: Gerd Hoffmann Message-id: 20180221131537.31341-7-kraxel@redhat.com --- 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 { }; 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); 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] = ui; } +bool qemu_display_find_default(DisplayOptions *opts) +{ + static DisplayType prio[] = { + DISPLAY_TYPE_GTK, + DISPLAY_TYPE_SDL, + DISPLAY_TYPE_COCOA + }; + int i; + + for (i = 0; i < ARRAY_SIZE(prio); i++) { + if (dpys[prio[i]] == NULL) { + continue; + } + opts->type = 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 == DISPLAY_TYPE_DEFAULT && !display_remote) { -#if defined(CONFIG_GTK) - dpy.type = DISPLAY_TYPE_GTK; -#elif defined(CONFIG_SDL) - dpy.type = DISPLAY_TYPE_SDL; -#elif defined(CONFIG_COCOA) - dpy.type = DISPLAY_TYPE_COCOA; -#elif defined(CONFIG_VNC) - vnc_parse("localhost:0,to=99,id=default", &error_abort); -#else - dpy.type = DISPLAY_TYPE_NONE; + if (!qemu_display_find_default(&dpy)) { + dpy.type = DISPLAY_TYPE_NONE; +#if defined(CONFIG_VNC) + vnc_parse("localhost:0,to=99,id=default", &error_abort); #endif + } } if (dpy.type == DISPLAY_TYPE_DEFAULT) { dpy.type = DISPLAY_TYPE_NONE;