qemu-stable
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 1/3] qemu-config: parse configuration files to a QDict


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v4 1/3] qemu-config: parse configuration files to a QDict
Date: Wed, 9 Jun 2021 13:37:31 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1

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);
> +    }
> +}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]