From patchwork Tue May 7 08:19:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 10932549 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B5D5114DB for ; Tue, 7 May 2019 08:26:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A608E28751 for ; Tue, 7 May 2019 08:26:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A7212892B; Tue, 7 May 2019 08:26:49 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3821B28751 for ; Tue, 7 May 2019 08:26:49 +0000 (UTC) Received: from localhost ([127.0.0.1]:42149 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNvR2-00078h-Eg for patchwork-qemu-devel@patchwork.kernel.org; Tue, 07 May 2019 04:26:48 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58078) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hNvKS-0000id-AS for qemu-devel@nongnu.org; Tue, 07 May 2019 04:20:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hNvKR-0008EL-CI for qemu-devel@nongnu.org; Tue, 07 May 2019 04:20:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43264) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hNvKN-0008BS-UE; Tue, 07 May 2019 04:19:56 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 31900C007344; Tue, 7 May 2019 08:19:55 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-45.ams2.redhat.com [10.36.116.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0B945B097; Tue, 7 May 2019 08:19:50 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id A145AA1E4; Tue, 7 May 2019 10:19:46 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 7 May 2019 10:19:43 +0200 Message-Id: <20190507081946.19264-6-kraxel@redhat.com> In-Reply-To: <20190507081946.19264-1-kraxel@redhat.com> References: <20190507081946.19264-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 07 May 2019 08:19:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/8] vl: add -vga help support 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: Peter Maydell , Alistair Francis , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Gerd Hoffmann , "Edgar E. Iglesias" , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Marc-André Lureau Provide help output similar to other argument help handling: $ qemu-system-x86_64 -vga help none std standard VGA (default) cirrus Cirrus VGA vmware VMWare SVGA xenfb qxl QXL VGA virtio Virtio VG Signed-off-by: Marc-André Lureau Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Message-id: 20190412152713.16018-3-marcandre.lureau@redhat.com Signed-off-by: Gerd Hoffmann --- vl.c | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/vl.c b/vl.c index 6b2820483c43..b6709514c1bb 100644 --- a/vl.c +++ b/vl.c @@ -2069,11 +2069,39 @@ static bool vga_interface_available(VGAInterfaceType t) object_class_by_name(ti->class_names[1]); } -static void select_vgahw(const char *p) +static const char * +get_default_vga_model(const MachineClass *machine_class) +{ + if (machine_class->default_display) { + return machine_class->default_display; + } else if (vga_interface_available(VGA_CIRRUS)) { + return "cirrus"; + } else if (vga_interface_available(VGA_STD)) { + return "std"; + } + + return NULL; +} + +static void select_vgahw(const MachineClass *machine_class, const char *p) { const char *opts; int t; + if (g_str_equal(p, "help")) { + const char *def = get_default_vga_model(machine_class); + + for (t = 0; t < VGA_TYPE_MAX; t++) { + const VGAInterfaceInfo *ti = &vga_interfaces[t]; + + if (vga_interface_available(t) && ti->opt_name) { + printf("%-20s %s%s\n", ti->opt_name, ti->name ?: "", + g_str_equal(ti->opt_name, def) ? " (default)" : ""); + } + } + exit(0); + } + assert(vga_interface_type == VGA_NONE); for (t = 0; t < VGA_TYPE_MAX; t++) { const VGAInterfaceInfo *ti = &vga_interfaces[t]; @@ -4424,16 +4452,10 @@ int main(int argc, char **argv, char **envp) /* If no default VGA is requested, the default is "none". */ if (default_vga) { - if (machine_class->default_display) { - vga_model = machine_class->default_display; - } else if (vga_interface_available(VGA_CIRRUS)) { - vga_model = "cirrus"; - } else if (vga_interface_available(VGA_STD)) { - vga_model = "std"; - } + vga_model = get_default_vga_model(machine_class); } if (vga_model) { - select_vgahw(vga_model); + select_vgahw(machine_class, vga_model); } if (watchdog) {