target/i386: Fix query-cpu-model-expansion to reject props
commit68192a5ffd00e4b5123b86fe93986d03ff066c68
authorMarkus Armbruster <armbru@redhat.com>
Tue, 5 Mar 2024 14:59:16 +0000 (5 15:59 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Tue, 12 Mar 2024 13:02:46 +0000 (12 14:02 +0100)
tree7939800d27eb7e25094a5c1bcee99f41427801e4
parentef6783d3f7d06cf185971afbb30ff35209e9db49
target/i386: Fix query-cpu-model-expansion to reject 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.

The i386 version of qmp_query_cpu_model_expansion() fails to check.
Instead, @props is silently ignored when it's not an object.  For
instance,

    {"execute": "query-cpu-model-expansion", "arguments": {"type": "full", "model": {"name": "qemu64", "props": null}}}

succeeds.

Fix by refactoring the code to match the other targets.  Now the
command fails as it should:

    {"error": {"class": "GenericError", "desc": "Invalid parameter type for 'props', expected: object"}}

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20240305145919.2186971-3-armbru@redhat.com>
target/i386/cpu-sysemu.c