vl: graphics stubs + #ifdef cleanup + DT_NOGRAPHIC cleanup
v3 cover vl: graphics stubs + #ifdef cleanup + DT_NOGRAPHIC cleanup
* Clean up the graphics initialization code to reduce the number of #ifdefs;
* Remove the display_type == DT_NOGRAPHIC checks from hardware emulation code;
* Make the display_type global variable a local variable on main();
* Make the display_remote static variable a local variable on main().
Changes v2 -> v3:
* Include the DT_NOGRAPHIC patches again in the series, so all of them can be reviewed
* Move the stub code to inline functions at console.h. This was done to simplify the series, as build dependencies get tricky when trying to build libqemustub.a with --disable-user --disable-system (it disables pixman build flags, and console.h won't build because qemu-pixman.h requires pixman headers)
* Now the series is based on my 'machine-next' branch, available at:
https://github.com/ehabkost/qemu.git machine-next
Changes v1 -> v2:
* Patches 2-6: Move stub files to stubs/ui/
* Patch 7: Move stubs to qemu-spice.h, as the header file already had a separate section for !CONFIG_SPICE
* Removed DT_NOGRAPHIC patches from the series (they will be sent as a separate series)
Eduardo Habkost (12):
vl: Add DT_COCOA DisplayType value
vnc: Initialization stubs
curses: curses_display_init() stub
sdl: Initialization stubs
cocoa: cocoa_display_init() stub
gtk: Initialization stubs
spice: Initialization stubs on qemu-spice.h
milkymist: Move DT_NOGRAPHIC check outside milkymist_tmu2_create()
vl: Replace DT_NOGRAPHIC with machine option
vl: Make display_type a local variable
vl: Move DisplayType typedef to vl.c
vl: Make display_remote a local variable
hw/core/machine.c | 21 +++++++++++++++ hw/lm32/milkymist-hw.h | 4 --- hw/lm32/milkymist.c | 4 ++- hw/nvram/fw_cfg.c | 6 +++-- hw/sparc/sun4m.c | 2 +- include/hw/boards.h | 1 + include/sysemu/sysemu.h | 11 -------- include/ui/console.h | 71 ++++++++++++++++++++++++++++++++++++++++++++++++- include/ui/qemu-spice.h | 13 +++++++++ vl.c | 66 +++++++++++++++++---------------------------- 10 files changed, 138 insertions(+), 61 deletions(-)
Signature · 1 line
2.1.0
PATCH v3 1/12 vl: Add DT_COCOA DisplayType value
Instead of reusing DT_SDL for Cocoa, use DT_COCOA to indicate that a Cocoa display was requested.
configure already ensures CONFIG_COCOA and CONFIG_SDL are never set at the same time. The only case where DT_SDL is used outside a #ifdef CONFIG_SDL block is in the no_frame/alt_grab/ctrl_grab check. That means the only user-visible change is that we will start printing a warning if the SDL-specific options are used in Cocoa mode. This is a bugfix, because no_frame/alt_grab/ctrl_grab are not used by Cocoa code.
--- include/sysemu/sysemu.h | 1 + vl.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-)
include/sysemu/sysemu.h +1 -0
@@ -136,6 +136,7 @@ typedef enum DisplayTypeDT_DEFAULT ,DT_CURSES ,DT_SDL , +DT_COCOA ,DT_GTK ,DT_NOGRAPHIC , DT_NONE,
vl.c +4 -2
@@ -4235,8 +4235,10 @@ int main(int argc, char **argv, char **envp)if (display_type ==DT_DEFAULT && !display_remote) {#if defined(CONFIG_GTK ) display_type =DT_GTK ; -#elif defined(CONFIG_SDL ) || defined(CONFIG_COCOA ) +#elif defined(CONFIG_SDL ) display_type =DT_SDL ; +#elif defined(CONFIG_COCOA ) + display_type =DT_COCOA ;#elif defined(CONFIG_VNC )vnc_parse ("localhost:0,to=99,id=default" , &error_abort); show_vnc_port =1 ;
@@ -4560,7 +4562,7 @@ int main(int argc, char **argv, char **envp)sdl_display_init (ds, full_screen, no_frame);break ;#elif defined(CONFIG_COCOA ) -case DT_SDL : +case DT_COCOA :cocoa_display_init (ds, full_screen);break ;#endif
Signature · 1 line
2.1.0
PATCH v3 2/12 vnc: Initialization stubs
In reply to Eduardo HabkostThis reduces the number of CONFIG_VNC #ifdefs in the vl.c code.
The only user-visible difference is that this will make QEMU complain about syntax when using "-display vnc" ("VNC requires a display argument vnc=<display>") even if CONFIG_VNC is disabled.
---
Changes v1 -> v2:
* Move stub file to stubs/ui/
Changes v2 -> v3:
* Move stubs to header file
--- include/ui/console.h | 20 +++++++++++++++++++- vl.c | 15 +-------------- 2 files changed, 20 insertions(+), 15 deletions(-)
include/ui/console.h +19 -1
@@ -6,6 +6,8 @@#include "qapi/qmp/qdict.h" #include "qemu/notify.h" #include "qapi-types.h" +#include "qemu/error-report.h" +#include "qapi/error.h" #ifdef CONFIG_OPENGL # include <epoxy/gl.h>
@@ -430,10 +432,10 @@ void cocoa_display_init(DisplayState *ds, int full_screen);void vnc_display_init (const char *id);void vnc_display_open (const char *id,Error **errp);void vnc_display_add_client (const char *id,int csock,bool skipauth); -char *vnc_display_local_addr (const char *id);#ifdef CONFIG_VNC int vnc_display_password (const char *id,const char *password);int vnc_display_pw_expire (const char *id,time_t expires); +char *vnc_display_local_addr (const char *id);QemuOpts *vnc_parse (const char *str,Error **errp);int vnc_init_func (void *opaque,QemuOpts *opts,Error **errp);#else
@@ -445,6 +447,22 @@ static inline int vnc_display_pw_expire(const char *id, time_t expires) {return -ENODEV ; }; +static inline QemuOpts *vnc_parse (const char *str,Error **errp) +{ +error_setg (errp,"VNC support is disabled" ); +return NULL ; +} +static inline int vnc_init_func (void *opaque,QemuOpts *opts,Error **errp) +{ +error_setg (errp,"VNC support is disabled" ); +return -1 ; +} +static inline char *vnc_display_local_addr (const char *id) +{ +/* This must never be called if CONFIG_VNC is disabled */ +error_report ("VNC support is disabled" ); +abort (); +}#endif /* curses.c */
vl.c +1 -14
@@ -2146,7 +2146,6 @@ static DisplayType select_display(const char *p)exit (1 );#endif }else if (strstart (p,"vnc" , &opts)) { -#ifdef CONFIG_VNC if (*opts =='=' ) {Error *err =NULL ;if (vnc_parse (opts +1 , &err) ==NULL ) {
@@ -2157,10 +2156,6 @@ static DisplayType select_display(const char *p)error_report ("VNC requires a display argument vnc=<display>" );exit (1 ); } -#else -error_report ("VNC support is disabled" ); -exit (1 ); -#endif }else if (strstart (p,"curses" , &opts)) {#ifdef CONFIG_CURSES display =DT_CURSES ;
@@ -2964,9 +2959,7 @@ int main(int argc, char **argv, char **envp)const char *qtest_log =NULL ;const char *pid_file =NULL ;const char *incoming =NULL ; -#ifdef CONFIG_VNC int show_vnc_port =0 ; -#endif bool defconfig = true;bool userconfig = true;const char *log_mask =NULL ;
@@ -3713,17 +3706,12 @@ int main(int argc, char **argv, char **envp)break ;case QEMU_OPTION_vnc: { -#ifdef CONFIG_VNC Error *local_err =NULL ;if (vnc_parse (optarg, &local_err) ==NULL ) {error_report_err (local_err);exit (1 ); } -#else -error_report ("VNC support is disabled" ); -exit (1 ); -#endif break ; }case QEMU_OPTION_no_acpi:
@@ -4578,7 +4566,6 @@ int main(int argc, char **argv, char **envp)/* must be after terminal init, SDL library changes signal handlers */ os_setup_signal_handling (); -#ifdef CONFIG_VNC /* init remote displays */ qemu_opts_foreach (qemu_find_opts ("vnc" ), vnc_init_func,NULL ,NULL );
@@ -4587,7 +4574,7 @@ int main(int argc, char **argv, char **envp)printf ("VNC server running on '%s'\n" , ret);g_free (ret); } -#endif +#ifdef CONFIG_SPICE if (using_spice) {qemu_spice_display_init ();
Signature · 1 line
2.1.0
PATCH v3 3/12 curses: curses_display_init() stub
In reply to Eduardo HabkostOne less #ifdef in vl.c.
---
Changes v1 -> v2:
* Move stub file to stubs/ui/
Changes v2 -> v3:
* Move stub to header file
--- include/ui/console.h | 9 +++++++++ vl.c | 2 -- 2 files changed, 9 insertions(+), 2 deletions(-)
include/ui/console.h +9 -0
@@ -466,7 +466,16 @@ static inline char *vnc_display_local_addr(const char *id)#endif /* curses.c */ +#ifdef CONFIG_CURSES void curses_display_init (DisplayState *ds,int full_screen); +#else +static inline void curses_display_init (DisplayState *ds,int full_screen) +{ +/* This must never be called if CONFIG_CURSES is disabled */ +error_report ("curses support is disabled" ); +abort (); +} +#endif /* input.c */ int index_from_key (const char *key,size_t key_length);
vl.c +0 -2
@@ -4540,11 +4540,9 @@ int main(int argc, char **argv, char **envp)case DT_NOGRAPHIC : (void )ds;/* avoid warning if no display is configured */ break ; -#if defined(CONFIG_CURSES )case DT_CURSES :curses_display_init (ds, full_screen);break ; -#endif #if defined(CONFIG_SDL )case DT_SDL :sdl_display_init (ds, full_screen, no_frame);
Signature · 1 line
2.1.0
PATCH v3 4/12 sdl: Initialization stubs
In reply to Eduardo HabkostThis reduces the number of CONFIG_SDL #ifdefs in vl.c.
---
Changes v1 -> v2:
* Move stub file to stubs/ui/
Changes v2 -> v3:
* Move stubs to header file
--- include/ui/console.h | 16 ++++++++++++++++ vl.c | 6 ++---- 2 files changed, 18 insertions(+), 4 deletions(-)
include/ui/console.h +16 -0
@@ -422,8 +422,24 @@ void surface_gl_setup_viewport(ConsoleGLState *gls,#endif /* sdl.c */ +#ifdef CONFIG_SDL void sdl_display_early_init (int opengl);void sdl_display_init (DisplayState *ds,int full_screen,int no_frame); +#else +static inline void sdl_display_early_init (int opengl) +{ +/* This must never be called if CONFIG_SDL is disabled */ +error_report ("SDL support is disabled" ); +abort (); +} +static inline void sdl_display_init (DisplayState *ds,int full_screen, +int no_frame) +{ +/* This must never be called if CONFIG_SDL is disabled */ +error_report ("SDL support is disabled" ); +abort (); +} +#endif /* cocoa.m */ void cocoa_display_init (DisplayState *ds,int full_screen);
vl.c +2 -4
@@ -4249,11 +4249,10 @@ int main(int argc, char **argv, char **envp) early_gtk_display_init(request_opengl); }#endif -#if defined(CONFIG_SDL )if (display_type ==DT_SDL ) {sdl_display_early_init (request_opengl); } -#endif +if (request_opengl ==1 && display_opengl ==0 ) {#if defined(CONFIG_OPENGL )error_report ("OpenGL is not supported by the display" );
@@ -4543,11 +4542,10 @@ int main(int argc, char **argv, char **envp)case DT_CURSES :curses_display_init (ds, full_screen);break ; -#if defined(CONFIG_SDL )case DT_SDL :sdl_display_init (ds, full_screen, no_frame);break ; -#elif defined(CONFIG_COCOA ) +#if defined(CONFIG_COCOA )case DT_COCOA :cocoa_display_init (ds, full_screen);break ;
Signature · 1 line
2.1.0
PATCH v3 5/12 cocoa: cocoa_display_init() stub
In reply to Eduardo HabkostOne less #ifdef in vl.c.
---
Changes v1 -> v2:
* Move stub file to stubs/ui/
Changes v2 -> v3:
* Fix typo (CONFIG_COCA) on comment
* Move stub to header file
--- include/ui/console.h | 9 +++++++++ vl.c | 2 -- 2 files changed, 9 insertions(+), 2 deletions(-)
include/ui/console.h +9 -0
@@ -442,7 +442,16 @@ static inline void sdl_display_init(DisplayState *ds, int full_screen,#endif /* cocoa.m */ +#ifdef CONFIG_COCOA void cocoa_display_init (DisplayState *ds,int full_screen); +#else +static inline void cocoa_display_init (DisplayState *ds,int full_screen) +{ +/* This must never be called if CONFIG_COCOA is disabled */ +error_report ("Cocoa support is disabled" ); +abort (); +} +#endif /* vnc.c */ void vnc_display_init (const char *id);
vl.c +0 -2
@@ -4545,11 +4545,9 @@ int main(int argc, char **argv, char **envp)case DT_SDL :sdl_display_init (ds, full_screen, no_frame);break ; -#if defined(CONFIG_COCOA )case DT_COCOA :cocoa_display_init (ds, full_screen);break ; -#endif #if defined(CONFIG_GTK )case DT_GTK :gtk_display_init (ds, full_screen, grab_on_hover);
Signature · 1 line
2.1.0
PATCH v3 6/12 gtk: Initialization stubs
In reply to Eduardo HabkostThis reduces the number of CONFIG_GTK #ifdefs in vl.c.
---
Changes v1 -> v2:
* Move stub file to stubs/ui/
Changes v2 -> v3:
* Add early_gtk_display_init() stub
* Move stubs to header file
--- include/ui/console.h | 17 +++++++++++++++++ vl.c | 7 +------ 2 files changed, 18 insertions(+), 6 deletions(-)
include/ui/console.h +17 -0
@@ -506,7 +506,24 @@ static inline void curses_display_init(DisplayState *ds, int full_screen)int index_from_key (const char *key,size_t key_length);/* gtk.c */ +#ifdef CONFIG_GTK void early_gtk_display_init (int opengl);void gtk_display_init (DisplayState *ds,bool full_screen,bool grab_on_hover); +#else +static inline void gtk_display_init (DisplayState *ds,bool full_screen, +bool grab_on_hover) +{ +/* This must never be called if CONFIG_GTK is disabled */ +error_report ("GTK support is disabled" ); +abort (); +} + +static inline void early_gtk_display_init (int opengl) +{ +/* This must never be called if CONFIG_GTK is disabled */ +error_report ("GTK support is disabled" ); +abort (); +} +#endif #endif
vl.c +1 -6
@@ -146,9 +146,7 @@ int vga_interface_type = VGA_NONE;static int full_screen =0 ;static int no_frame =0 ;int no_quit =0 ; -#ifdef CONFIG_GTK static bool grab_on_hover; -#endif CharDriverState *serial_hds[MAX_SERIAL_PORTS ];CharDriverState *parallel_hds[MAX_PARALLEL_PORTS ];CharDriverState *virtcon_hds[MAX_VIRTIO_CONSOLES ];
@@ -4244,11 +4242,10 @@ int main(int argc, char **argv, char **envp) "ignoring option"); } -#if defined(CONFIG_GTK )if (display_type ==DT_GTK ) {early_gtk_display_init (request_opengl); } -#endif +if (display_type ==DT_SDL ) {sdl_display_early_init (request_opengl); }
@@ -4548,11 +4545,9 @@ int main(int argc, char **argv, char **envp)case DT_COCOA :cocoa_display_init (ds, full_screen);break ; -#if defined(CONFIG_GTK )case DT_GTK :gtk_display_init (ds, full_screen, grab_on_hover);break ; -#endif default :break ; }
Signature · 1 line
2.1.0
PATCH v3 7/12 spice: Initialization stubs on qemu-spice.h
In reply to Eduardo HabkostThis reduces the number of CONFIG_SPICE #ifdefs in vl.c.
---
Changes v1 -> v2:
* Move stubs to qemu-spice.h, as the header file already had a separate section for !CONFIG_SPICE
--- include/ui/qemu-spice.h | 13 +++++++++++++ vl.c | 4 ---- 2 files changed, 13 insertions(+), 4 deletions(-)
include/ui/qemu-spice.h +13 -0
@@ -51,6 +51,8 @@ static inline CharDriverState *qemu_chr_open_spice_port(const char *name)#else /* CONFIG_SPICE */ +#include "qemu/error-report.h" +#define using_spice 0#define spice_displays 0 static inline int qemu_spice_set_passwd(const char *passwd,
@@ -75,6 +77,17 @@ static inline int qemu_spice_display_add_client(int csock, int skipauth, return -1; } +static inline void qemu_spice_display_init (void ) +{ +/* This must never be called if CONFIG_SPICE is disabled */ +error_report ("spice support is disabled" ); +abort (); +} + +static inline void qemu_spice_init (void ) +{ +} +#endif /* CONFIG_SPICE */ static inline bool qemu_using_spice (Error **errp)
vl.c +0 -4
@@ -4359,10 +4359,8 @@ int main(int argc, char **argv, char **envp)os_set_line_buffering (); -#ifdef CONFIG_SPICE /* spice needs the timers to be initialized by this point */ qemu_spice_init (); -#endif cpu_ticks_init ();if (icount_opts) {
@@ -4564,11 +4562,9 @@ int main(int argc, char **argv, char **envp)g_free (ret); } -#ifdef CONFIG_SPICE if (using_spice) {qemu_spice_display_init (); } -#endif if (foreach_device_config (DEV_GDB , gdbserver_start) <0 ) {exit (1 );
Signature · 1 line
2.1.0
PATCH v3 8/12 milkymist: Move DT_NOGRAPHIC check outside milkymist_tmu2_create()
In reply to Eduardo HabkostDT_NOGRAPHIC handling will be moved to a MachineState field, and it will be easier to change milkymist_init() to check that field.
--- hw/lm32/milkymist-hw.h | 4 ---- hw/lm32/milkymist.c | 4 +++- 2 files changed, 3 insertions(+), 5 deletions(-)
hw/lm32/milkymist-hw.h +0 -4
@@ -108,10 +108,6 @@ static inline DeviceState *milkymist_tmu2_create(hwaddr base,int nelements;int ver_major, ver_minor; -if (display_type ==DT_NOGRAPHIC ) { -return NULL ; - } -/* check that GLX will work */ d =XOpenDisplay (NULL );if (d ==NULL ) {
hw/lm32/milkymist.c +3 -1
@@ -167,7 +167,9 @@ 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 ]); -milkymist_tmu2_create (0x60007000 , irq[9 ]); +if (display_type !=DT_NOGRAPHIC ) { +milkymist_tmu2_create (0x60007000 , irq[9 ]); + }milkymist_minimac2_create (0x60008000 ,0x30000000 , irq[10 ], irq[11 ]);milkymist_softusb_create (0x6000f000 , irq[15 ],0x20000000 ,0x1000 ,0x20020000 ,0x2000 );
Signature · 1 line
2.1.0
PATCH v3 9/12 vl: Replace DT_NOGRAPHIC with machine option
In reply to Eduardo HabkostAll 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.
---
Changes v1 -> v2:
* (none, patch was removed in v2 of series)
Change v2 -> v3:
* Patch re-added in v3 of series
* Added "-machine graphics=on|off" option, rename field to "enable_graphics" instead of "nographic"
--- 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(-)
hw/core/machine.c +21 -0
@@ -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 );
hw/lm32/milkymist.c +1 -1
@@ -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 ]);
hw/nvram/fw_cfg.c +4 -2
@@ -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);
hw/sparc/sun4m.c +1 -1
@@ -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],
include/hw/boards.h +1 -0
@@ -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;
include/sysemu/sysemu.h +0 -1
@@ -138,7 +138,6 @@ typedef enum DisplayTypeDT_SDL ,DT_COCOA ,DT_GTK , -DT_NOGRAPHIC ,DT_NONE , } DisplayType;
vl.c +7 -6
@@ -2960,6 +2960,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 ;
@@ -3204,7 +3205,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
@@ -4165,7 +4169,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" );
@@ -4179,7 +4183,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 ;
Signature · 1 line
2.1.0
PATCH v3 10/12 vl: Make display_type a local variable
In reply to Eduardo HabkostNow display_type is only used inside main(), and don't need to be a global variable.
--- include/sysemu/sysemu.h | 1 - vl.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
include/sysemu/sysemu.h +0 -1
@@ -155,7 +155,6 @@ extern int vga_interface_type;extern int graphic_width;extern int graphic_height;extern int graphic_depth; -extern DisplayType display_type;extern int display_opengl;extern const char *keyboard_layout;extern int win2k_install_hack;
vl.c +1 -1
@@ -127,7 +127,6 @@ static const char *data_dir[16];static int data_dir_idx;const char *bios_name =NULL ;enum vga_retrace_method vga_retrace_method =VGA_RETRACE_DUMB ; -DisplayType display_type =DT_DEFAULT ;int request_opengl =-1 ;int display_opengl;static int display_remote;
@@ -2961,6 +2960,7 @@ int main(int argc, char **argv, char **envp)bool defconfig = true;bool userconfig = true;bool nographic = false; +DisplayType display_type =DT_DEFAULT ;const char *log_mask =NULL ;const char *log_file =NULL ;char *trace_file =NULL ;
Signature · 1 line
2.1.0
PATCH v3 11/12 vl: Move DisplayType typedef to vl.c
In reply to Eduardo HabkostNow the type is only used inside vl.c and doesn't need to be in a header file.
---
Change v1 -> v2:
* Coding style fix
(open brace '{' following enum go on the same line)
--- include/sysemu/sysemu.h | 10 ---------- vl.c | 9 +++++++++ 2 files changed, 9 insertions(+), 10 deletions(-)
include/sysemu/sysemu.h +0 -10
@@ -131,16 +131,6 @@ void qemu_savevm_send_postcopy_ram_discard(QEMUFile *f, const char *name,int qemu_loadvm_state (QEMUFile *f); -typedef enum DisplayType -{ -DT_DEFAULT , -DT_CURSES , -DT_SDL , -DT_COCOA , -DT_GTK , -DT_NONE , -}DisplayType ; -extern int autostart; typedef enum {
vl.c +9 -0
@@ -2075,6 +2075,15 @@ static void select_vgahw(const char *p) } } +typedef enum DisplayType { +DT_DEFAULT , +DT_CURSES , +DT_SDL , +DT_COCOA , +DT_GTK , +DT_NONE , +}DisplayType ; +static DisplayType select_display (const char *p) {const char *opts;
Signature · 1 line
2.1.0
PATCH v3 12/12 vl: Make display_remote a local variable
In reply to Eduardo HabkostThe variable is used only inside main(), so it can be local.
--- vl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
vl.c +1 -1
@@ -129,7 +129,6 @@ const char *bios_name = NULL;enum vga_retrace_method vga_retrace_method =VGA_RETRACE_DUMB ;int request_opengl =-1 ;int display_opengl; -static int display_remote;const char * keyboard_layout =NULL ;ram_addr_t ram_size;const char *mem_path =NULL ;
@@ -2970,6 +2969,7 @@ int main(int argc, char **argv, char **envp)bool userconfig = true;bool nographic = false;DisplayType display_type =DT_DEFAULT ; +int display_remote =0 ;const char *log_mask =NULL ;const char *log_file =NULL ;char *trace_file =NULL ;
Signature · 1 line
2.1.0
Quoted 42 lines · Eduardo Habkost
* Clean up the graphics initialization code to reduce the number of #ifdefs;
* Remove thedisplay_type==DT_NOGRAPHICchecks from hardware emulation code;
* Make thedisplay_typeglobal variable a local variable onmain();
* Make thedisplay_remotestatic variable a local variable onmain().Changes v2 -> v3:
* Include theDT_NOGRAPHICpatches again in the series, so all of them can be reviewed
* Move the stub code to inline functions atconsole.h. This was done to simplify the series, as build dependencies get tricky when trying to build libqemustub.a with --disable-user --disable-system (it disables pixman build flags, andconsole.hwon't build becauseqemu-pixman.hrequires pixman headers)
* Now the series is based on my 'machine-next' branch, available at:
https://github.com/ehabkost/qemu.git machine-nextChanges v1 -> v2:
* Patches 2-6: Move stub files to stubs/ui/
* Patch 7: Move stubs toqemu-spice.h, as the header file already had a separate section for !CONFIG_SPICE
* RemovedDT_NOGRAPHICpatches from the series (they will be sent as a separate series)Eduardo Habkost (12):
vl: AddDT_COCOADisplayType value
vnc: Initialization stubs
curses:curses_display_init()stub
sdl: Initialization stubs
cocoa:cocoa_display_init()stub
gtk: Initialization stubs
spice: Initialization stubs onqemu-spice.h
milkymist: MoveDT_NOGRAPHICcheck outsidemilkymist_tmu2_create()
vl: ReplaceDT_NOGRAPHICwith machine option
vl: Makedisplay_typea local variable
vl: Move DisplayType typedef tovl.c
vl: Makedisplay_remotea local variable
Quoted 11 lines
hw/core/machine.c | 21 +++++++++++++++ hw/lm32/milkymist-hw.h | 4 --- hw/lm32/milkymist.c | 4 ++- hw/nvram/fw_cfg.c | 6 +++-- hw/sparc/sun4m.c | 2 +- include/hw/boards.h | 1 + include/sysemu/sysemu.h | 11 -------- include/ui/console.h | 71 ++++++++++++++++++++++++++++++++++++++++++++++++- include/ui/qemu-spice.h | 13 +++++++++ vl.c | 66 +++++++++++++++++---------------------------- 10 files changed, 138 insertions(+), 61 deletions(-)
Very nice, I suppose you'll be sending the pull request?
Paolo
Quoted 10 lines · Paolo Bonzini
Quoted 9 lines · Eduardo Habkost
* Clean up the graphics initialization code to reduce the number of #ifdefs;
* Remove thedisplay_type==DT_NOGRAPHICchecks from hardware emulation code;
* Make thedisplay_typeglobal variable a local variable onmain();
* Make thedisplay_remotestatic variable a local variable onmain().
[...]
Quoted 2 lines
Very nice, I suppose you'll be sending the pull request?
Now that I got some feedback, I plan to apply it, yes. :)
Signature · 1 line
Eduardo