diff options
author | Markus Armbruster <armbru@redhat.com> | 2024-03-05 15:59:17 +0100 |
---|---|---|
committer | Markus Armbruster <armbru@redhat.com> | 2024-03-12 14:03:00 +0100 |
commit | 8934643a0e2631d468940b05ae2332f219631d17 (patch) | |
tree | f8dc1da4c75f2d12e56e72f13c64bc5d5a66f8dc /target/riscv | |
parent | 68192a5ffd00e4b5123b86fe93986d03ff066c68 (diff) |
target: Improve error reporting for CpuModelInfo member @props
query-cpu-model-comparison, query-cpu-model-baseline, and
query-cpu-model-expansion take CpuModelInfo arguments. Errors in
@props members of these arguments are reported for 'props', without
further context. For instance, s390x rejects
{"execute": "query-cpu-model-comparison", "arguments": {"modela": {"name": "z13", "props": {}}, "modelb": {"name": "z14", "props": []}}}
with
{"error": {"class": "GenericError", "desc": "Invalid parameter type for 'props', expected: object"}}
This is unusual; the common QAPI unmarshaling machinery would complain
about 'modelb.props'. Our hand-written code to visit the @props
member neglects to provide the context.
Tweak it so it provides it. The command above now fails with
{"error": {"class": "GenericError", "desc": "Invalid parameter type for 'modelb.props', expected: dict"}}
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20240305145919.2186971-4-armbru@redhat.com>
Acked-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Diffstat (limited to 'target/riscv')
-rw-r--r-- | target/riscv/riscv-qmp-cmds.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/target/riscv/riscv-qmp-cmds.c b/target/riscv/riscv-qmp-cmds.c index d0360c0528..d363dc318d 100644 --- a/target/riscv/riscv-qmp-cmds.c +++ b/target/riscv/riscv-qmp-cmds.c @@ -128,6 +128,7 @@ static void riscv_obj_add_profiles_qdict(Object *obj, QDict *qdict_out) } static void riscv_cpuobj_validate_qdict_in(Object *obj, QObject *props, + const char *props_arg_name, Error **errp) { const QDict *qdict_in; @@ -136,7 +137,7 @@ static void riscv_cpuobj_validate_qdict_in(Object *obj, QObject *props, Error *local_err = NULL; visitor = qobject_input_visitor_new(props); - if (!visit_start_struct(visitor, "props", NULL, 0, &local_err)) { + if (!visit_start_struct(visitor, props_arg_name, NULL, 0, &local_err)) { goto err; } @@ -197,7 +198,8 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type, } if (model->props) { - riscv_cpuobj_validate_qdict_in(obj, model->props, &local_err); + riscv_cpuobj_validate_qdict_in(obj, model->props, "model.props", + &local_err); if (local_err) { error_propagate(errp, local_err); object_unref(obj); |