[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 09/19] qapi: introduce x-query-numa QMP command
From: |
Daniel P . Berrangé |
Subject: |
[PATCH v3 09/19] qapi: introduce x-query-numa QMP command |
Date: |
Thu, 30 Sep 2021 14:23:39 +0100 |
This is a counterpart to the HMP "info numa" 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: Daniel P. Berrangé <berrange@redhat.com>
---
hw/core/machine-hmp-cmds.c | 33 +++++---------------------------
hw/core/machine-qmp-cmds.c | 39 ++++++++++++++++++++++++++++++++++++++
qapi/machine.json | 12 ++++++++++++
3 files changed, 56 insertions(+), 28 deletions(-)
diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
index 76b22b00d6..cfa01c6933 100644
--- a/hw/core/machine-hmp-cmds.c
+++ b/hw/core/machine-hmp-cmds.c
@@ -134,35 +134,12 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict)
void hmp_info_numa(Monitor *mon, const QDict *qdict)
{
- int i, nb_numa_nodes;
- NumaNodeMem *node_mem;
- CpuInfoFastList *cpu_list, *cpu;
- MachineState *ms = MACHINE(qdev_get_machine());
+ Error *err = NULL;
+ g_autoptr(HumanReadableText) info = qmp_x_query_numa(&err);
- nb_numa_nodes = ms->numa_state ? ms->numa_state->num_nodes : 0;
- monitor_printf(mon, "%d nodes\n", nb_numa_nodes);
- if (!nb_numa_nodes) {
+ if (err) {
+ error_report_err(err);
return;
}
-
- cpu_list = qmp_query_cpus_fast(&error_abort);
- node_mem = g_new0(NumaNodeMem, nb_numa_nodes);
-
- query_numa_node_mem(node_mem, ms);
- for (i = 0; i < nb_numa_nodes; i++) {
- monitor_printf(mon, "node %d cpus:", i);
- for (cpu = cpu_list; cpu; cpu = cpu->next) {
- if (cpu->value->has_props && cpu->value->props->has_node_id &&
- cpu->value->props->node_id == i) {
- monitor_printf(mon, " %" PRIi64, cpu->value->cpu_index);
- }
- }
- monitor_printf(mon, "\n");
- monitor_printf(mon, "node %d size: %" PRId64 " MB\n", i,
- node_mem[i].node_mem >> 20);
- monitor_printf(mon, "node %d plugged: %" PRId64 " MB\n", i,
- node_mem[i].node_plugged_mem >> 20);
- }
- qapi_free_CpuInfoFastList(cpu_list);
- g_free(node_mem);
+ monitor_printf(mon, "%s", info->human_readable_text);
}
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index 76f2b84d81..4f4ab30f8c 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -205,3 +205,42 @@ MemdevList *qmp_query_memdev(Error **errp)
object_child_foreach(obj, query_memdev, &list);
return list;
}
+
+HumanReadableText *qmp_x_query_numa(Error **errp)
+{
+ g_autoptr(GString) buf = g_string_new("");
+ int i, nb_numa_nodes;
+ NumaNodeMem *node_mem;
+ CpuInfoFastList *cpu_list, *cpu;
+ MachineState *ms = MACHINE(qdev_get_machine());
+
+ nb_numa_nodes = ms->numa_state ? ms->numa_state->num_nodes : 0;
+ g_string_append_printf(buf, "%d nodes\n", nb_numa_nodes);
+ if (!nb_numa_nodes) {
+ goto done;
+ }
+
+ cpu_list = qmp_query_cpus_fast(&error_abort);
+ node_mem = g_new0(NumaNodeMem, nb_numa_nodes);
+
+ query_numa_node_mem(node_mem, ms);
+ for (i = 0; i < nb_numa_nodes; i++) {
+ g_string_append_printf(buf, "node %d cpus:", i);
+ for (cpu = cpu_list; cpu; cpu = cpu->next) {
+ if (cpu->value->has_props && cpu->value->props->has_node_id &&
+ cpu->value->props->node_id == i) {
+ g_string_append_printf(buf, " %" PRIi64,
cpu->value->cpu_index);
+ }
+ }
+ g_string_append_printf(buf, "\n");
+ g_string_append_printf(buf, "node %d size: %" PRId64 " MB\n", i,
+ node_mem[i].node_mem >> 20);
+ g_string_append_printf(buf, "node %d plugged: %" PRId64 " MB\n", i,
+ node_mem[i].node_plugged_mem >> 20);
+ }
+ qapi_free_CpuInfoFastList(cpu_list);
+ g_free(node_mem);
+
+ done:
+ return human_readable_text_from_str(buf);
+}
diff --git a/qapi/machine.json b/qapi/machine.json
index db1bb9454e..c69a7ceef6 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -1347,6 +1347,18 @@
'*threads': 'int',
'*maxcpus': 'int' } }
+##
+# @x-query-numa:
+#
+# Query NUMA topology information
+#
+# Returns: topology information
+#
+# Since: 6.2
+##
+{ 'command': 'x-query-numa',
+ 'returns': 'HumanReadableText' }
+
##
# @x-query-profile:
#
--
2.31.1
- [PATCH v3 00/19] monitor: explicitly permit QMP commands to be added for all use cases, Daniel P . Berrangé, 2021/09/30
- [PATCH v3 02/19] docs/devel: tweak headings in monitor command docs, Daniel P . Berrangé, 2021/09/30
- [PATCH v3 03/19] docs/devel: document expectations for QAPI data modelling for QMP, Daniel P . Berrangé, 2021/09/30
- [PATCH v3 04/19] docs/devel: add example of command returning unstructured text, Daniel P . Berrangé, 2021/09/30
- [PATCH v3 05/19] docs/devel: document expectations for HMP commands in the future, Daniel P . Berrangé, 2021/09/30
- [PATCH v3 01/19] docs/devel: rename file for writing monitor commands, Daniel P . Berrangé, 2021/09/30
- [PATCH v3 06/19] monitor: remove 'info ioapic' HMP command, Daniel P . Berrangé, 2021/09/30
- [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é <=
- [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é, 2021/09/30
- [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