From nobody Mon May 6 20:14:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1623747898; cv=none; d=zohomail.com; s=zohoarc; b=auxhDYpbXSvfpiHV38HyySy/xZHoiqpfhm8E51xO+Paug4LpLYu/yp9Qb0VAHsZCLi9834UVmztGpm+0j0VqscicqFgMV57UXIOHfQeQkZRmJCE/MxEtB57qX151s/hTGx+xKiNLrqCdLmJ1H6k+ZEhc9BoLROZTjWWhjuBwaZc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1623747898; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=RL+50h9vmSdQ6ek3VVt9x2BYruTizZHc35L/871QydI=; b=QQA1uNK79GrjdIjXDFBgzQKuxwz58P5rKFdd+8kIA1BZIEDg2pGThXmK3MwPQkWzd6qBRuF4r1Kl/ZGRoK/FZ1147vQQ2cYhIj0xDU78JpNEirHtRqlH+uLEGc3OFA9To1gDeeWoRGEYZqt9qIyIKPW1q4uNUk7z8ERrwgknOCg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1623747898530995.8962295105156; Tue, 15 Jun 2021 02:04:58 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-258-opdX6wkrOKSOeImY5iCEtA-1; Tue, 15 Jun 2021 05:04:55 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0097C100C660; Tue, 15 Jun 2021 09:04:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BBDC660C0F; Tue, 15 Jun 2021 09:04:50 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7467B46F81; Tue, 15 Jun 2021 09:04:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15F94nIC010759 for ; Tue, 15 Jun 2021 05:04:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 830EB19726; Tue, 15 Jun 2021 09:04:49 +0000 (UTC) Received: from thuth.com (ovpn-114-110.ams2.redhat.com [10.36.114.110]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAF4D19D9B; Tue, 15 Jun 2021 09:04:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623747897; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=RL+50h9vmSdQ6ek3VVt9x2BYruTizZHc35L/871QydI=; b=IVabmiwryFZuIWZvJj1HLgakAxYLjg4o0+GMPTyXS6LGgZMP+LbL9M9/pXvV+dBVPh/9yB cZ5ZAkR24TihCqdpn9cMAeRAdCQOByL35xYk9Sc9ZttAbwYGzikhQN08TcDJjWfy9NxIZx gztb8BN51xMv5QtP2db2TNwC737ITEA= X-MC-Unique: opdX6wkrOKSOeImY5iCEtA-1 From: Thomas Huth To: Gerd Hoffmann , qemu-devel@nongnu.org Subject: [PATCH v2] ui: Make the DisplayType enum entries conditional Date: Tue, 15 Jun 2021 11:04:39 +0200 Message-Id: <20210615090439.70926-1-thuth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com, Eric Blake X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Libvirt's "domcapabilities" command has a way to state whether certain graphic frontends are available in QEMU or not. Originally, libvirt looked at the "--help" output of the QEMU binary to determine whether SDL was available or not (by looking for the "-sdl" parameter in the help text), but since libvirt stopped doing this analysis of the help text, the detection of SDL is currently broken, see: https://bugzilla.redhat.com/show_bug.cgi?id=3D1790902 QEMU should provide a way via the QMP interface instead. A simple way, without introducing additional commands, is to make the DisplayType enum entries conditional, so that the enum only contains the entries if the corresponding CONFIG_xxx switches have been set. This of course only gives an indication which possibilities have been enabled during compile-time of QEMU (and does not take into account whether modules are later available or not for example - for this we'd need a separate command), but anyway, this should already be good enough for the above bug ticket, and it's a good idea anyway to make the QMP interface conditional here, so let's simply do it. Signed-off-by: Thomas Huth --- v2: Make gtk, curses and egl also conditional qapi/ui.json | 23 +++++++++++++++++------ softmmu/vl.c | 20 +++++++++++++++++--- ui/console.c | 8 +++++++- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/qapi/ui.json b/qapi/ui.json index 1052ca9c38..6a667a0abf 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -1126,9 +1126,16 @@ # ## { 'enum' : 'DisplayType', - 'data' : [ 'default', 'none', 'gtk', 'sdl', - 'egl-headless', 'curses', 'cocoa', - 'spice-app'] } + 'data' : [ + { 'name': 'default' }, + { 'name': 'none' }, + { 'name': 'gtk', 'if': 'defined(CONFIG_GTK)' }, + { 'name': 'sdl', 'if': 'defined(CONFIG_SDL)' }, + { 'name': 'egl-headless', + 'if': 'defined(CONFIG_OPENGL) && defined(CONFIG_GBM)' }, + { 'name': 'curses', 'if': 'defined(CONFIG_CURSES)' }, + { 'name': 'cocoa', 'if': 'defined(CONFIG_COCOA)' }, + { 'name': 'spice-app', 'if': 'defined(CONFIG_SPICE)'} ] } =20 ## # @DisplayOptions: @@ -1152,9 +1159,13 @@ '*show-cursor' : 'bool', '*gl' : 'DisplayGLMode' }, 'discriminator' : 'type', - 'data' : { 'gtk' : 'DisplayGTK', - 'curses' : 'DisplayCurses', - 'egl-headless' : 'DisplayEGLHeadless'} } + 'data' : { + 'gtk': { 'type': 'DisplayGTK', 'if': 'defined(CONFIG_GTK)' }, + 'curses': { 'type': 'DisplayCurses', 'if': 'defined(CONFIG_CURSES)' = }, + 'egl-headless': { 'type': 'DisplayEGLHeadless', + 'if': 'defined(CONFIG_OPENGL) && defined(CONFIG_GB= M)' } + } +} =20 ## # @query-display-options: diff --git a/softmmu/vl.c b/softmmu/vl.c index 326c1e9080..fc103c2cb2 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -1068,6 +1068,7 @@ static void parse_display(const char *p) * Not clear yet what happens to them long-term. Should * replaced by something better or deprecated and dropped. */ +#if defined(CONFIG_SDL) dpy.type =3D DISPLAY_TYPE_SDL; while (*opts) { const char *nextopt; @@ -1131,6 +1132,10 @@ static void parse_display(const char *p) } opts =3D nextopt; } +#else + error_report("SDL display supported is not available in this binar= y"); + exit(1); +#endif } else if (strstart(p, "vnc", &opts)) { /* * vnc isn't a (local) DisplayType but a protocol for remote @@ -1867,13 +1872,22 @@ static void qemu_apply_machine_options(void) static void qemu_create_early_backends(void) { MachineClass *machine_class =3D MACHINE_GET_CLASS(current_machine); +#if defined(CONFIG_SDL) + const bool use_sdl =3D (dpy.type =3D=3D DISPLAY_TYPE_SDL); +#else + const bool use_sdl =3D false; +#endif +#if defined(CONFIG_GTK) + const bool use_gtk =3D (dpy.type =3D=3D DISPLAY_TYPE_GTK); +#else + const bool use_gtk =3D false; +#endif =20 - if ((alt_grab || ctrl_grab) && dpy.type !=3D DISPLAY_TYPE_SDL) { + if ((alt_grab || ctrl_grab) && !use_sdl) { error_report("-alt-grab and -ctrl-grab are only valid " "for SDL, ignoring option"); } - if (dpy.has_window_close && - (dpy.type !=3D DISPLAY_TYPE_GTK && dpy.type !=3D DISPLAY_TYPE_SDL)= ) { + if (dpy.has_window_close && !use_gtk && !use_sdl) { error_report("-no-quit is only valid for GTK and SDL, " "ignoring option"); } diff --git a/ui/console.c b/ui/console.c index 2de5f4105b..1103b65314 100644 --- a/ui/console.c +++ b/ui/console.c @@ -2370,13 +2370,19 @@ void qemu_display_register(QemuDisplay *ui) bool qemu_display_find_default(DisplayOptions *opts) { static DisplayType prio[] =3D { +#if defined(CONFIG_GTK) DISPLAY_TYPE_GTK, +#endif +#if defined(CONFIG_SDL) DISPLAY_TYPE_SDL, +#endif +#if defined(CONFIG_COCOA) DISPLAY_TYPE_COCOA +#endif }; int i; =20 - for (i =3D 0; i < ARRAY_SIZE(prio); i++) { + for (i =3D 0; i < (int)ARRAY_SIZE(prio); i++) { if (dpys[prio[i]] =3D=3D NULL) { ui_module_load_one(DisplayType_str(prio[i])); } --=20 2.27.0