From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, armbru@redhat.com, qemu-stable@nongnu.org
Subject: [PATCH 3/3] vl: plug -object back into -readconfig
Date: Tue, 18 May 2021 11:40:59 -0400 [thread overview]
Message-ID: <20210518154059.3002446-3-pbonzini@redhat.com> (raw)
In-Reply-To: <20210518154014.2999326-1-pbonzini@redhat.com>
Commit bc2f4fcb1d ("qom: move user_creatable_add_opts logic to vl.c
and QAPIfy it", 2021-03-19) switched the creation of objects from
qemu_opts_foreach to a bespoke QTAILQ in preparation for supporting JSON
syntax in -object.
Unfortunately in doing so it lost support for [object] stanzas in
configuration files and also for "-set object.ID.KEY=VAL". The latter
is hard to re-establish and probably best solved by deprecating -set.
This patch uses the infrastructure introduced by the previous two
patches in order to parse QOM objects correctly from configuration
files.
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
softmmu/vl.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 90e491cc0c..a8abf8e740 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -1708,9 +1708,15 @@ static void object_option_foreach_add(bool (*type_opt_predicate)(const char *))
}
}
+static void object_option_add_visitor(Visitor *v)
+{
+ ObjectOption *opt = g_new0(ObjectOption, 1);
+ visit_type_ObjectOptions(v, NULL, &opt->opts, &error_fatal);
+ QTAILQ_INSERT_TAIL(&object_opts, opt, next);
+}
+
static void object_option_parse(const char *optarg)
{
- ObjectOption *opt;
QemuOpts *opts;
const char *type;
Visitor *v;
@@ -1738,11 +1744,8 @@ static void object_option_parse(const char *optarg)
v = opts_visitor_new(opts);
}
- opt = g_new0(ObjectOption, 1);
- visit_type_ObjectOptions(v, NULL, &opt->opts, &error_fatal);
+ object_option_add_visitor(v);
visit_free(v);
-
- QTAILQ_INSERT_TAIL(&object_opts, opt, next);
}
/*
@@ -2122,12 +2125,21 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp)
*/
static bool is_qemuopts_group(const char *group)
{
+ if (g_str_equal(group, "object")) {
+ return false;
+ }
return true;
}
static void qemu_record_config_group(const char *group, QDict *dict, bool from_json, Error **errp)
{
- abort();
+ if (g_str_equal(group, "object")) {
+ Visitor *v = qobject_input_visitor_new_keyval(QOBJECT(dict));
+ object_option_add_visitor(v);
+ visit_free(v);
+ } else {
+ abort();
+ }
}
/*
--
2.27.0
next prev parent reply other threads:[~2021-05-18 15:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-18 15:40 [PATCH 0/3] vl: add -object support back into -readconfig Paolo Bonzini
2021-05-18 15:40 ` [PATCH 1/3] qemu-config: parse configuration files to a QDict Paolo Bonzini
2021-05-19 14:40 ` Kevin Wolf
2021-05-20 7:41 ` Paolo Bonzini
2021-05-18 15:40 ` [PATCH 2/3] vl: plumb keyval-based options into -readconfig Paolo Bonzini
2021-05-19 16:35 ` Kevin Wolf
2021-05-18 15:40 ` Paolo Bonzini [this message]
2021-05-19 16:41 ` [PATCH 3/3] vl: plug -object back " Kevin Wolf
2021-05-19 13:58 ` [PATCH 0/3] vl: add -object support " Kevin Wolf
2021-05-19 14:46 ` Paolo Bonzini
2021-05-19 14:09 ` no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210518154059.3002446-3-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).