ui: use qapi-based parser for most -display options.
cover ui: use qapi-based parser for most -display options.
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.
vl.c | 81 ++++++++++++++++++++++++++++++++++---------------------------------- 1 file changed, 41 insertions(+), 40 deletions(-)
Signature · 1 line
2.9.3
PATCH 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 | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)
vl.c +27 -2
@@ -126,6 +126,7 @@ int main(int argc, char **argv)#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"
@@ -2090,6 +2091,31 @@ 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); +visit_free (v); + +/* +* We don't have any dynamically allocated stuff inside +* DisplayOptions, so we can simply copy the struct content and +* free opts without ending up with pointers pointing into +* nowhere. +*/ + dpy = *opts; +qapi_free_DisplayOptions (opts); +} +static void parse_display (const char *p) {const char *opts;
@@ -2201,8 +2227,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 1/4] ui: add qapi parser for -display
Quoted 11 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().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 static void select_vgahw(const char *p) · line 2116
Quoted 9 lines
vl.c +9
-0+ +/* +* We don't have any dynamically allocated stuff inside +* DisplayOptions, so we can simply copy the struct content and +* free opts without ending up with pointers pointing into +* nowhere. +*/ + dpy = *opts; +qapi_free_DisplayOptions (opts);
That's risky; would it be better to use QAPI_CLONE_MEMBERS() to not have to worry about if we add a pointer in the future?
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PATCH 1/4] ui: add qapi parser for -display
Quoted 11 lines
vl.c static void select_vgahw(const char *p) · line 2116
Quoted 8 lines
vl.c +8
-0+/* +* We don't have any dynamically allocated stuff inside +* DisplayOptions, so we can simply copy the struct content and +* free opts without ending up with pointers pointing into +* nowhere. +*/ + dpy = *opts; +qapi_free_DisplayOptions (opts);That's risky; would it be better to use
QAPI_CLONE_MEMBERS()to not have to worry about if we add a pointer in the future?
Didn't know QAPI_CLONE_MEMBERS() exists. Yes, probably more future-proof to just use that instead of adding that comment. Will look into that for v2.
cheers,
Gerd
Re: [Qemu-devel] [PATCH 1/4] ui: add qapi parser for -display
In reply to Gerd HoffmannQuoted 7 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().Improves the error message for unknown display types.
Also enables json as -display argument, i.e. -display "{ 'type': 'gtk' }"
This new option argument syntax is undocumented. Intentional?
Quoted 4 lines
Signed-off-by Gerd Hoffmann <[email protected]>--- vl.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)
Re: [Qemu-devel] [PATCH 1/4] ui: add qapi parser for -display
Quoted 11 lines · Markus Armbruster
Quoted 7 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().Improves the error message for unknown display types.
Also enables json as -display argument, i.e. -display "{ 'type': 'gtk' }"
This new option argument syntax is undocumented. Intentional?
Please advise.
Re: [Qemu-devel] [PATCH 1/4] ui: add qapi parser for -display
Quoted 8 lines · Markus Armbruster
Quoted 6 lines · Markus Armbruster
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 5 lines
Quoted 5 lines
Quoted 3 lines
Improves the error message for unknown display types.
Also enables json as -display argument, i.e. -display "{ 'type': 'gtk' }"
This new option argument syntax is undocumented. Intentional?
No, just -ENOTIME.
Quoted 1 line
Please advise.
Well, just need to find some time to do it.
In case you want tackle it: Works simliar to -blockdev, with a few exceptions. Some legacy sdl options I plan to deprecate are not supported via json.
cheers,
Gerd
Re: [Qemu-devel] [PATCH 1/4] ui: add qapi parser for -display
In reply to Markus ArmbrusterQuoted 8 lines · Markus Armbruster
Quoted 6 lines · Markus Armbruster
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 7 lines
Quoted 5 lines
Quoted 3 lines
Improves the error message for unknown display types.
Also enables json as -display argument, i.e. -display "{ 'type': 'gtk' }"
This new option argument syntax is undocumented. Intentional?
Please advise.
Hmm, checking -blockdev doc in qemu-options.hx, nothing about json. Is this documented elsewhere?
cheers,
Gerd
PATCH 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
@@ -2188,10 +2188,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) {
@@ -2224,8 +2220,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
PATCH 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.
--- vl.c | 32 -------------------------------- 1 file changed, 32 deletions(-)
vl.c +0 -32
@@ -2188,38 +2188,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 = true; - }else if (strstart (opts,"off" , &nextopt)) { - dpy.gl = false; - }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 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
@@ -2121,6 +2121,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;
@@ -2182,6 +2192,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