@@ -157,7 +157,7 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,
Error *err = NULL;
visitor = qobject_input_visitor_new(model->props);
- if (!visit_start_struct(visitor, "props", NULL, 0, errp)) {
+ if (!visit_start_struct(visitor, "model.props", NULL, 0, errp)) {
visit_free(visitor);
object_unref(obj);
return NULL;
@@ -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;
}
@@ -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);
@@ -97,7 +97,7 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
}
static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info,
- Error **errp)
+ const char *info_arg_name, Error **errp)
{
Error *err = NULL;
const QDict *qdict;
@@ -127,8 +127,11 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info,
}
if (info->props) {
+ g_autofree const char *props_name = g_strdup_printf("%s.props",
+ info_arg_name);
+
visitor = qobject_input_visitor_new(info->props);
- if (!visit_start_struct(visitor, "props", NULL, 0, errp)) {
+ if (!visit_start_struct(visitor, props_name, NULL, 0, errp)) {
visit_free(visitor);
object_unref(obj);
return;
@@ -215,7 +218,7 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,
bool delta_changes = false;
/* convert it to our internal representation */
- cpu_model_from_info(&s390_model, model, &err);
+ cpu_model_from_info(&s390_model, model, "model", &err);
if (err) {
error_propagate(errp, err);
return NULL;
@@ -253,12 +256,12 @@ CpuModelCompareInfo *qmp_query_cpu_model_comparison(CpuModelInfo *infoa,
S390CPUModel modela, modelb;
/* convert both models to our internal representation */
- cpu_model_from_info(&modela, infoa, &err);
+ cpu_model_from_info(&modela, infoa, "modela", &err);
if (err) {
error_propagate(errp, err);
return NULL;
}
- cpu_model_from_info(&modelb, infob, &err);
+ cpu_model_from_info(&modelb, infob, "modelb", &err);
if (err) {
error_propagate(errp, err);
return NULL;
@@ -330,13 +333,13 @@ CpuModelBaselineInfo *qmp_query_cpu_model_baseline(CpuModelInfo *infoa,
uint8_t max_gen;
/* convert both models to our internal representation */
- cpu_model_from_info(&modela, infoa, &err);
+ cpu_model_from_info(&modela, infoa, "modela", &err);
if (err) {
error_propagate(errp, err);
return NULL;
}
- cpu_model_from_info(&modelb, infob, &err);
+ cpu_model_from_info(&modelb, infob, "modelb", &err);
if (err) {
error_propagate(errp, err);
return NULL;
@@ -213,7 +213,8 @@ static void assert_bad_props(QTestState *qts, const char *cpu_type)
error = resp_get_error(resp);
g_assert(error);
g_assert_cmpstr(error, ==,
- "Invalid parameter type for 'props', expected: object");
+ "Invalid parameter type for 'model.props',"
+ " expected: object");
qobject_unref(resp);
}
@@ -446,7 +447,7 @@ static void test_query_cpu_model_expansion(const void *data)
assert_bad_props(qts, "max");
assert_error(qts, "foo", "The CPU type 'foo' is not a recognized "
"ARM CPU type", NULL);
- assert_error(qts, "max", "Parameter 'props.not-a-prop' is unexpected",
+ assert_error(qts, "max", "Parameter 'model.props.not-a-prop' is unexpected",
"{ 'not-a-prop': false }");
assert_error(qts, "host", "The CPU type 'host' requires KVM", NULL);