aboutsummaryrefslogtreecommitdiff
path: root/target/s390x
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2024-03-05 15:59:15 +0100
committerMarkus Armbruster <armbru@redhat.com>2024-03-12 13:54:01 +0100
commitef6783d3f7d06cf185971afbb30ff35209e9db49 (patch)
tree68d527ae4a59964330e76b1b615c57fab6c65e1a /target/s390x
parent05ec974671200814fa5c1d5db710e0e4b88a40af (diff)
downloadqemu-ef6783d3f7d06cf185971afbb30ff35209e9db49.zip
qemu-ef6783d3f7d06cf185971afbb30ff35209e9db49.tar.gz
qemu-ef6783d3f7d06cf185971afbb30ff35209e9db49.tar.bz2
target: Simplify type checks for CpuModelInfo member @props
CpuModelInfo member @props is semantically a mapping from name to value, and syntactically a JSON object on the wire. This translates to QDict in C. Since the QAPI schema language lacks the means to express 'object', we use 'any' instead. This is QObject in C. Commands taking a CpuModelInfo argument need to check the QObject is a QDict. For arm, riscv, and s390x, the code checks right before passing the QObject to visit_start_struct(). visit_start_struct() then checks again. Delete the first check. The error message for @props that are not an object changes slightly to the the message we get for this kind of type error in other contexts. Minor improvement. Additionally, error messages about members of @props now refer to 'props.prop-name' instead of just 'prop-name'. Another minor improvement. Both changes are visible in tests/qtest/arm-cpu-features.c. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240305145919.2186971-2-armbru@redhat.com> Acked-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> [Drop #include now superfluous]
Diffstat (limited to 'target/s390x')
-rw-r--r--target/s390x/cpu_models_sysemu.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/target/s390x/cpu_models_sysemu.c b/target/s390x/cpu_models_sysemu.c
index 63981bf..53bce8a 100644
--- a/target/s390x/cpu_models_sysemu.c
+++ b/target/s390x/cpu_models_sysemu.c
@@ -17,7 +17,6 @@
#include "sysemu/kvm.h"
#include "qapi/error.h"
#include "qapi/visitor.h"
-#include "qapi/qmp/qerror.h"
#include "qapi/qobject-input-visitor.h"
#include "qapi/qmp/qdict.h"
#include "qapi/qapi-commands-machine-target.h"
@@ -101,21 +100,13 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info,
Error **errp)
{
Error *err = NULL;
- const QDict *qdict = NULL;
+ const QDict *qdict;
const QDictEntry *e;
Visitor *visitor;
ObjectClass *oc;
S390CPU *cpu;
Object *obj;
- if (info->props) {
- qdict = qobject_to(QDict, info->props);
- if (!qdict) {
- error_setg(errp, QERR_INVALID_PARAMETER_TYPE, "props", "dict");
- return;
- }
- }
-
oc = cpu_class_by_name(TYPE_S390_CPU, info->name);
if (!oc) {
error_setg(errp, "The CPU definition \'%s\' is unknown.", info->name);
@@ -135,13 +126,14 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info,
return;
}
- if (qdict) {
+ if (info->props) {
visitor = qobject_input_visitor_new(info->props);
- if (!visit_start_struct(visitor, NULL, NULL, 0, errp)) {
+ if (!visit_start_struct(visitor, "props", NULL, 0, errp)) {
visit_free(visitor);
object_unref(obj);
return;
}
+ qdict = qobject_to(QDict, info->props);
for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) {
if (!object_property_set(obj, e->key, visitor, &err)) {
break;