dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame 0005-vl-plug-object-back-into-readconfig.patch

Paolo Bonzini d9c8b5
From 10b889b529490efb228667505bab851e8e406c67 Mon Sep 17 00:00:00 2001
Paolo Bonzini d9c8b5
From: Paolo Bonzini <pbonzini@redhat.com>
Paolo Bonzini d9c8b5
Date: Tue, 18 May 2021 11:40:59 -0400
Paolo Bonzini d9c8b5
Subject: [PATCH 5/5] vl: plug -object back into -readconfig
Paolo Bonzini d9c8b5
Paolo Bonzini d9c8b5
Commit bc2f4fcb1d ("qom: move user_creatable_add_opts logic to vl.c
Paolo Bonzini d9c8b5
and QAPIfy it", 2021-03-19) switched the creation of objects from
Paolo Bonzini d9c8b5
qemu_opts_foreach to a bespoke QTAILQ in preparation for supporting JSON
Paolo Bonzini d9c8b5
syntax in -object.
Paolo Bonzini d9c8b5
Paolo Bonzini d9c8b5
Unfortunately in doing so it lost support for [object] stanzas in
Paolo Bonzini d9c8b5
configuration files and also for "-set object.ID.KEY=VAL".  The latter
Paolo Bonzini d9c8b5
is hard to re-establish and probably best solved by deprecating -set.
Paolo Bonzini d9c8b5
This patch uses the infrastructure introduced by the previous two
Paolo Bonzini d9c8b5
patches in order to parse QOM objects correctly from configuration
Paolo Bonzini d9c8b5
files.
Paolo Bonzini d9c8b5
Paolo Bonzini d9c8b5
Cc: Markus Armbruster <armbru@redhat.com>
Paolo Bonzini d9c8b5
Cc: qemu-stable@nongnu.org
Paolo Bonzini d9c8b5
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Paolo Bonzini d9c8b5
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Paolo Bonzini d9c8b5
Message-Id: <20210524105752.3318299-4-pbonzini@redhat.com>
Paolo Bonzini d9c8b5
---
Paolo Bonzini d9c8b5
 softmmu/vl.c | 24 ++++++++++++++++++------
Paolo Bonzini d9c8b5
 1 file changed, 18 insertions(+), 6 deletions(-)
Paolo Bonzini d9c8b5
Paolo Bonzini d9c8b5
diff --git a/softmmu/vl.c b/softmmu/vl.c
Paolo Bonzini d9c8b5
index 48d1f06..d282dea 100644
Paolo Bonzini d9c8b5
--- a/softmmu/vl.c
Paolo Bonzini d9c8b5
+++ b/softmmu/vl.c
Paolo Bonzini d9c8b5
@@ -1709,9 +1709,15 @@ static void object_option_foreach_add(bool (*type_opt_predicate)(const char *))
Paolo Bonzini d9c8b5
     }
Paolo Bonzini d9c8b5
 }
Paolo Bonzini d9c8b5
 
Paolo Bonzini d9c8b5
+static void object_option_add_visitor(Visitor *v)
Paolo Bonzini d9c8b5
+{
Paolo Bonzini d9c8b5
+    ObjectOption *opt = g_new0(ObjectOption, 1);
Paolo Bonzini d9c8b5
+    visit_type_ObjectOptions(v, NULL, &opt->opts, &error_fatal);
Paolo Bonzini d9c8b5
+    QTAILQ_INSERT_TAIL(&object_opts, opt, next);
Paolo Bonzini d9c8b5
+}
Paolo Bonzini d9c8b5
+
Paolo Bonzini d9c8b5
 static void object_option_parse(const char *optarg)
Paolo Bonzini d9c8b5
 {
Paolo Bonzini d9c8b5
-    ObjectOption *opt;
Paolo Bonzini d9c8b5
     QemuOpts *opts;
Paolo Bonzini d9c8b5
     const char *type;
Paolo Bonzini d9c8b5
     Visitor *v;
Paolo Bonzini d9c8b5
@@ -1739,11 +1745,8 @@ static void object_option_parse(const char *optarg)
Paolo Bonzini d9c8b5
         v = opts_visitor_new(opts);
Paolo Bonzini d9c8b5
     }
Paolo Bonzini d9c8b5
 
Paolo Bonzini d9c8b5
-    opt = g_new0(ObjectOption, 1);
Paolo Bonzini d9c8b5
-    visit_type_ObjectOptions(v, NULL, &opt->opts, &error_fatal);
Paolo Bonzini d9c8b5
+    object_option_add_visitor(v);
Paolo Bonzini d9c8b5
     visit_free(v);
Paolo Bonzini d9c8b5
-
Paolo Bonzini d9c8b5
-    QTAILQ_INSERT_TAIL(&object_opts, opt, next);
Paolo Bonzini d9c8b5
 }
Paolo Bonzini d9c8b5
 
Paolo Bonzini d9c8b5
 /*
Paolo Bonzini d9c8b5
@@ -2120,13 +2123,22 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp)
Paolo Bonzini d9c8b5
  */
Paolo Bonzini d9c8b5
 static bool is_qemuopts_group(const char *group)
Paolo Bonzini d9c8b5
 {
Paolo Bonzini d9c8b5
+    if (g_str_equal(group, "object")) {
Paolo Bonzini d9c8b5
+        return false;
Paolo Bonzini d9c8b5
+    }
Paolo Bonzini d9c8b5
     return true;
Paolo Bonzini d9c8b5
 }
Paolo Bonzini d9c8b5
 
Paolo Bonzini d9c8b5
 static void qemu_record_config_group(const char *group, QDict *dict,
Paolo Bonzini d9c8b5
                                      bool from_json, Error **errp)
Paolo Bonzini d9c8b5
 {
Paolo Bonzini d9c8b5
-    abort();
Paolo Bonzini d9c8b5
+    if (g_str_equal(group, "object")) {
Paolo Bonzini d9c8b5
+        Visitor *v = qobject_input_visitor_new_keyval(QOBJECT(dict));
Paolo Bonzini d9c8b5
+        object_option_add_visitor(v);
Paolo Bonzini d9c8b5
+        visit_free(v);
Paolo Bonzini d9c8b5
+    } else {
Paolo Bonzini d9c8b5
+        abort();
Paolo Bonzini d9c8b5
+    }
Paolo Bonzini d9c8b5
 }
Paolo Bonzini d9c8b5
 
Paolo Bonzini d9c8b5
 /*
Paolo Bonzini d9c8b5
-- 
Paolo Bonzini d9c8b5
2.31.1
Paolo Bonzini d9c8b5