From: Kevin Wolf <kwolf@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-stable@nongnu.org, qemu-devel@nongnu.org, armbru@redhat.com
Subject: Re: [PATCH v3 1/3] qemu-config: parse configuration files to a QDict
Date: Fri, 21 May 2021 18:09:09 +0200 [thread overview]
Message-ID: <YKfbJZVb22MoZXU3@merkur.fritz.box> (raw)
In-Reply-To: <20210521102104.3271053-2-pbonzini@redhat.com>
Am 21.05.2021 um 12:21 hat Paolo Bonzini geschrieben:
> 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: fix error propagation
> +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;
> + }
> + qemu_opts_absorb_qdict(opts, qdict, errp);
> + if (errp) {
This doesn't do what you wanted.
*errp would be be better, but you also need ERRP_GUARD() then.
The other option would be using the return value of
qemu_opts_absorb_qdict().
> + return;
> + }
> + unrecognized = qdict_first(qdict);
> + if (unrecognized) {
> + error_setg(errp, QERR_INVALID_PARAMETER, unrecognized->key);
> + qemu_opts_del(opts);
> + }
> +}
Kevin
next prev parent reply other threads:[~2021-05-21 16:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-21 10:21 [PATCH v3 0/3] vl: add -object support back into -readconfig Paolo Bonzini
2021-05-21 10:21 ` [PATCH v3 1/3] qemu-config: parse configuration files to a QDict Paolo Bonzini
2021-05-21 16:09 ` Kevin Wolf [this message]
2021-05-21 16:42 ` Paolo Bonzini
2021-05-21 10:21 ` [PATCH v3 2/3] vl: plumb keyval-based options into -readconfig Paolo Bonzini
2021-05-21 10:21 ` [PATCH v3 3/3] vl: plug -object back " 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=YKfbJZVb22MoZXU3@merkur.fritz.box \
--to=kwolf@redhat.com \
--cc=armbru@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).