[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 17/19] qapi: introduce x-query-irq QMP command
From: |
Daniel P . Berrangé |
Subject: |
[PATCH v3 17/19] qapi: introduce x-query-irq QMP command |
Date: |
Thu, 30 Sep 2021 14:23:47 +0100 |
This is a counterpart to the HMP "info irq" 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.
This command is unable to use the pre-existing HumanReadableText,
because if 'common.json' is included into 'machine-target.json'
the static marshalling method for HumanReadableText will be reported
as unused by the compiler on all architectures except s390x.
Possible options were
1 Support 'if' conditionals on 'include' statements in QAPI
2 Add further commands to 'machine-target.json' that use
HumanReadableText, such that it has at least one usage
on all architecture targets.
3 Duplicate HumanReadableText as TargetHumanReadableText
adding conditions
This patch takes option (3) in the belief that we will eventually
get to a point where option (2) happens, and TargetHumanReadableText
can be removed again.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
monitor/hmp-cmds.c | 40 ++++++++--------------------------------
monitor/qmp-cmds.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
qapi/machine.json | 12 ++++++++++++
3 files changed, 64 insertions(+), 32 deletions(-)
diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c
index 2d09a01599..2df1136e21 100644
--- a/monitor/hmp-cmds.c
+++ b/monitor/hmp-cmds.c
@@ -784,42 +784,18 @@ static void hmp_info_pci_device(Monitor *mon, const
PciDeviceInfo *dev)
}
}
-static int hmp_info_irq_foreach(Object *obj, void *opaque)
+void hmp_info_irq(Monitor *mon, const QDict *qdict)
{
- InterruptStatsProvider *intc;
- InterruptStatsProviderClass *k;
- Monitor *mon = opaque;
+ Error *err = NULL;
+ g_autoptr(HumanReadableText) info = NULL;
- if (object_dynamic_cast(obj, TYPE_INTERRUPT_STATS_PROVIDER)) {
- intc = INTERRUPT_STATS_PROVIDER(obj);
- k = INTERRUPT_STATS_PROVIDER_GET_CLASS(obj);
- uint64_t *irq_counts;
- unsigned int nb_irqs, i;
- if (k->get_statistics &&
- k->get_statistics(intc, &irq_counts, &nb_irqs)) {
- if (nb_irqs > 0) {
- monitor_printf(mon, "IRQ statistics for %s:\n",
- object_get_typename(obj));
- for (i = 0; i < nb_irqs; i++) {
- if (irq_counts[i] > 0) {
- monitor_printf(mon, "%2d: %" PRId64 "\n", i,
- irq_counts[i]);
- }
- }
- }
- } else {
- monitor_printf(mon, "IRQ statistics not available for %s.\n",
- object_get_typename(obj));
- }
+ info = qmp_x_query_irq(&err);
+ if (err) {
+ error_report_err(err);
+ return;
}
- return 0;
-}
-
-void hmp_info_irq(Monitor *mon, const QDict *qdict)
-{
- object_child_foreach_recursive(object_get_root(),
- hmp_info_irq_foreach, mon);
+ monitor_printf(mon, "%s", info->human_readable_text);
}
static int hmp_info_pic_foreach(Object *obj, void *opaque)
diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
index a9766fa38d..343353e27a 100644
--- a/monitor/qmp-cmds.c
+++ b/monitor/qmp-cmds.c
@@ -41,6 +41,7 @@
#include "exec/ramlist.h"
#include "hw/mem/memory-device.h"
#include "hw/acpi/acpi_dev_interface.h"
+#include "hw/intc/intc.h"
#include "hw/rdma/rdma.h"
NameInfo *qmp_query_name(Error **errp)
@@ -422,3 +423,46 @@ HumanReadableText *qmp_x_query_ramblock(Error **errp)
return human_readable_text_from_str(buf);
}
+
+static int qmp_x_query_irq_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);
+ uint64_t *irq_counts;
+ unsigned int nb_irqs, i;
+ if (k->get_statistics &&
+ k->get_statistics(intc, &irq_counts, &nb_irqs)) {
+ if (nb_irqs > 0) {
+ g_string_append_printf(buf, "IRQ statistics for %s:\n",
+ object_get_typename(obj));
+ for (i = 0; i < nb_irqs; i++) {
+ if (irq_counts[i] > 0) {
+ g_string_append_printf(buf, "%2d: %" PRId64 "\n", i,
+ irq_counts[i]);
+ }
+ }
+ }
+ } else {
+ g_string_append_printf(buf,
+ "IRQ statistics not available for %s.\n",
+ object_get_typename(obj));
+ }
+ }
+
+ return 0;
+}
+
+HumanReadableText *qmp_x_query_irq(Error **errp)
+{
+ g_autoptr(GString) buf = g_string_new("");
+
+ object_child_foreach_recursive(object_get_root(),
+ qmp_x_query_irq_foreach, buf);
+
+ return human_readable_text_from_str(buf);
+}
diff --git a/qapi/machine.json b/qapi/machine.json
index 340ab57f60..31eafe2fc4 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -1347,6 +1347,18 @@
'*threads': 'int',
'*maxcpus': 'int' } }
+##
+# @x-query-irq:
+#
+# Query interrupt statistics
+#
+# Returns: interrupt statistics
+#
+# Since: 6.2
+##
+{ 'command': 'x-query-irq',
+ 'returns': 'HumanReadableText' }
+
##
# @x-query-numa:
#
--
2.31.1
- [PATCH v3 07/19] qapi: introduce x-query-roms QMP command, (continued)
- [PATCH v3 07/19] qapi: introduce x-query-roms QMP command, Daniel P . Berrangé, 2021/09/30
- [PATCH v3 08/19] qapi: introduce x-query-profile QMP command, Daniel P . Berrangé, 2021/09/30
- [PATCH v3 09/19] qapi: introduce x-query-numa QMP command, Daniel P . Berrangé, 2021/09/30
- [PATCH v3 10/19] qapi: introduce x-query-usb QMP command, Daniel P . Berrangé, 2021/09/30
- [PATCH v3 11/19] qapi: introduce x-query-rdma QMP command, Daniel P . Berrangé, 2021/09/30
- [PATCH v3 12/19] qapi: introduce x-query-ramblock QMP command, Daniel P . Berrangé, 2021/09/30
- [PATCH v3 13/19] qapi: introduce x-query-skeys QMP command, Daniel P . Berrangé, 2021/09/30
- [PATCH v3 14/19] qapi: introduce x-query-cmma QMP command, Daniel P . Berrangé, 2021/09/30
- [PATCH v3 15/19] hmp: synchronize cpu state for lapic info, Daniel P . Berrangé, 2021/09/30
- [PATCH v3 16/19] qapi: introduce x-query-lapic QMP command, Daniel P . Berrangé, 2021/09/30
- [PATCH v3 17/19] qapi: introduce x-query-irq QMP command,
Daniel P . Berrangé <=
- [PATCH v3 18/19] qapi: introduce x-query-jit QMP command, Daniel P . Berrangé, 2021/09/30
- [PATCH v3 19/19] qapi: introduce x-query-opcount QMP command, Daniel P . Berrangé, 2021/09/30