yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
ae23c9
From f8d17c68e5d3f5b526968a4790a14681fdc69ecd Mon Sep 17 00:00:00 2001
ae23c9
From: Gerd Hoffmann <kraxel@redhat.com>
ae23c9
Date: Fri, 14 Dec 2018 08:26:38 +0000
ae23c9
Subject: [PATCH 1/5] ui: add qapi parser for -display
ae23c9
MIME-Version: 1.0
ae23c9
Content-Type: text/plain; charset=UTF-8
ae23c9
Content-Transfer-Encoding: 8bit
ae23c9
ae23c9
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
ae23c9
Message-id: <20181214082642.21878-2-kraxel@redhat.com>
ae23c9
Patchwork-id: 83507
ae23c9
O-Subject: [RHEL8/rhel qemu-kvm PATCH 1/5] ui: add qapi parser for -display
ae23c9
Bugzilla: 1652871
ae23c9
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
ae23c9
RH-Acked-by: Daniel P. Berrange <berrange@redhat.com>
ae23c9
RH-Acked-by: Erik Skultety <eskultet@redhat.com>
ae23c9
ae23c9
Add parse_display_qapi() function which parses the -display command line
ae23c9
using a qapi visitor for DisplayOptions.  Wire up as default catch in
ae23c9
parse_display().
ae23c9
ae23c9
Improves the error message for unknown display types.
ae23c9
ae23c9
Also enables json as -display argument, i.e. -display "{ 'type': 'gtk' }"
ae23c9
ae23c9
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
ae23c9
Reviewed-by: Eric Blake <eblake@redhat.com>
ae23c9
Message-id: 20180507095539.19584-2-kraxel@redhat.com
ae23c9
(cherry picked from commit 776d1344bd0566f412d5bc063e753a6b98530bcf)
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 vl.c | 24 ++++++++++++++++++++++--
ae23c9
 1 file changed, 22 insertions(+), 2 deletions(-)
ae23c9
ae23c9
diff --git a/vl.c b/vl.c
ae23c9
index 74fa8f2..934e402 100644
ae23c9
--- a/vl.c
ae23c9
+++ b/vl.c
ae23c9
@@ -120,12 +120,14 @@ int main(int argc, char **argv)
ae23c9
 #include "ui/qemu-spice.h"
ae23c9
 #include "qapi/string-input-visitor.h"
ae23c9
 #include "qapi/opts-visitor.h"
ae23c9
+#include "qapi/clone-visitor.h"
ae23c9
 #include "qom/object_interfaces.h"
ae23c9
 #include "exec/semihost.h"
ae23c9
 #include "crypto/init.h"
ae23c9
 #include "sysemu/replay.h"
ae23c9
 #include "qapi/qapi-events-run-state.h"
ae23c9
 #include "qapi/qapi-visit-block-core.h"
ae23c9
+#include "qapi/qapi-visit-ui.h"
ae23c9
 #include "qapi/qapi-commands-block-core.h"
ae23c9
 #include "qapi/qapi-commands-misc.h"
ae23c9
 #include "qapi/qapi-commands-run-state.h"
ae23c9
@@ -2117,6 +2119,25 @@ static void select_vgahw(const char *p)
ae23c9
     }
ae23c9
 }
ae23c9
 
ae23c9
+static void parse_display_qapi(const char *optarg)
ae23c9
+{
ae23c9
+    Error *err = NULL;
ae23c9
+    DisplayOptions *opts;
ae23c9
+    Visitor *v;
ae23c9
+
ae23c9
+    v = qobject_input_visitor_new_str(optarg, "type", &err;;
ae23c9
+    if (!v) {
ae23c9
+        error_report_err(err);
ae23c9
+        exit(1);
ae23c9
+    }
ae23c9
+
ae23c9
+    visit_type_DisplayOptions(v, NULL, &opts, &error_fatal);
ae23c9
+    QAPI_CLONE_MEMBERS(DisplayOptions, &dpy, opts);
ae23c9
+
ae23c9
+    qapi_free_DisplayOptions(opts);
ae23c9
+    visit_free(v);
ae23c9
+}
ae23c9
+
ae23c9
 static void parse_display(const char *p)
ae23c9
 {
ae23c9
     const char *opts;
ae23c9
@@ -2228,8 +2249,7 @@ static void parse_display(const char *p)
ae23c9
     } else if (strstart(p, "none", &opts)) {
ae23c9
         dpy.type = DISPLAY_TYPE_NONE;
ae23c9
     } else {
ae23c9
-        error_report("unknown display type");
ae23c9
-        exit(1);
ae23c9
+        parse_display_qapi(p);
ae23c9
     }
ae23c9
 }
ae23c9
 
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9