[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 28/45] qemu-option: pass QemuOptsList to opts_accepts_any
From: |
Paolo Bonzini |
Subject: |
[PULL 28/45] qemu-option: pass QemuOptsList to opts_accepts_any |
Date: |
Tue, 15 Dec 2020 12:54:28 -0500 |
A QemuOptsList can be of one of two kinds: either it is pre-validated, or
it accepts any key and validation happens somewhere else (typically in
a Visitor or against a list of QOM properties). opts_accepts_any
returns true if a QemuOpts instance was created from a QemuOptsList of
the latter kind, but there is no function to do the check on a QemuOptsList.
Since this property comes from the QemuOptsList and almost all callers of
opts_accepts_any use opts->list anyway, modify the function to accept
QemuOptsList.
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
util/qemu-option.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/util/qemu-option.c b/util/qemu-option.c
index 6bd654a473..c88e159f18 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -460,16 +460,16 @@ static bool qemu_opt_parse(QemuOpt *opt, Error **errp)
}
}
-static bool opts_accepts_any(const QemuOpts *opts)
+static bool opts_accepts_any(const QemuOptsList *list)
{
- return opts->list->desc[0].name == NULL;
+ return list->desc[0].name == NULL;
}
int qemu_opt_unset(QemuOpts *opts, const char *name)
{
QemuOpt *opt = qemu_opt_find(opts, name);
- assert(opts_accepts_any(opts));
+ assert(opts_accepts_any(opts->list));
if (opt == NULL) {
return -1;
@@ -500,9 +500,10 @@ static bool opt_validate(QemuOpt *opt, bool *help_wanted,
Error **errp)
{
const QemuOptDesc *desc;
+ const QemuOptsList *list = opt->opts->list;
- desc = find_desc_by_name(opt->opts->list->desc, opt->name);
- if (!desc && !opts_accepts_any(opt->opts)) {
+ desc = find_desc_by_name(list->desc, opt->name);
+ if (!desc && !opts_accepts_any(list)) {
error_setg(errp, QERR_INVALID_PARAMETER, opt->name);
if (help_wanted && is_help_option(opt->name)) {
*help_wanted = true;
@@ -535,9 +536,10 @@ bool qemu_opt_set_bool(QemuOpts *opts, const char *name,
bool val,
{
QemuOpt *opt;
const QemuOptDesc *desc;
+ const QemuOptsList *list = opts->list;
- desc = find_desc_by_name(opts->list->desc, name);
- if (!desc && !opts_accepts_any(opts)) {
+ desc = find_desc_by_name(list->desc, name);
+ if (!desc && !opts_accepts_any(list)) {
error_setg(errp, QERR_INVALID_PARAMETER, name);
return false;
}
@@ -557,9 +559,10 @@ bool qemu_opt_set_number(QemuOpts *opts, const char *name,
int64_t val,
{
QemuOpt *opt;
const QemuOptDesc *desc;
+ const QemuOptsList *list = opts->list;
- desc = find_desc_by_name(opts->list->desc, name);
- if (!desc && !opts_accepts_any(opts)) {
+ desc = find_desc_by_name(list->desc, name);
+ if (!desc && !opts_accepts_any(list)) {
error_setg(errp, QERR_INVALID_PARAMETER, name);
return false;
}
@@ -1107,7 +1110,7 @@ bool qemu_opts_validate(QemuOpts *opts, const QemuOptDesc
*desc, Error **errp)
{
QemuOpt *opt;
- assert(opts_accepts_any(opts));
+ assert(opts_accepts_any(opts->list));
QTAILQ_FOREACH(opt, &opts->head, next) {
opt->desc = find_desc_by_name(desc, opt->name);
--
2.26.2
- [PULL 18/45] msix: assert that accesses are within bounds, (continued)
- [PULL 18/45] msix: assert that accesses are within bounds, Paolo Bonzini, 2020/12/15
- [PULL 22/45] Remove the deprecated -realtime option, Paolo Bonzini, 2020/12/15
- [PULL 26/45] kvm: Take into account the unaligned section size when preparing bitmap, Paolo Bonzini, 2020/12/15
- [PULL 25/45] scsi: fix device removal race vs IO restart callback on resume, Paolo Bonzini, 2020/12/15
- [PULL 27/45] qemu-option: simplify search for end of key, Paolo Bonzini, 2020/12/15
- [PULL 36/45] tests: remove GCC < 4 fallbacks, Paolo Bonzini, 2020/12/15
- [PULL 32/45] qemu/atomic: Drop special case for unsupported compiler, Paolo Bonzini, 2020/12/15
- [PULL 35/45] qemu-plugin.h: remove GCC < 4, Paolo Bonzini, 2020/12/15
- [PULL 42/45] linux-user: remove GNUC check, Paolo Bonzini, 2020/12/15
- [PULL 20/45] accel/tcg: Remove deprecated '-tb-size' option, Paolo Bonzini, 2020/12/15
- [PULL 28/45] qemu-option: pass QemuOptsList to opts_accepts_any,
Paolo Bonzini <=
- [PULL 24/45] icount: improve exec nocache usage, Paolo Bonzini, 2020/12/15
- [PULL 29/45] vl: rename local variable in configure_accelerators, Paolo Bonzini, 2020/12/15
- [PULL 31/45] hw/core: Restrict 'fw-path-provider.c' to system mode emulation, Paolo Bonzini, 2020/12/15
- [PULL 33/45] accel/tcg: Remove special case for GCC < 4.6, Paolo Bonzini, 2020/12/15
- [PULL 30/45] docs: set CONFDIR when running sphinx, Paolo Bonzini, 2020/12/15
- [PULL 37/45] virtiofsd: replace _Static_assert with QEMU_BUILD_BUG_ON, Paolo Bonzini, 2020/12/15
- [PULL 34/45] compiler.h: remove GCC < 3 __builtin_expect fallback, Paolo Bonzini, 2020/12/15
- [PULL 39/45] poison: remove GNUC check, Paolo Bonzini, 2020/12/15
- [PULL 38/45] compiler.h: explicit case for Clang printf attribute, Paolo Bonzini, 2020/12/15
- [PULL 41/45] compiler: remove GNUC check, Paolo Bonzini, 2020/12/15