From patchwork Fri May 20 20:28:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 9130199 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 2A48960221 for ; Fri, 20 May 2016 23:27:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C57927CF9 for ; Fri, 20 May 2016 23:27:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1130227E72; Fri, 20 May 2016 23:27:01 +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 CB8FC27CF9 for ; Fri, 20 May 2016 23:26:59 +0000 (UTC) Received: from localhost ([::1]:37972 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3too-0005IZ-L1 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 20 May 2016 19:26:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47014) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3t8Q-0003fN-Hq for qemu-devel@nongnu.org; Fri, 20 May 2016 18:43:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b3r2s-0001Ag-4W for qemu-devel@nongnu.org; Fri, 20 May 2016 16:29:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52543) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b3r2r-0001Aa-SB for qemu-devel@nongnu.org; Fri, 20 May 2016 16:29:18 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 49D417F0B1; Fri, 20 May 2016 20:29:17 +0000 (UTC) Received: from localhost (vpn1-7-50.gru2.redhat.com [10.97.7.50]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4KKTF0D024991; Fri, 20 May 2016 16:29:16 -0400 From: Eduardo Habkost To: Peter Maydell Date: Fri, 20 May 2016 17:28:33 -0300 Message-Id: <1463776121-13529-14-git-send-email-ehabkost@redhat.com> In-Reply-To: <1463776121-13529-1-git-send-email-ehabkost@redhat.com> References: <1463776121-13529-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 20 May 2016 20:29:17 +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 13/21] vl: Replace DT_NOGRAPHIC with machine option 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: "Michael S. Tsirkin" , Mark Cave-Ayland , qemu-devel@nongnu.org, Blue Swirl , Michael Walle , Marcel Apfelbaum , Paolo Bonzini Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP All DisplayType values are just UI options that don't affect any hardware emulation code, except for DT_NOGRAPHIC. Replace DT_NOGRAPHIC with DT_NONE plus a new "-machine graphics=on|off" option, so hardware emulation code don't need to use the display_type variable. Cc: Michael Walle Cc: Blue Swirl Cc: Mark Cave-Ayland Signed-off-by: Eduardo Habkost --- hw/core/machine.c | 21 +++++++++++++++++++++ hw/lm32/milkymist.c | 2 +- hw/nvram/fw_cfg.c | 6 ++++-- hw/sparc/sun4m.c | 2 +- include/hw/boards.h | 1 + include/sysemu/sysemu.h | 1 - vl.c | 13 +++++++------ 7 files changed, 35 insertions(+), 11 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 6dbbc85..0bb96ad 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -257,6 +257,20 @@ static void machine_set_usb(Object *obj, bool value, Error **errp) ms->usb_disabled = !value; } +static bool machine_get_graphics(Object *obj, Error **errp) +{ + MachineState *ms = MACHINE(obj); + + return ms->enable_graphics; +} + +static void machine_set_graphics(Object *obj, bool value, Error **errp) +{ + MachineState *ms = MACHINE(obj); + + ms->enable_graphics = value; +} + static bool machine_get_igd_gfx_passthru(Object *obj, Error **errp) { MachineState *ms = MACHINE(obj); @@ -382,6 +396,7 @@ static void machine_initfn(Object *obj) ms->kvm_shadow_mem = -1; ms->dump_guest_core = true; ms->mem_merge = true; + ms->enable_graphics = true; object_property_add_str(obj, "accel", machine_get_accel, machine_set_accel, NULL); @@ -460,6 +475,12 @@ static void machine_initfn(Object *obj) object_property_set_description(obj, "usb", "Set on/off to enable/disable usb", NULL); + object_property_add_bool(obj, "graphics", + machine_get_graphics, + machine_set_graphics, NULL); + object_property_set_description(obj, "graphics", + "Set on/off to enable/disable graphics emulation", + NULL); object_property_add_bool(obj, "igd-passthru", machine_get_igd_gfx_passthru, machine_set_igd_gfx_passthru, NULL); diff --git a/hw/lm32/milkymist.c b/hw/lm32/milkymist.c index 694dac3..1abdf6e 100644 --- a/hw/lm32/milkymist.c +++ b/hw/lm32/milkymist.c @@ -167,7 +167,7 @@ milkymist_init(MachineState *machine) milkymist_memcard_create(0x60004000); milkymist_ac97_create(0x60005000, irq[4], irq[5], irq[6], irq[7]); milkymist_pfpu_create(0x60006000, irq[8]); - if (display_type != DT_NOGRAPHIC) { + if (machine->enable_graphics) { milkymist_tmu2_create(0x60007000, irq[9]); } milkymist_minimac2_create(0x60008000, 0x30000000, irq[10], irq[11]); diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 999f480..cdbdfb5 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -25,6 +25,7 @@ #include "hw/hw.h" #include "sysemu/sysemu.h" #include "sysemu/dma.h" +#include "hw/boards.h" #include "hw/isa/isa.h" #include "hw/nvram/fw_cfg.h" #include "hw/sysbus.h" @@ -868,16 +869,17 @@ static void fw_cfg_machine_ready(struct Notifier *n, void *data) static void fw_cfg_init1(DeviceState *dev) { FWCfgState *s = FW_CFG(dev); + MachineState *machine = MACHINE(qdev_get_machine()); assert(!object_resolve_path(FW_CFG_PATH, NULL)); - object_property_add_child(qdev_get_machine(), FW_CFG_NAME, OBJECT(s), NULL); + object_property_add_child(OBJECT(machine), FW_CFG_NAME, OBJECT(s), NULL); qdev_init_nofail(dev); fw_cfg_add_bytes(s, FW_CFG_SIGNATURE, (char *)"QEMU", 4); fw_cfg_add_bytes(s, FW_CFG_UUID, qemu_uuid, 16); - fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)(display_type == DT_NOGRAPHIC)); + fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)!machine->enable_graphics); fw_cfg_add_i16(s, FW_CFG_NB_CPUS, (uint16_t)smp_cpus); fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)boot_menu); fw_cfg_bootsplash(s); diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index 7bfc00a..478fda8 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -1000,7 +1000,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef, slavio_timer_init_all(hwdef->counter_base, slavio_irq[19], slavio_cpu_irq, smp_cpus); slavio_serial_ms_kbd_init(hwdef->ms_kb_base, slavio_irq[14], - display_type == DT_NOGRAPHIC, ESCC_CLOCK, 1); + !machine->enable_graphics, ESCC_CLOCK, 1); /* Slavio TTYA (base+4, Linux ttyS0) is the first QEMU serial device Slavio TTYB (base+0, Linux ttyS1) is the second QEMU serial device */ escc_init(hwdef->serial_base, slavio_irq[15], slavio_irq[15], diff --git a/include/hw/boards.h b/include/hw/boards.h index 8d4fe56..f968a25 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -154,6 +154,7 @@ struct MachineState { bool iommu; bool suppress_vmdesc; bool enforce_config_section; + bool enable_graphics; ram_addr_t ram_size; ram_addr_t maxram_size; diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 90766da..6076b80 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -138,7 +138,6 @@ typedef enum DisplayType DT_SDL, DT_COCOA, DT_GTK, - DT_NOGRAPHIC, DT_NONE, } DisplayType; diff --git a/vl.c b/vl.c index 8576556..35ed954 100644 --- a/vl.c +++ b/vl.c @@ -2962,6 +2962,7 @@ int main(int argc, char **argv, char **envp) int show_vnc_port = 0; bool defconfig = true; bool userconfig = true; + bool nographic = false; const char *log_mask = NULL; const char *log_file = NULL; char *trace_file = NULL; @@ -3206,7 +3207,10 @@ int main(int argc, char **argv, char **envp) display_type = select_display(optarg); break; case QEMU_OPTION_nographic: - display_type = DT_NOGRAPHIC; + olist = qemu_find_opts("machine"); + qemu_opts_parse_noisily(olist, "graphics=off", false); + nographic = true; + display_type = DT_NONE; break; case QEMU_OPTION_curses: #ifdef CONFIG_CURSES @@ -4167,7 +4171,7 @@ int main(int argc, char **argv, char **envp) * -nographic _and_ redirects all ports explicitly - this is valid * usage, -nographic is just a no-op in this case. */ - if (display_type == DT_NOGRAPHIC + if (nographic && (default_parallel || default_serial || default_monitor || default_virtcon)) { error_report("-nographic cannot be used with -daemonize"); @@ -4181,7 +4185,7 @@ int main(int argc, char **argv, char **envp) #endif } - if (display_type == DT_NOGRAPHIC) { + if (nographic) { if (default_parallel) add_device_config(DEV_PARALLEL, "null"); if (default_serial && default_monitor) { @@ -4531,9 +4535,6 @@ int main(int argc, char **argv, char **envp) /* init local displays */ switch (display_type) { - case DT_NOGRAPHIC: - (void)ds; /* avoid warning if no display is configured */ - break; case DT_CURSES: curses_display_init(ds, full_screen); break;