mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-10 02:54:58 -06:00
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>
This commit is contained in:
parent
68192a5ffd
commit
8934643a0e
5 changed files with 24 additions and 17 deletions
|
@ -130,14 +130,15 @@ static void x86_cpu_to_dict_full(X86CPU *cpu, QDict *props)
|
|||
}
|
||||
}
|
||||
|
||||
static void object_apply_props(Object *obj, QObject *props, Error **errp)
|
||||
static void object_apply_props(Object *obj, QObject *props,
|
||||
const char *props_arg_name, Error **errp)
|
||||
{
|
||||
Visitor *visitor;
|
||||
QDict *qdict;
|
||||
const QDictEntry *prop;
|
||||
|
||||
visitor = qobject_input_visitor_new(props);
|
||||
if (!visit_start_struct(visitor, "props", NULL, 0, errp)) {
|
||||
if (!visit_start_struct(visitor, props_arg_name, NULL, 0, errp)) {
|
||||
visit_free(visitor);
|
||||
return;
|
||||
}
|
||||
|
@ -158,7 +159,7 @@ out:
|
|||
|
||||
/* Create X86CPU object according to model+props specification */
|
||||
static X86CPU *x86_cpu_from_model(const char *model, QObject *props,
|
||||
Error **errp)
|
||||
const char *props_arg_name, Error **errp)
|
||||
{
|
||||
X86CPU *xc = NULL;
|
||||
X86CPUClass *xcc;
|
||||
|
@ -172,7 +173,7 @@ static X86CPU *x86_cpu_from_model(const char *model, QObject *props,
|
|||
|
||||
xc = X86_CPU(object_new_with_class(OBJECT_CLASS(xcc)));
|
||||
if (props) {
|
||||
object_apply_props(OBJECT(xc), props, &err);
|
||||
object_apply_props(OBJECT(xc), props, props_arg_name, &err);
|
||||
if (err) {
|
||||
goto out;
|
||||
}
|
||||
|
@ -203,7 +204,7 @@ qmp_query_cpu_model_expansion(CpuModelExpansionType type,
|
|||
QDict *props = NULL;
|
||||
const char *base_name;
|
||||
|
||||
xc = x86_cpu_from_model(model->name, model->props, &err);
|
||||
xc = x86_cpu_from_model(model->name, model->props, "model.props", &err);
|
||||
if (err) {
|
||||
goto out;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue