From: Markus Armbruster <armbru@redhat.com>
To: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>,
Eric Blake <eblake@redhat.com>,
qemu-devel@nongnu.org,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [PATCH 4/5] qapi: introduce x-query-registers QMP command
Date: Thu, 09 Sep 2021 11:05:20 +0200 [thread overview]
Message-ID: <87czpinmpb.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20210908103711.683940-5-berrange@redhat.com> ("Daniel P. Berrangé"'s message of "Wed, 8 Sep 2021 11:37:10 +0100")
Daniel P. Berrangé <berrange@redhat.com> writes:
> This is a counterpart to the HMP "info registers" command. It is being
> added with an "x-" prefix because this QMP command is intended as an
> adhoc debugging tool and will thus not be modelled in QAPI as fully
> structured data, nor will it have long term guaranteed stability.
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
> hw/core/machine-qmp-cmds.c | 28 ++++++++++++++++++++++++++++
> qapi/machine.json | 37 +++++++++++++++++++++++++++++++++++++
> 2 files changed, 65 insertions(+)
>
> diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
> index 216fdfaf3a..0d9943ff60 100644
> --- a/hw/core/machine-qmp-cmds.c
> +++ b/hw/core/machine-qmp-cmds.c
> @@ -204,3 +204,31 @@ MemdevList *qmp_query_memdev(Error **errp)
> object_child_foreach(obj, query_memdev, &list);
> return list;
> }
> +
> +RegisterInfo *qmp_x_query_registers(bool has_cpu, int64_t cpu, Error **errp)
> +{
> + RegisterInfo *info = g_new0(RegisterInfo, 1);
> + g_autoptr(GString) buf = g_string_new("");
> + CPUState *cs = NULL, *tmp;
> +
> + if (has_cpu) {
> + CPU_FOREACH(tmp) {
> + if (cpu == tmp->cpu_index) {
> + cs = tmp;
> + }
> + }
> + if (!cs) {
> + error_setg(errp, "CPU %"PRId64" not available", cpu);
> + return NULL;
> + }
> + cpu_format_state(cs, buf, CPU_DUMP_FPU);
> + } else {
> + CPU_FOREACH(cs) {
> + g_string_append_printf(buf, "\nCPU#%d\n", cs->cpu_index);
> + cpu_format_state(cs, buf, CPU_DUMP_FPU);
> + }
> + }
> +
> + info->state = g_steal_pointer(&buf->str);
> + return info;
> +}
> diff --git a/qapi/machine.json b/qapi/machine.json
> index 157712f006..27b922f2ce 100644
> --- a/qapi/machine.json
> +++ b/qapi/machine.json
> @@ -1312,3 +1312,40 @@
> '*cores': 'int',
> '*threads': 'int',
> '*maxcpus': 'int' } }
> +
> +##
> +# @RegisterParams:
> +#
> +# Information about the CPU to query state of
> +#
> +# @cpu: the CPU number to query. If omitted, queries all CPUs
> +#
> +# Since: 6.2.0
> +#
> +##
> +{ 'struct': 'RegisterParams', 'data': {'*cpu': 'int' } }
> +
> +##
> +# @RegisterInfo:
> +#
> +# Information about the CPU state
> +#
> +# @state: the CPU state in an architecture specific format
> +#
> +# Since: 6.2.0
> +#
> +##
> +{ 'struct': 'RegisterInfo', 'data': {'state': 'str' } }
> +
> +##
> +# @x-query-registers:
> +#
> +# Return information on the CPU registers
> +#
> +# Returns: the CPU state
> +#
> +# Since: 6.2.0
> +##
> +{ 'command': 'x-query-registers',
> + 'data': 'RegisterParams',
Unless you have further uses of RegisterParams in mind, use an implicit
type:
'data': { '*cpu': 'int' } }
> + 'returns': 'RegisterInfo' }
I'd like us to adopt a convention for commands returning formatted text
for human consumption. Like so:
'returns': 'HumanReadableText' }
with the obvious
##
# @HumanReadableText:
#
# @human-readable-text: Formatted output intended for humans.
#
# Since: 6.2.0
##
{ 'struct': 'HumanReadableText',
'data': { 'human-readable-text': 'str' } }
When the output needs explaining, do that in the command's doc string.
I figure
##
# @x-query-registers:
#
# Returns information about the CPU state
#
# Returns: CPU state in an architecture-specific format
#
# Since: 6.2.0
##
would do in this case.
next prev parent reply other threads:[~2021-09-09 9:06 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-08 10:37 [PATCH 0/5] Stop adding HMP-only commands, allow QMP for all Daniel P. Berrangé
2021-09-08 10:37 ` [PATCH 1/5] docs/devel: document expectations for QAPI data modelling for QMP Daniel P. Berrangé
2021-09-08 17:42 ` Eric Blake
2021-09-09 9:33 ` Markus Armbruster
2021-09-10 12:46 ` Daniel P. Berrangé
2021-09-10 13:45 ` Markus Armbruster
2021-09-10 13:52 ` Daniel P. Berrangé
2021-09-08 10:37 ` [PATCH 2/5] hw/core: introduce 'format_state' callback to replace 'dump_state' Daniel P. Berrangé
2021-09-08 10:37 ` [PATCH 3/5] target/i386: convert to use format_state instead of dump_state Daniel P. Berrangé
2021-09-08 12:17 ` Ján Tomko
2021-09-08 18:05 ` Eric Blake
2021-09-08 22:06 ` Daniel P. Berrangé
2021-09-09 9:55 ` Daniel P. Berrangé
2021-09-08 10:37 ` [PATCH 4/5] qapi: introduce x-query-registers QMP command Daniel P. Berrangé
2021-09-08 18:06 ` Eric Blake
2021-09-09 9:05 ` Markus Armbruster [this message]
2021-09-09 10:01 ` Daniel P. Berrangé
2021-09-08 10:37 ` [PATCH 5/5] monitor: rewrite 'info registers' in terms of 'x-query-registers' Daniel P. Berrangé
2021-09-08 11:01 ` Philippe Mathieu-Daudé
2021-09-08 11:02 ` Daniel P. Berrangé
2021-09-08 12:18 ` [PATCH 0/5] Stop adding HMP-only commands, allow QMP for all Ján Tomko
2021-09-08 15:09 ` Markus Armbruster
2021-09-08 15:24 ` Daniel P. Berrangé
2021-09-09 4:48 ` Markus Armbruster
2021-09-09 8:13 ` Markus Armbruster
2021-09-09 8:40 ` Daniel P. Berrangé
2021-09-08 16:15 ` Philippe Mathieu-Daudé
2021-09-09 6:15 ` Paolo Bonzini
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=87czpinmpb.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=ehabkost@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.