ui: use qapi-based parser for most -display options.
v2 cover ui: use qapi-based parser for most -display options.
v2: rebase, adapt to gl= option changes.
Gerd Hoffmann (4):
ui: add qapi parser for -display
ui: switch trivial displays to qapi parser
ui: switch gtk display to qapi parser
ui: document non-qapi parser cases.
ui/gtk.c | 6 ++++- vl.c | 76 ++++++++++++++++++++++++++++++---------------------------------- 2 files changed, 41 insertions(+), 41 deletions(-)
Signature · 1 line
2.9.3
PATCH v2 1/4 ui: add qapi parser for -display
Add parse_display_qapi() function which parses the -display command line using a qapi visitor for DisplayOptions. Wire up as default catch in parse_display().
Improves the error message for unknown display types.
Also enables json as -display argument, i.e. -display "{ 'type': 'gtk' }"
--- vl.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
vl.c +22 -2
@@ -120,12 +120,14 @@ int main(int argc, char **argv)#include "ui/qemu-spice.h" #include "qapi/string-input-visitor.h" #include "qapi/opts-visitor.h" +#include "qapi/clone-visitor.h" #include "qom/object_interfaces.h" #include "exec/semihost.h" #include "crypto/init.h" #include "sysemu/replay.h" #include "qapi/qapi-events-run-state.h" #include "qapi/qapi-visit-block-core.h" +#include "qapi/qapi-visit-ui.h" #include "qapi/qapi-commands-block-core.h" #include "qapi/qapi-commands-misc.h" #include "qapi/qapi-commands-run-state.h"
@@ -2088,6 +2090,25 @@ static void select_vgahw(const char *p) } } +static void parse_display_qapi (const char *optarg) +{ +Error *err =NULL ; +DisplayOptions *opts; +Visitor *v; + + v =qobject_input_visitor_new_str (optarg,"type" , &err); +if (!v) { +error_report_err (err); +exit (1 ); + } + +visit_type_DisplayOptions (v,NULL , &opts, &error_fatal); +QAPI_CLONE_MEMBERS (DisplayOptions, &dpy, opts); + +qapi_free_DisplayOptions (opts); +visit_free (v); +} +static void parse_display (const char *p) {const char *opts;
@@ -2203,8 +2224,7 @@ static void parse_display(const char *p) }else if (strstart (p,"none" , &opts)) { dpy.type =DISPLAY_TYPE_NONE ; }else { -error_report ("unknown display type" ); -exit (1 ); +parse_display_qapi (p); } }
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH v2 1/4] ui: add qapi parser for -display
Quoted 4 lines · Gerd Hoffmann
Add
parse_display_qapi()function which parses the -display command line using a qapi visitor for DisplayOptions. Wire up as default catch inparse_display().
Quoted 8 lines
Improves the error message for unknown display types.
Also enables json as -display argument, i.e. -display "{ 'type': 'gtk' }"
Signed-off-by Gerd Hoffmann <[email protected]>--- vl.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH v2 2/4 ui: switch trivial displays to qapi parser
In reply to Gerd HoffmannDrop the option-less display types (egl-headless, curses, none) from parse_display(), so they'll be handled by parse_display_qapi().
--- vl.c | 6 ------ 1 file changed, 6 deletions(-)
vl.c +0 -6
@@ -2185,10 +2185,6 @@ static void parse_display(const char *p)error_report ("VNC requires a display argument vnc=<display>" );exit (1 ); } - }else if (strstart (p,"egl-headless" , &opts)) { - dpy.type =DISPLAY_TYPE_EGL_HEADLESS ; - }else if (strstart (p,"curses" , &opts)) { - dpy.type =DISPLAY_TYPE_CURSES ; }else if (strstart (p,"gtk" , &opts)) { dpy.type =DISPLAY_TYPE_GTK ;while (*opts) {
@@ -2221,8 +2217,6 @@ static void parse_display(const char *p) } opts = nextopt; } - }else if (strstart (p,"none" , &opts)) { - dpy.type =DISPLAY_TYPE_NONE ; }else {parse_display_qapi (p); }
Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH v2 2/4] ui: switch trivial displays to qapi parser
Quoted 8 lines · Gerd Hoffmann
Drop the option-less display types (egl-headless, curses, none) from
parse_display(), so they'll be handled byparse_display_qapi().Signed-off-by Gerd Hoffmann <[email protected]>--- vl.c | 6 ------ 1 file changed, 6 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH v2 3/4 ui: switch gtk display to qapi parser
In reply to Gerd HoffmannDrop the gtk option parser from parse_display(), so parse_display_qapi() will handle it instead.
With this change the parser will accept gl=core and gl=es too, gtk must catch the unsupported gles variant now.
--- ui/gtk.c | 6 +++++- vl.c | 32 -------------------------------- 2 files changed, 5 insertions(+), 33 deletions(-)
ui/gtk.c +5 -1
@@ -2434,7 +2434,11 @@ static void early_gtk_display_init(DisplayOptions *opts) }assert (opts->type ==DISPLAY_TYPE_GTK ); -if (opts->has_gl && opts->gl) { +if (opts->has_gl && opts->gl !=DISPLAYGL_MODE_OFF ) { +if (opts->gl ==DISPLAYGL_MODE_ES ) { +error_report ("gtk: opengl es not supported" ); +return ; + } #if defined(CONFIG_OPENGL) #if defined(CONFIG_GTK_GL) && defined(GDK_WINDOWING_WAYLAND) if (GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default())) {
vl.c +0 -32
@@ -2185,38 +2185,6 @@ static void parse_display(const char *p)error_report ("VNC requires a display argument vnc=<display>" );exit (1 ); } - }else if (strstart (p,"gtk" , &opts)) { - dpy.type =DISPLAY_TYPE_GTK ; -while (*opts) { -const char *nextopt; - -if (strstart (opts,",grab_on_hover=" , &nextopt)) { - opts = nextopt; - dpy.u.gtk.has_grab_on_hover = true; -if (strstart (opts,"on" , &nextopt)) { - dpy.u.gtk.grab_on_hover = true; - }else if (strstart (opts,"off" , &nextopt)) { - dpy.u.gtk.grab_on_hover = false; - }else { - goto invalid_gtk_args; - } - }else if (strstart (opts,",gl=" , &nextopt)) { - opts = nextopt; - dpy.has_gl = true; -if (strstart (opts,"on" , &nextopt)) { - dpy.gl =DISPLAYGL_MODE_ON ; - }else if (strstart (opts,"off" , &nextopt)) { - dpy.gl =DISPLAYGL_MODE_OFF ; - }else { - goto invalid_gtk_args; - } - }else { - invalid_gtk_args: -error_report ("invalid GTK option string" ); -exit (1 ); - } - opts = nextopt; - } }else {parse_display_qapi (p); }
Signature · 1 line
2.9.3
PATCH v2 4/4 ui: document non-qapi parser cases.
In reply to Gerd HoffmannAdd comments to the cases not (yet) switched
over to parse_display_qapi().
--- vl.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
vl.c +14 -0
@@ -2114,6 +2114,16 @@ static void parse_display(const char *p)const char *opts;if (strstart (p,"sdl" , &opts)) { +/* +* sdl DisplayType needs hand-crafted parser instead of +* parse_display_qapi() due to some options not in +* DisplayOptions, specifically: +* - frame +* Already deprecated. +* - ctrl_grab + alt_grab +* Not clear yet what happens to them long-term. Should +* replaced by something better or deprecated and dropped. +*/ dpy.type =DISPLAY_TYPE_SDL ;while (*opts) {const char *nextopt;
@@ -2179,6 +2189,10 @@ static void parse_display(const char *p) opts = nextopt; } }else if (strstart (p,"vnc" , &opts)) { +/* +* vnc isn't a (local) DisplayType but a protocol for remote +* display access. +*/ if (*opts =='=' ) {vnc_parse (opts +1 , &error_fatal); }else {
Signature · 1 line
2.9.3