Re: [PATCH 2/3] ui: Switch "-display sdl" to use the QAPI parser
On 17/05/2022 13.19, Markus Armbruster wrote: Paolo Bonzini writes: On 5/17/22 10:34, Thomas Huth wrote: This remains, and that's fine. One step at time. Not sure how we want to proceed with that in the long run, though ... IIRC clearly, Paolo once said that it doesn't really belong into "-display" anyway and should be handled with the separate "-vnc" option instead? Not me, Gerd (https://lore.kernel.org/all/20210825092023.81396-2-th...@redhat.com/T/#e8c4f826cc8ff48b9afad37703e11704137f540c8): Other way around, -display vnc should be dropped. -display is about local displays, and there can be only one instance. -vnc / -spice enable remote access, and this can be done in addition to a local display. not possible: -display gtk + -display sdl possible: -display gtk + -vnc -display gtk + -vnc + -spice -display none + -vnc + -spice For what it's worth, Libvirt uses both -vnc and -spice, so we might very well proceed with Gerd's idea. If we don't like -vnc and -spice then it may be possible to QOMify them and go with -object. Are we ready to deprecate -display vnc? If nobody disagrees, I'd say yes. Thomas
Re: [PATCH 2/3] ui: Switch "-display sdl" to use the QAPI parser
Paolo Bonzini writes: > On 5/17/22 10:34, Thomas Huth wrote: >>> This remains, and that's fine. One step at time. >> Not sure how we want to proceed with that in the long run, though >> ... IIRC clearly, Paolo once said that it doesn't really belong into >> "-display" anyway and should be handled with the separate "-vnc" >> option instead? > > Not me, Gerd > (https://lore.kernel.org/all/20210825092023.81396-2-th...@redhat.com/T/#e8c4f826cc8ff48b9afad37703e11704137f540c8): > >> Other way around, -display vnc should be dropped. -display is about >> local displays, and there can be only one instance. -vnc / -spice >> enable remote access, and this can be done in addition to a local >> display. >> not possible: >> -display gtk + -display sdl >> possible: >> -display gtk + -vnc >> -display gtk + -vnc + -spice >> -display none + -vnc + -spice > > For what it's worth, Libvirt uses both -vnc and -spice, so we might > very well proceed with Gerd's idea. If we don't like -vnc and -spice > then it may be possible to QOMify them and go with -object. Are we ready to deprecate -display vnc?
Re: [PATCH 2/3] ui: Switch "-display sdl" to use the QAPI parser
On 5/17/22 10:34, Thomas Huth wrote: This remains, and that's fine. One step at time. Not sure how we want to proceed with that in the long run, though ... IIRC clearly, Paolo once said that it doesn't really belong into "-display" anyway and should be handled with the separate "-vnc" option instead? Not me, Gerd (https://lore.kernel.org/all/20210825092023.81396-2-th...@redhat.com/T/#e8c4f826cc8ff48b9afad37703e11704137f540c8): Other way around, -display vnc should be dropped. -display is about local displays, and there can be only one instance. -vnc / -spice enable remote access, and this can be done in addition to a local display. not possible: -display gtk + -display sdl possible: -display gtk + -vnc -display gtk + -vnc + -spice -display none + -vnc + -spice For what it's worth, Libvirt uses both -vnc and -spice, so we might very well proceed with Gerd's idea. If we don't like -vnc and -spice then it may be possible to QOMify them and go with -object. Thanks, Paolo
Re: [PATCH 2/3] ui: Switch "-display sdl" to use the QAPI parser
Thomas Huth writes: > On 12/05/2022 14.16, Markus Armbruster wrote: [...] >>> This introduces the new "DisplaySDL" QAPI struct that is used to hold >>> the parameters that are unique to the SDL display. The only specific >>> parameter is currently "grab-mod" which is modeled as a string, so that >>> it could be extended for other arbitrary modifiers later more easily. >> >> Are the values of @grab-mod parsed in any way, or do we recognize a set >> of fixed strings? >> >> The former would be problematic. We try hard to represent complex data >> as JSON instead of inventing little ad hoc languages. >> >> If it's the latter, use an enum. Makes introspection more useful, and >> adding enumeration values is no harder than adding string literals. > > It's currently only two strings that are used to replace the old behavior. > But in the long run, I think it would be nice to have more flexibility here, > so that a user could specify an arbitrary combination of modifier keys. I > don't think that an enum will really scale here, so I'd prefer to go with > the current approach and use the string for more flexibility. "Arbitrary combination of modifier keys" sounds like set of enum to me. We approximate sets with lists in QAPI.
Re: [PATCH 2/3] ui: Switch "-display sdl" to use the QAPI parser
On 12/05/2022 14.16, Markus Armbruster wrote: [...]> 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. This sounds like it was mostly reluctance to drag undesirables into the QAPI schema. Yeah, ctrl_grab and alt_grab were just too ugly and inflexible to drag them along into the QAPI world. @@ -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 { This remains, and that's fine. One step at time. Not sure how we want to proceed with that in the long run, though ... IIRC clearly, Paolo once said that it doesn't really belong into "-display" anyway and should be handled with the separate "-vnc" option instead? Now that the problematic parameters have been removed, we can switch to use the QAPI parser instead. Here's my attempt at a more accurate commit message. The "-display sdl" option still uses a hand-crafted parser for its parameters since we didn't want to drag an interface we considered somewhat flawed into the QAPI schema. Since the flaws are gone now, it's time to QAPIfy. Ok, I can update the description, thanks! This introduces the new "DisplaySDL" QAPI struct that is used to hold the parameters that are unique to the SDL display. The only specific parameter is currently "grab-mod" which is modeled as a string, so that it could be extended for other arbitrary modifiers later more easily. Are the values of @grab-mod parsed in any way, or do we recognize a set of fixed strings? The former would be problematic. We try hard to represent complex data as JSON instead of inventing little ad hoc languages. If it's the latter, use an enum. Makes introspection more useful, and adding enumeration values is no harder than adding string literals. It's currently only two strings that are used to replace the old behavior. But in the long run, I think it would be nice to have more flexibility here, so that a user could specify an arbitrary combination of modifier keys. I don't think that an enum will really scale here, so I'd prefer to go with the current approach and use the string for more flexibility. Thomas
Re: [PATCH 2/3] ui: Switch "-display sdl" to use the QAPI parser
Thomas Huth writes: > The "-display sdl" option still uses a hand-crafted parser for its > parameters since some of them used underscores which is forbidden > in QAPI. Kind of. QAPI indeed requires lower-case-with-hyphens for such names, but there is an exception mechanism for names with upper case and underscore: pragma member-name-exceptions. Used for old names that predate naming rule enforcement, and for newer names we've elected to make consistent with their old siblings. The series that QAPIfied -display partially explained why it left -display sdl,... and -display vnc,... unQAPIfied in commit 7a61f43859 "ui: document non-qapi parser cases.": diff --git a/vl.c b/vl.c index 5f1734d851..3b39bbd7a8 100644 --- a/vl.c +++ b/vl.c @@ -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. This sounds like it was mostly reluctance to drag undesirables into the QAPI schema. Commit f6b560bbc1 "softmmu/vl: Remove obsolete comment about the "frame" parameter" dropped item "frame". Commit 8e8e844be4 "softmmu/vl: Add a "grab-mod" parameter to the -display sdl option" decided the future of ctrl_grab + alt_grab. It replaced the second item's text: + * They can't be moved into the QAPI since they use underscores, + * thus they will get replaced by "grab-mod" in the long term I figure they could've been moved to the QAPI schema back then. Instead, we're getting rid of them without a detour through the schema. Good! + */ 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 { This remains, and that's fine. One step at time. > Now that the problematic parameters have been removed, we can > switch to use the QAPI parser instead. Here's my attempt at a more accurate commit message. The "-display sdl" option still uses a hand-crafted parser for its parameters since we didn't want to drag an interface we considered somewhat flawed into the QAPI schema. Since the flaws are gone now, it's time to QAPIfy. > This introduces the new "DisplaySDL" QAPI struct that is used to hold > the parameters that are unique to the SDL display. The only specific > parameter is currently "grab-mod" which is modeled as a string, so that > it could be extended for other arbitrary modifiers later more easily. Are the values of @grab-mod parsed in any way, or do we recognize a set of fixed strings? The former would be problematic. We try hard to represent complex data as JSON instead of inventing little ad hoc languages. If it's the latter, use an enum. Makes introspection more useful, and adding enumeration values is no harder than adding string literals. > Signed-off-by: Thomas Huth
Re: [PATCH 2/3] ui: Switch "-display sdl" to use the QAPI parser
On Wed, May 11, 2022 at 07:51:46PM +0200, Thomas Huth wrote: > The "-display sdl" option still uses a hand-crafted parser for its > parameters since some of them used underscores which is forbidden > in QAPI. Now that the problematic parameters have been removed, we can > switch to use the QAPI parser instead. > > This introduces the new "DisplaySDL" QAPI struct that is used to hold > the parameters that are unique to the SDL display. The only specific > parameter is currently "grab-mod" which is modeled as a string, so that > it could be extended for other arbitrary modifiers later more easily. > > Signed-off-by: Thomas Huth > --- > qapi/ui.json| 17 +- > include/sysemu/sysemu.h | 2 -- > softmmu/globals.c | 2 -- > softmmu/vl.c| 70 + > ui/sdl2.c | 13 > 5 files changed, 30 insertions(+), 74 deletions(-) Reviewed-by: Daniel P. Berrangé With regards, Daniel -- |: https://berrange.com -o-https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o-https://fstop138.berrange.com :| |: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|
[PATCH 2/3] ui: Switch "-display sdl" to use the QAPI parser
The "-display sdl" option still uses a hand-crafted parser for its parameters since some of them used underscores which is forbidden in QAPI. Now that the problematic parameters have been removed, we can switch to use the QAPI parser instead. This introduces the new "DisplaySDL" QAPI struct that is used to hold the parameters that are unique to the SDL display. The only specific parameter is currently "grab-mod" which is modeled as a string, so that it could be extended for other arbitrary modifiers later more easily. Signed-off-by: Thomas Huth --- qapi/ui.json| 17 +- include/sysemu/sysemu.h | 2 -- softmmu/globals.c | 2 -- softmmu/vl.c| 70 + ui/sdl2.c | 13 5 files changed, 30 insertions(+), 74 deletions(-) diff --git a/qapi/ui.json b/qapi/ui.json index 059302a5ef..511ade44f2 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -1309,6 +1309,20 @@ '*swap-opt-cmd': 'bool' } } +## +# @DisplaySDL: +# +# SDL2 display options. +# +# @grab-mod: String with modifier keys that should be pressed together with +# the "G" key to release the mouse grab. Only "lshift-lctrl-lalt" +# and "rctrl" are currently supported. +# +# Since: 7.1 +## +{ 'struct' : 'DisplaySDL', + 'data': { '*grab-mod' : 'str' } } + ## # @DisplayType: # @@ -1391,7 +1405,8 @@ 'curses': { 'type': 'DisplayCurses', 'if': 'CONFIG_CURSES' }, 'egl-headless': { 'type': 'DisplayEGLHeadless', 'if': { 'all': ['CONFIG_OPENGL', 'CONFIG_GBM'] } }, - 'dbus': { 'type': 'DisplayDBus', 'if': 'CONFIG_DBUS_DISPLAY' } + 'dbus': { 'type': 'DisplayDBus', 'if': 'CONFIG_DBUS_DISPLAY' }, + 'sdl': { 'type': 'DisplaySDL', 'if': 'CONFIG_SDL' } } } diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 360a408edf..7cca797450 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -42,8 +42,6 @@ extern int graphic_depth; extern int display_opengl; extern const char *keyboard_layout; extern int win2k_install_hack; -extern int alt_grab; -extern int ctrl_grab; extern int graphic_rotate; extern int old_param; extern int boot_menu; diff --git a/softmmu/globals.c b/softmmu/globals.c index 98b64e0492..12611c2a7a 100644 --- a/softmmu/globals.c +++ b/softmmu/globals.c @@ -50,8 +50,6 @@ QEMUOptionRom option_rom[MAX_OPTION_ROMS]; int nb_option_roms; int old_param; const char *qemu_name; -int alt_grab; -int ctrl_grab; unsigned int nb_prom_envs; const char *prom_envs[MAX_PROM_ENVS]; int boot_menu; diff --git a/softmmu/vl.c b/softmmu/vl.c index fdf797270c..90a0a4d393 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -1045,75 +1045,7 @@ static void parse_display(const char *p) exit(0); } -if (strstart(p, "sdl", &opts)) { -/* - * sdl DisplayType needs hand-crafted parser instead of - * parse_display_qapi() due to some options not in - * DisplayOptions, specifically: - * - ctrl_grab + alt_grab - * They can't be moved into the QAPI since they use underscores, - * thus they will get replaced by "grab-mod" in the long term - */ -#if defined(CONFIG_SDL) -dpy.type = DISPLAY_TYPE_SDL; -while (*opts) { -const char *nextopt; - -if (strstart(opts, ",grab-mod=", &nextopt)) { -opts = nextopt; -if (strstart(opts, "lshift-lctrl-lalt", &nextopt)) { -alt_grab = 1; -} else if (strstart(opts, "rctrl", &nextopt)) { -ctrl_grab = 1; -} else { -goto invalid_sdl_args; -} -} else if (strstart(opts, ",window-close=", &nextopt)) { -opts = nextopt; -dpy.has_window_close = true; -if (strstart(opts, "on", &nextopt)) { -dpy.window_close = true; -} else if (strstart(opts, "off", &nextopt)) { -dpy.window_close = false; -} else { -goto invalid_sdl_args; -} -} else if (strstart(opts, ",show-cursor=", &nextopt)) { -opts = nextopt; -dpy.has_show_cursor = true; -if (strstart(opts, "on", &nextopt)) { -dpy.show_cursor = true; -} else if (strstart(opts, "off", &nextopt)) { -dpy.show_cursor = false; -} else { -goto invalid_sdl_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, "core", &nextopt)) { -dpy.gl = DISPLAYGL_MODE_CORE; -