From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, pbonzini@redhat.com,
gaosong@loongson.cn, palmer@dabbelt.com,
alistair.francis@wdc.com, bin.meng@windriver.com,
liwei1518@gmail.com, dbarboza@ventanamicro.com,
zhiwei_liu@linux.alibaba.com, richard.henderson@linaro.org,
david@redhat.com, iii@linux.ibm.com, thuth@redhat.com,
qemu-arm@nongnu.org, qemu-riscv@nongnu.org,
qemu-s390x@nongnu.org
Subject: [PATCH 4/4] target/loongarch: Fix query-cpu-model-expansion to reject props
Date: Tue, 5 Mar 2024 15:59:18 +0100 [thread overview]
Message-ID: <20240305145919.2186971-5-armbru@redhat.com> (raw)
In-Reply-To: <20240305145919.2186971-1-armbru@redhat.com>
query-cpu-model-expansion takes a CpuModelInfo argument. The
loongarch version of the command silently ignores the argument's
member @props. For instance,
{"execute": "query-cpu-model-expansion", "arguments": {"type": "static", "model": {"name": "la464", "props": null}}}
and
{"execute": "query-cpu-model-expansion", "arguments": {"type": "static", "model": {"name": "la464", "props": {"prop": null}}}}
succeed.
Add skeleton code for property processing that recognizes no
properties. Now the two commands fail as they should:
{"error": {"class": "GenericError", "desc": "Invalid parameter type for 'model.props', expected: object"}}
and
{"error": {"class": "GenericError", "desc": "Parameter 'model.props.prop' is unexpected"}}
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
target/loongarch/loongarch-qmp-cmds.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/target/loongarch/loongarch-qmp-cmds.c b/target/loongarch/loongarch-qmp-cmds.c
index ec33ce81f0..44d1f089b6 100644
--- a/target/loongarch/loongarch-qmp-cmds.c
+++ b/target/loongarch/loongarch-qmp-cmds.c
@@ -48,6 +48,8 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,
CpuModelInfo *model,
Error **errp)
{
+ Visitor *visitor;
+ bool ok;
CpuModelExpansionInfo *expansion_info;
QDict *qdict_out;
ObjectClass *oc;
@@ -60,6 +62,21 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,
return NULL;
}
+ if (model->props) {
+ visitor = qobject_input_visitor_new(model->props);
+ if (!visit_start_struct(visitor, "model.props", NULL, 0, errp)) {
+ visit_free(visitor);
+ return NULL;
+ }
+
+ ok = visit_check_struct(visitor, errp);
+ visit_end_struct(visitor, NULL);
+ visit_free(visitor);
+ if (!ok) {
+ return NULL;
+ }
+ }
+
oc = cpu_class_by_name(TYPE_LOONGARCH_CPU, model->name);
if (!oc) {
error_setg(errp, "The CPU type '%s' is not a recognized LoongArch CPU type",
--
2.44.0
prev parent reply other threads:[~2024-03-05 15:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-05 14:59 [PATCH 0/4] target: Improve error reporting for CpuModelInfo member @props Markus Armbruster
2024-03-05 14:59 ` [PATCH 1/4] target: Simplify type checks " Markus Armbruster
2024-03-06 13:05 ` Daniel Henrique Barboza
2024-03-05 14:59 ` [PATCH 2/4] target/i386: Fix query-cpu-model-expansion to reject props Markus Armbruster
2024-03-05 14:59 ` [PATCH 3/4] target: Improve error reporting for CpuModelInfo member @props Markus Armbruster
2024-03-06 13:05 ` Daniel Henrique Barboza
2024-03-05 14:59 ` Markus Armbruster [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240305145919.2186971-5-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=alistair.francis@wdc.com \
--cc=bin.meng@windriver.com \
--cc=david@redhat.com \
--cc=dbarboza@ventanamicro.com \
--cc=gaosong@loongson.cn \
--cc=iii@linux.ibm.com \
--cc=liwei1518@gmail.com \
--cc=palmer@dabbelt.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
--cc=zhiwei_liu@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).