diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2021-05-24 06:57:50 -0400 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2021-06-04 13:50:01 +0200 |
commit | 37701411397c7b7d709ae92abd347cc593940ee5 (patch) | |
tree | ad45f77b74441f22488143ba90236e207ed70c38 /include | |
parent | 4db4385a7ab6512e9af08305f5725b26c8a980ee (diff) |
qemu-config: parse configuration files to a QDict
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>
Message-Id: <20210524105752.3318299-2-pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/qemu/config-file.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/include/qemu/config-file.h b/include/qemu/config-file.h index 0500b3668d..f605423321 100644 --- a/include/qemu/config-file.h +++ b/include/qemu/config-file.h @@ -1,6 +1,8 @@ #ifndef QEMU_CONFIG_FILE_H #define QEMU_CONFIG_FILE_H +typedef void QEMUConfigCB(const char *group, QDict *qdict, void *opaque, Error **errp); + void qemu_load_module_for_opts(const char *group); QemuOptsList *qemu_find_opts(const char *group); QemuOptsList *qemu_find_opts_err(const char *group, Error **errp); @@ -14,7 +16,10 @@ void qemu_config_write(FILE *fp); int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname, Error **errp); -int qemu_read_config_file(const char *filename, Error **errp); +/* A default callback for qemu_read_config_file(). */ +void qemu_config_do_parse(const char *group, QDict *qdict, void *opaque, Error **errp); + +int qemu_read_config_file(const char *filename, QEMUConfigCB *f, Error **errp); /* Parse QDict options as a replacement for a config file (allowing multiple enumerated (0..(n-1)) configuration "sections") */ |