cryptospore / rpms / qemu-kvm

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