vl: graphics stubs + #ifdef cleanup
v2 cover vl: graphics stubs + #ifdef cleanup
Clean up the graphics initialization code to reduce the number of
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 (7):
vl: Add DT_COCOA DisplayType value
stubs: VNC initialization stubs
stubs: curses_display_init() stub
stubs: SDL initialization stubs
stubs: cocoa_display_init() stub
stubs: gtk_display_init() stub
spice: Initialization stubs on qemu-spice.h
include/sysemu/sysemu.h | 1 + include/ui/console.h | 4 ++-- include/ui/qemu-spice.h | 13 +++++++++++++ stubs/Makefile.objs | 1 + stubs/ui/Makefile.objs | 5 +++++ stubs/ui/cocoa.c | 10 ++++++++++ stubs/ui/curses.c | 10 ++++++++++ stubs/ui/gtk.c | 10 ++++++++++ stubs/ui/sdl.c | 17 +++++++++++++++++ stubs/ui/vnc.c | 22 ++++++++++++++++++++++ vl.c | 37 ++++++------------------------------- 11 files changed, 97 insertions(+), 33 deletions(-) create mode 100644 stubs/ui/Makefile.objs create mode 100644 stubs/ui/cocoa.c create mode 100644 stubs/ui/curses.c create mode 100644 stubs/ui/gtk.c create mode 100644 stubs/ui/sdl.c create mode 100644 stubs/ui/vnc.c
Signature · 1 line
2.1.0
PATCH v2 1/7 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
@@ -137,6 +137,7 @@ typedef enum DisplayTypeDT_DEFAULT ,DT_CURSES ,DT_SDL , +DT_COCOA ,DT_GTK ,DT_NOGRAPHIC , DT_NONE,
vl.c +4 -2
@@ -4247,8 +4247,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 ;
@@ -4588,7 +4590,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
Re: [Qemu-devel] [PATCH v2 1/7] vl: Add DT_COCOA DisplayType value
Am 12.11.2015 um 20:02 schrieb Eduardo Habkost:
Quoted 48 lines
Instead of reusing
DT_SDLfor Cocoa, useDT_COCOAto indicate that a Cocoa display was requested.configure already ensures
CONFIG_COCOAandCONFIG_SDLare never set at the same time. The only case whereDT_SDLis used outside a #ifdefCONFIG_SDLblock 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.Cc Andreas Färber <[email protected]>Cc Peter Maydell <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>--- include/sysemu/sysemu.h | 1 + vl.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-)include/sysemu/sysemu.h +1
-0@@ -137,6 +137,7 @@ typedef enum DisplayTypeDT_DEFAULT ,DT_CURSES ,DT_SDL , +DT_COCOA ,DT_GTK ,DT_NOGRAPHIC , DT_NONE,vl.c +3
-1@@ -4247,8 +4247,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 ;
vl.c int main(int argc, char **argv, char **envp) · line 4596
Quoted 8 lines
vl.c +1
-1@@ -4588,7 +4590,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
Sounds like a good idea, but haven't reviewed those extra DT_SDL uses,
Regards,
Andreas
PATCH v2 2/7 stubs: 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/
--- include/ui/console.h | 4 ++-- stubs/Makefile.objs | 1 + stubs/ui/Makefile.objs | 1 + stubs/ui/vnc.c | 22 ++++++++++++++++++++++ vl.c | 15 +-------------- 5 files changed, 27 insertions(+), 16 deletions(-) create mode 100644 stubs/ui/Makefile.objs create mode 100644 stubs/ui/vnc.c
include/ui/console.h +2 -2
@@ -413,11 +413,11 @@ 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); +QemuOpts *vnc_parse (const char *str,Error **errp); +int vnc_init_func (void *opaque,QemuOpts *opts,Error **errp);#ifdef CONFIG_VNC int vnc_display_password (const char *id,const char *password);int vnc_display_pw_expire (const char *id,time_t expires); -QemuOpts *vnc_parse (const char *str,Error **errp); -int vnc_init_func (void *opaque,QemuOpts *opts,Error **errp);#else static inline int vnc_display_password (const char *id,const char *password) {
stubs/Makefile.objs +1 -0
@@ -38,3 +38,4 @@ stub-obj-y += qmp_pc_dimm_device_list.o stub-obj-y += target-monitor-defs.o stub-obj-y += target-get-monitor-def.o stub-obj-y += vhost.o +stub-obj-y += ui/
stubs/ui/Makefile.objs new file +1 -0
@@ -0,0 +1 @@ +stub-obj-y += vnc.o
stubs/ui/vnc.c new file +22 -0
@@ -0,0 +1,22 @@ +#include "qemu-common.h" +#include "ui/console.h" +#include "qemu/error-report.h" + +QemuOpts *vnc_parse (const char *str,Error **errp) +{ +error_setg (errp,"VNC support is disabled" ); +return NULL ; +} + +int vnc_init_func (void *opaque,QemuOpts *opts,Error **errp) +{ +error_setg (errp,"VNC support is disabled" ); +return -1 ; +} + +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 (); +}
vl.c +1 -14
@@ -2145,7 +2145,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 ) {
@@ -2156,10 +2155,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 ;
@@ -2984,9 +2979,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 ;
@@ -3726,17 +3719,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:
@@ -4606,7 +4594,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 );
@@ -4615,7 +4602,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 v2 3/7 stubs: curses_display_init() stub
In reply to Eduardo HabkostOne less #ifdef in vl.c.
---
Changes v1 -> v2:
* Move stub file to stubs/ui/
--- stubs/ui/Makefile.objs | 1 + stubs/ui/curses.c | 10 ++++++++++ vl.c | 2 -- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 stubs/ui/curses.c
stubs/ui/Makefile.objs +1 -0
@@ -1 +1,2 @@ stub-obj-y += vnc.o +stub-obj-y += curses.o
stubs/ui/curses.c new file +10 -0
@@ -0,0 +1,10 @@ +#include "qemu-common.h" +#include "ui/console.h" +#include "qemu/error-report.h" + +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 (); +}
vl.c +0 -2
@@ -4568,11 +4568,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 v2 4/7 stubs: 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/
--- stubs/ui/Makefile.objs | 1 + stubs/ui/sdl.c | 17 +++++++++++++++++ vl.c | 6 ++---- 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 stubs/ui/sdl.c
stubs/ui/Makefile.objs +1 -0
@@ -1,2 +1,3 @@ stub-obj-y += vnc.o stub-obj-y += curses.o +stub-obj-y += sdl.o
stubs/ui/sdl.c new file +17 -0
@@ -0,0 +1,17 @@ +#include "qemu-common.h" +#include "ui/console.h" +#include "qemu/error-report.h" + +void sdl_display_early_init (int opengl) +{ +/* This must never be called if CONFIG_SDL is disabled */ +error_report ("SDL support is disabled" ); +abort (); +} + +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 (); +}
vl.c +2 -4
@@ -4261,11 +4261,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" );
@@ -4571,11 +4570,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 v2 5/7 stubs: cocoa_display_init() stub
In reply to Eduardo HabkostOne less #ifdef in vl.c.
---
Changes v1 -> v2:
* Move stub file to stubs/ui/
--- stubs/ui/Makefile.objs | 1 + stubs/ui/cocoa.c | 10 ++++++++++ vl.c | 2 -- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 stubs/ui/cocoa.c
stubs/ui/Makefile.objs +1 -0
@@ -1,3 +1,4 @@ stub-obj-y += vnc.o stub-obj-y += curses.o stub-obj-y += sdl.o +stub-obj-y += cocoa.o
stubs/ui/cocoa.c new file +10 -0
@@ -0,0 +1,10 @@ +#include "qemu-common.h" +#include "ui/console.h" +#include "qemu/error-report.h" + +void cocoa_display_init (DisplayState *ds,int full_screen) +{ +/* This must never be called if CONFIG_COCA is disabled */ +error_report ("Cocoa support is disabled" ); +abort (); +}
vl.c +0 -2
@@ -4573,11 +4573,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
Re: [Qemu-devel] [PATCH v2 5/7] stubs: cocoa_display_init() stub
Quoted 28 lines · Eduardo Habkost
One less #ifdef in
vl.c.Signed-off-by Eduardo Habkost <[email protected]>---
Changes v1 -> v2:
* Move stub file to stubs/ui/--- stubs/ui/Makefile.objs | 1 + stubs/ui/cocoa.c | 10 ++++++++++ vl.c | 2 -- 3 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 stubs/ui/cocoa.cstubs/ui/Makefile.objs +1
-0@@ -1,3 +1,4 @@ stub-obj-y += vnc.o stub-obj-y += curses.o stub-obj-y += sdl.o +stub-obj-y += cocoa.ostubs/ui/cocoa.c new file +0
-0
stubs/ui/cocoa.c line 7
Quoted 7 lines
stubs/ui/cocoa.c new file +7
-0@@ -0,0 +1,10 @@ +#include "qemu-common.h" +#include "ui/console.h" +#include "qemu/error-report.h" + +void cocoa_display_init (DisplayState *ds,int full_screen) +{ +/* This must never be called if CONFIG_COCA is disabled */
"CONFIG_COCOA".
thanks
-- PMM
Re: [Qemu-devel] [PATCH v2 5/7] stubs: cocoa_display_init() stub
Quoted 1 line · Peter Maydell
On 12 November 2015 at 19:02, Eduardo Habkost <[email protected]> wrote:
[...]
Quoted 5 lines
stubs/ui/cocoa.c line 7
Quoted 3 lines
stubs/ui/cocoa.c new file +3
-0+void cocoa_display_init (DisplayState *ds,int full_screen) +{ +/* This must never be called if CONFIG_COCA is disabled */ "
CONFIG_COCOA".
Will be fixed in next version. Thanks!
Signature · 1 line
Eduardo
PATCH v2 6/7 stubs: gtk_display_init() stub
In reply to Eduardo HabkostThis reduces the number of CONFIG_GTK #ifdefs in vl.c.
---
Changes v1 -> v2:
* Move stub file to stubs/ui/
--- stubs/ui/Makefile.objs | 1 + stubs/ui/gtk.c | 10 ++++++++++ vl.c | 4 ---- 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 stubs/ui/gtk.c
stubs/ui/Makefile.objs +1 -0
@@ -2,3 +2,4 @@ stub-obj-y += vnc.o stub-obj-y += curses.o stub-obj-y += sdl.o stub-obj-y += cocoa.o +stub-obj-y += gtk.o
stubs/ui/gtk.c new file +10 -0
@@ -0,0 +1,10 @@ +#include "qemu-common.h" +#include "ui/console.h" +#include "qemu/error-report.h" + +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 (); +}
vl.c +0 -4
@@ -151,9 +151,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 ];
@@ -4576,11 +4574,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 v2 7/7 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
@@ -52,6 +52,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,
@@ -76,6 +78,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
@@ -4386,10 +4386,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) {
@@ -4593,11 +4591,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
Re: [Qemu-devel] [PATCH v2 7/7] spice: Initialization stubs on qemu-spice.h
Quoted 8 lines · Eduardo Habkost
This reduces the number of
CONFIG_SPICE#ifdefs invl.c.Cc Gerd Hoffmann <[email protected]>Signed-off-by Eduardo Habkost <[email protected]>---
Changes v1 -> v2:
* Move stubs toqemu-spice.h, as the header file already had a separate section for !CONFIG_SPICE
cheers,
Gerd
Quoted 2 lines · Eduardo Habkost
Clean up the graphics initialization code to reduce the number of
Lame of git for eating lines that start with #ifdef. But at least it doesn't matter on the cover letter :)
Quoted 35 lines
Changes 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 (7):
vl: AddDT_COCOADisplayType value
stubs: VNC initialization stubs
stubs:curses_display_init()stub
stubs: SDL initialization stubs
stubs:cocoa_display_init()stub
stubs:gtk_display_init()stub
spice: Initialization stubs onqemu-spice.hinclude/sysemu/sysemu.h | 1 + include/ui/console.h | 4 ++-- include/ui/qemu-spice.h | 13 +++++++++++++ stubs/Makefile.objs | 1 + stubs/ui/Makefile.objs | 5 +++++ stubs/ui/cocoa.c | 10 ++++++++++ stubs/ui/curses.c | 10 ++++++++++ stubs/ui/gtk.c | 10 ++++++++++ stubs/ui/sdl.c | 17 +++++++++++++++++ stubs/ui/vnc.c | 22 ++++++++++++++++++++++ vl.c | 37 ++++++------------------------------- 11 files changed, 97 insertions(+), 33 deletions(-) create mode 100644 stubs/ui/Makefile.objs create mode 100644 stubs/ui/cocoa.c create mode 100644 stubs/ui/curses.c create mode 100644 stubs/ui/gtk.c create mode 100644 stubs/ui/sdl.c create mode 100644 stubs/ui/vnc.c
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 6 lines · Eric Blake
Quoted 2 lines · Eduardo Habkost
Clean up the graphics initialization code to reduce the number of
Lame of git for eating lines that start with #ifdef. But at least it doesn't matter on the cover letter :)
Maybe it's a git-publish bug, I will check. Thanks for noting! :)
Signature · 1 line
Eduardo
Quoted 9 lines · Eduardo Habkost
Quoted 6 lines · Eric Blake
Quoted 2 lines · Eduardo Habkost
Clean up the graphics initialization code to reduce the number of
Lame of git for eating lines that start with #ifdef. But at least it doesn't matter on the cover letter :)
Maybe it's a git-publish bug, I will check. Thanks for noting! :)
I've confirmed it's a "git tag -F" bug/feature, it's not git-publish's fault.
Signature · 1 line
Eduardo