All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/4] ui: use qapi-based parser for most -display options.
@ 2018-05-07  9:55 Gerd Hoffmann
  2018-05-07  9:55 ` [Qemu-devel] [PATCH v2 1/4] ui: add qapi parser for -display Gerd Hoffmann
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2018-05-07  9:55 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Paolo Bonzini, Michael Tokarev, qemu-trivial,
	Gerd Hoffmann, Markus Armbruster

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(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH v2 1/4] ui: add qapi parser for -display
  2018-05-07  9:55 [Qemu-devel] [PATCH v2 0/4] ui: use qapi-based parser for most -display options Gerd Hoffmann
@ 2018-05-07  9:55 ` Gerd Hoffmann
  2018-05-07 17:56   ` Eric Blake
  2018-05-07  9:55 ` [Qemu-devel] [PATCH v2 2/4] ui: switch trivial displays to qapi parser Gerd Hoffmann
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Gerd Hoffmann @ 2018-05-07  9:55 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Paolo Bonzini, Michael Tokarev, qemu-trivial,
	Gerd Hoffmann, Markus Armbruster

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' }"

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 vl.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/vl.c b/vl.c
index 806eec2ef6..d53ea078bd 100644
--- a/vl.c
+++ b/vl.c
@@ -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);
     }
 }
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH v2 2/4] ui: switch trivial displays to qapi parser
  2018-05-07  9:55 [Qemu-devel] [PATCH v2 0/4] ui: use qapi-based parser for most -display options Gerd Hoffmann
  2018-05-07  9:55 ` [Qemu-devel] [PATCH v2 1/4] ui: add qapi parser for -display Gerd Hoffmann
@ 2018-05-07  9:55 ` Gerd Hoffmann
  2018-05-07 17:57   ` Eric Blake
  2018-05-07  9:55 ` [Qemu-devel] [PATCH v2 3/4] ui: switch gtk display " Gerd Hoffmann
  2018-05-07  9:55 ` [Qemu-devel] [PATCH v2 4/4] ui: document non-qapi parser cases Gerd Hoffmann
  3 siblings, 1 reply; 7+ messages in thread
From: Gerd Hoffmann @ 2018-05-07  9:55 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Paolo Bonzini, Michael Tokarev, qemu-trivial,
	Gerd Hoffmann, Markus Armbruster

Drop the option-less display types (egl-headless, curses, none) from
parse_display(), so they'll be handled by parse_display_qapi().

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 vl.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/vl.c b/vl.c
index d53ea078bd..1bd6758f3a 100644
--- a/vl.c
+++ b/vl.c
@@ -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);
     }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH v2 3/4] ui: switch gtk display to qapi parser
  2018-05-07  9:55 [Qemu-devel] [PATCH v2 0/4] ui: use qapi-based parser for most -display options Gerd Hoffmann
  2018-05-07  9:55 ` [Qemu-devel] [PATCH v2 1/4] ui: add qapi parser for -display Gerd Hoffmann
  2018-05-07  9:55 ` [Qemu-devel] [PATCH v2 2/4] ui: switch trivial displays to qapi parser Gerd Hoffmann
@ 2018-05-07  9:55 ` Gerd Hoffmann
  2018-05-07  9:55 ` [Qemu-devel] [PATCH v2 4/4] ui: document non-qapi parser cases Gerd Hoffmann
  3 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2018-05-07  9:55 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Paolo Bonzini, Michael Tokarev, qemu-trivial,
	Gerd Hoffmann, Markus Armbruster

Drop 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.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/gtk.c |  6 +++++-
 vl.c     | 32 --------------------------------
 2 files changed, 5 insertions(+), 33 deletions(-)

diff --git a/ui/gtk.c b/ui/gtk.c
index bb3214cffb..7859b506ea 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -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())) {
diff --git a/vl.c b/vl.c
index 1bd6758f3a..03ac9a2cbb 100644
--- a/vl.c
+++ b/vl.c
@@ -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);
     }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH v2 4/4] ui: document non-qapi parser cases.
  2018-05-07  9:55 [Qemu-devel] [PATCH v2 0/4] ui: use qapi-based parser for most -display options Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2018-05-07  9:55 ` [Qemu-devel] [PATCH v2 3/4] ui: switch gtk display " Gerd Hoffmann
@ 2018-05-07  9:55 ` Gerd Hoffmann
  3 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2018-05-07  9:55 UTC (permalink / raw)
  To: qemu-devel
  Cc: Laurent Vivier, Paolo Bonzini, Michael Tokarev, qemu-trivial,
	Gerd Hoffmann, Markus Armbruster

Add comments to the cases not (yet) switched
over to parse_display_qapi().

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 vl.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/vl.c b/vl.c
index 03ac9a2cbb..041b3836d7 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.
+         */
         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 {
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH v2 1/4] ui: add qapi parser for -display
  2018-05-07  9:55 ` [Qemu-devel] [PATCH v2 1/4] ui: add qapi parser for -display Gerd Hoffmann
@ 2018-05-07 17:56   ` Eric Blake
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Blake @ 2018-05-07 17:56 UTC (permalink / raw)
  To: Gerd Hoffmann, qemu-devel
  Cc: qemu-trivial, Michael Tokarev, Laurent Vivier, Markus Armbruster,
	Paolo Bonzini

On 05/07/2018 04:55 AM, Gerd Hoffmann wrote:
> 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' }"
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>   vl.c | 24 ++++++++++++++++++++++--
>   1 file changed, 22 insertions(+), 2 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH v2 2/4] ui: switch trivial displays to qapi parser
  2018-05-07  9:55 ` [Qemu-devel] [PATCH v2 2/4] ui: switch trivial displays to qapi parser Gerd Hoffmann
@ 2018-05-07 17:57   ` Eric Blake
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Blake @ 2018-05-07 17:57 UTC (permalink / raw)
  To: Gerd Hoffmann, qemu-devel
  Cc: qemu-trivial, Michael Tokarev, Laurent Vivier, Markus Armbruster,
	Paolo Bonzini

On 05/07/2018 04:55 AM, Gerd Hoffmann wrote:
> Drop the option-less display types (egl-headless, curses, none) from
> parse_display(), so they'll be handled by parse_display_qapi().
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>   vl.c | 6 ------
>   1 file changed, 6 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-05-07 17:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-07  9:55 [Qemu-devel] [PATCH v2 0/4] ui: use qapi-based parser for most -display options Gerd Hoffmann
2018-05-07  9:55 ` [Qemu-devel] [PATCH v2 1/4] ui: add qapi parser for -display Gerd Hoffmann
2018-05-07 17:56   ` Eric Blake
2018-05-07  9:55 ` [Qemu-devel] [PATCH v2 2/4] ui: switch trivial displays to qapi parser Gerd Hoffmann
2018-05-07 17:57   ` Eric Blake
2018-05-07  9:55 ` [Qemu-devel] [PATCH v2 3/4] ui: switch gtk display " Gerd Hoffmann
2018-05-07  9:55 ` [Qemu-devel] [PATCH v2 4/4] ui: document non-qapi parser cases Gerd Hoffmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.