From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, armbru@redhat.com, qemu-stable@nongnu.org
Subject: Re: [PATCH v4 1/3] qemu-config: parse configuration files to a QDict
Date: Wed, 9 Jun 2021 13:37:31 +0200 [thread overview]
Message-ID: <7728cf1b-76c8-c39e-4e60-e7f25416d920@redhat.com> (raw)
In-Reply-To: <20210524105752.3318299-2-pbonzini@redhat.com>
Hi Paolo,
On 5/24/21 12:57 PM, Paolo Bonzini wrote:
> Change the parser to put the values into a QDict and pass them
> to a callback. qemu_config_parse's QemuOpts creation is
> itself turned into a callback function.
>
> This is useful for -readconfig to support keyval-based options;
> getting a QDict from the parser removes a roundtrip from
> QDict to QemuOpts and then back to QDict.
>
> Unfortunately there is a disadvantage in that semantic errors will
> point to the last line of the group, because the entries of the QDict
> do not have a location attached.
>
> 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>
> ---
> v1->v2: check for unrecognized entries in the QDict, move a loc_pop for
> better error messages
>
> v2->v3->v4: fix error propagation
>
> include/qemu/config-file.h | 7 ++-
> softmmu/vl.c | 4 +-
> util/qemu-config.c | 98 ++++++++++++++++++++++++++------------
> 3 files changed, 76 insertions(+), 33 deletions(-)
> -int qemu_read_config_file(const char *filename, Error **errp)
> +void qemu_config_do_parse(const char *group, QDict *qdict, void *opaque, Error **errp)
> +{
> + QemuOptsList **lists = opaque;
> + const char *id = qdict_get_try_str(qdict, "id");
> + QemuOptsList *list;
> + QemuOpts *opts;
> + const QDictEntry *unrecognized;
> +
> + list = find_list(lists, group, errp);
> + if (!list) {
> + return;
> + }
> +
> + opts = qemu_opts_create(list, id, 1, errp);
> + if (!opts) {
> + return;
> + }
> + if (!qemu_opts_absorb_qdict(opts, qdict, errp)) {
> + return;
> + }
> + unrecognized = qdict_first(qdict);
> + if (unrecognized) {
Using the qemu-qmp.conf from:
https://wiki.qemu.org/Documentation/QMP#By_hand
I'm getting:
qemu-system-i386:qemu-qmp.conf:5: Invalid parameter 'id'
I don't see any "id" in my config. Is it broken? Do we need to
update the wiki?
> + error_setg(errp, QERR_INVALID_PARAMETER, unrecognized->key);
FYI about QERR_INVALID_PARAMETER in "qapi/qmp/qerror.h":
/*
* These macros will go away, please don't use in new code, and do not
* add new ones!
*/
> + qemu_opts_del(opts);
> + }
> +}
next prev parent reply other threads:[~2021-06-09 11:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-24 10:57 [PATCH v4 0/3] vl: add -object support back into -readconfig Paolo Bonzini
2021-05-24 10:57 ` [PATCH v4 1/3] qemu-config: parse configuration files to a QDict Paolo Bonzini
2021-06-09 11:37 ` Philippe Mathieu-Daudé [this message]
2021-05-24 10:57 ` [PATCH v4 2/3] vl: plumb keyval-based options into -readconfig Paolo Bonzini
2021-05-24 10:57 ` [PATCH v4 3/3] vl: plug -object back " Paolo Bonzini
2021-06-08 13:14 ` [PATCH v4 0/3] vl: add -object support " Markus Armbruster
2021-06-09 12:40 ` Paolo Bonzini
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=7728cf1b-76c8-c39e-4e60-e7f25416d920@redhat.com \
--to=philmd@redhat.com \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@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).