From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
"Dr. David Alan Gilbert" <dave@treblig.org>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Harsh Prateek Bora" <harshpb@linux.ibm.com>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Laurent Vivier" <laurent@vivier.eu>,
"David Gibson" <david@gibson.dropbear.id.au>,
"Daniel P . Berrangé" <berrange@redhat.com>,
"Daniel Henrique Barboza" <danielhb413@gmail.com>,
"Eric Blake" <eblake@redhat.com>,
"Yanan Wang" <wangyanan55@huawei.com>,
"Cédric Le Goater" <clg@kaod.org>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Don Porter" <porter@cs.unc.edu>,
"Frédéric Barrat" <fbarrat@linux.ibm.com>,
qemu-ppc@nongnu.org, "Markus Armbruster" <armbru@redhat.com>
Subject: [PATCH 2/2] hw/intc: Introduce x-query-interrupt-controllers QMP command
Date: Mon, 10 Jun 2024 08:35:17 +0200 [thread overview]
Message-ID: <20240610063518.50680-3-philmd@linaro.org> (raw)
In-Reply-To: <20240610063518.50680-1-philmd@linaro.org>
This is a counterpart to the HMP "info pic" 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.
The existing HMP command is rewritten to call the QMP command.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
qapi/machine.json | 17 +++++++++++++++++
hw/core/machine-qmp-cmds.c | 29 +++++++++++++++++++++++++++++
monitor/hmp-cmds.c | 33 ---------------------------------
hmp-commands-info.hx | 2 +-
4 files changed, 47 insertions(+), 34 deletions(-)
diff --git a/qapi/machine.json b/qapi/machine.json
index 453feb9347..1283d14493 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -1864,3 +1864,20 @@
{ 'command': 'dumpdtb',
'data': { 'filename': 'str' },
'if': 'CONFIG_FDT' }
+
+##
+# @x-query-interrupt-controllers:
+#
+# Query information on interrupt controller devices
+#
+# Features:
+#
+# @unstable: This command is meant for debugging.
+#
+# Returns: Interrupt controller device information
+#
+# Since: 9.1
+##
+{ 'command': 'x-query-interrupt-controllers',
+ 'returns': 'HumanReadableText',
+ 'features': [ 'unstable' ]}
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index 5972100b1f..130217da8f 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -361,6 +361,35 @@ HumanReadableText *qmp_x_query_irq(Error **errp)
return human_readable_text_from_str(buf);
}
+static int qmp_x_query_intc_foreach(Object *obj, void *opaque)
+{
+ InterruptStatsProvider *intc;
+ InterruptStatsProviderClass *k;
+ GString *buf = opaque;
+
+ if (object_dynamic_cast(obj, TYPE_INTERRUPT_STATS_PROVIDER)) {
+ intc = INTERRUPT_STATS_PROVIDER(obj);
+ k = INTERRUPT_STATS_PROVIDER_GET_CLASS(obj);
+ if (k->print_info) {
+ k->print_info(intc, buf);
+ } else {
+ g_string_append_printf(buf,
+ "Interrupt controller information not available for %s.\n",
+ object_get_typename(obj));
+ }
+ }
+
+ return 0;
+}
+
+HumanReadableText *qmp_x_query_interrupt_controllers(Error **errp)
+{
+ g_autoptr(GString) buf = g_string_new("");
+ object_child_foreach_recursive(object_get_root(),
+ qmp_x_query_intc_foreach, buf);
+ return human_readable_text_from_str(buf);
+}
+
GuidInfo *qmp_query_vm_generation_id(Error **errp)
{
GuidInfo *info;
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index fbff7fdb57..45ee3a9e1f 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -25,9 +25,7 @@
#include "qapi/qapi-commands-machine.h"
#include "qapi/qapi-commands-misc.h"
#include "qapi/qmp/qdict.h"
-#include "qapi/type-helpers.h"
#include "qemu/cutils.h"
-#include "hw/intc/intc.h"
#include "qemu/log.h"
#include "sysemu/sysemu.h"
@@ -83,37 +81,6 @@ void hmp_info_version(Monitor *mon, const QDict *qdict)
qapi_free_VersionInfo(info);
}
-static int hmp_info_pic_foreach(Object *obj, void *opaque)
-{
- InterruptStatsProvider *intc;
- InterruptStatsProviderClass *k;
- Monitor *mon = opaque;
-
- if (object_dynamic_cast(obj, TYPE_INTERRUPT_STATS_PROVIDER)) {
- intc = INTERRUPT_STATS_PROVIDER(obj);
- k = INTERRUPT_STATS_PROVIDER_GET_CLASS(obj);
- if (k->print_info) {
- g_autoptr(GString) buf = g_string_new("");
- g_autoptr(HumanReadableText) info = NULL;
-
- k->print_info(intc, buf);
- info = human_readable_text_from_str(buf);
- monitor_puts(mon, info->human_readable_text);
- } else {
- monitor_printf(mon, "Interrupt controller information not available for %s.\n",
- object_get_typename(obj));
- }
- }
-
- return 0;
-}
-
-void hmp_info_pic(Monitor *mon, const QDict *qdict)
-{
- object_child_foreach_recursive(object_get_root(),
- hmp_info_pic_foreach, mon);
-}
-
void hmp_quit(Monitor *mon, const QDict *qdict)
{
monitor_suspend(mon);
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index 20a9835ea8..cfd4ad5651 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -174,7 +174,7 @@ ERST
.args_type = "",
.params = "",
.help = "show PIC state",
- .cmd = hmp_info_pic,
+ .cmd_info_hrt = qmp_x_query_interrupt_controllers,
},
SRST
--
2.41.0
next prev parent reply other threads:[~2024-06-10 6:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-10 6:35 [PATCH 0/2] hw/intc: Introduce x-query-interrupt-controllers QMP command Philippe Mathieu-Daudé
2024-06-10 6:35 ` [PATCH 1/2] hw/intc: Avoid using Monitor in INTERRUPT_STATS_PROVIDER::print_info() Philippe Mathieu-Daudé
2024-06-10 8:35 ` Daniel P. Berrangé
2024-06-10 6:35 ` Philippe Mathieu-Daudé [this message]
2024-06-10 8:35 ` [PATCH 2/2] hw/intc: Introduce x-query-interrupt-controllers QMP command Daniel P. Berrangé
2024-06-18 11:00 ` [PATCH 0/2] " Philippe Mathieu-Daudé
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=20240610063518.50680-3-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=clg@kaod.org \
--cc=danielhb413@gmail.com \
--cc=dave@treblig.org \
--cc=david@gibson.dropbear.id.au \
--cc=eblake@redhat.com \
--cc=eduardo@habkost.net \
--cc=fbarrat@linux.ibm.com \
--cc=harshpb@linux.ibm.com \
--cc=laurent@vivier.eu \
--cc=marcel.apfelbaum@gmail.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mst@redhat.com \
--cc=npiggin@gmail.com \
--cc=pbonzini@redhat.com \
--cc=porter@cs.unc.edu \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=wangyanan55@huawei.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).