[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 10/18] qapi: introduce x-query-roms QMP command
From: |
Daniel P . Berrangé |
Subject: |
[PULL 10/18] qapi: introduce x-query-roms QMP command |
Date: |
Tue, 2 Nov 2021 17:56:52 +0000 |
This is a counterpart to the HMP "info roms" 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.
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
hmp-commands-info.hx | 2 +-
hw/core/loader.c | 39 ++++++++++++++++++++++-----------------
monitor/misc.c | 1 +
qapi/machine.json | 12 ++++++++++++
4 files changed, 36 insertions(+), 18 deletions(-)
diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
index 24c478aead..b6325d36ed 100644
--- a/hmp-commands-info.hx
+++ b/hmp-commands-info.hx
@@ -594,7 +594,7 @@ ERST
.args_type = "",
.params = "",
.help = "show roms",
- .cmd = hmp_info_roms,
+ .cmd_info_hrt = qmp_x_query_roms,
},
SRST
diff --git a/hw/core/loader.c b/hw/core/loader.c
index c7f97fdce8..052a0fd719 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -46,6 +46,8 @@
#include "qemu-common.h"
#include "qemu/datadir.h"
#include "qapi/error.h"
+#include "qapi/qapi-commands-machine.h"
+#include "qapi/type-helpers.h"
#include "trace.h"
#include "hw/hw.h"
#include "disas/disas.h"
@@ -1474,32 +1476,35 @@ void *rom_ptr_for_as(AddressSpace *as, hwaddr addr,
size_t size)
return cbdata.rom;
}
-void hmp_info_roms(Monitor *mon, const QDict *qdict)
+HumanReadableText *qmp_x_query_roms(Error **errp)
{
Rom *rom;
+ g_autoptr(GString) buf = g_string_new("");
QTAILQ_FOREACH(rom, &roms, next) {
if (rom->mr) {
- monitor_printf(mon, "%s"
- " size=0x%06zx name=\"%s\"\n",
- memory_region_name(rom->mr),
- rom->romsize,
- rom->name);
+ g_string_append_printf(buf, "%s"
+ " size=0x%06zx name=\"%s\"\n",
+ memory_region_name(rom->mr),
+ rom->romsize,
+ rom->name);
} else if (!rom->fw_file) {
- monitor_printf(mon, "addr=" TARGET_FMT_plx
- " size=0x%06zx mem=%s name=\"%s\"\n",
- rom->addr, rom->romsize,
- rom->isrom ? "rom" : "ram",
- rom->name);
+ g_string_append_printf(buf, "addr=" TARGET_FMT_plx
+ " size=0x%06zx mem=%s name=\"%s\"\n",
+ rom->addr, rom->romsize,
+ rom->isrom ? "rom" : "ram",
+ rom->name);
} else {
- monitor_printf(mon, "fw=%s/%s"
- " size=0x%06zx name=\"%s\"\n",
- rom->fw_dir,
- rom->fw_file,
- rom->romsize,
- rom->name);
+ g_string_append_printf(buf, "fw=%s/%s"
+ " size=0x%06zx name=\"%s\"\n",
+ rom->fw_dir,
+ rom->fw_file,
+ rom->romsize,
+ rom->name);
}
}
+
+ return human_readable_text_from_str(buf);
}
typedef enum HexRecord HexRecord;
diff --git a/monitor/misc.c b/monitor/misc.c
index 0e124044d0..c3efdf6336 100644
--- a/monitor/misc.c
+++ b/monitor/misc.c
@@ -71,6 +71,7 @@
#include "qapi/qapi-commands-misc.h"
#include "qapi/qapi-commands-qom.h"
#include "qapi/qapi-commands-trace.h"
+#include "qapi/qapi-commands-machine.h"
#include "qapi/qapi-init-commands.h"
#include "qapi/error.h"
#include "qapi/qmp-event.h"
diff --git a/qapi/machine.json b/qapi/machine.json
index 5db54df298..26d4ef8195 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -1411,3 +1411,15 @@
'*cores': 'int',
'*threads': 'int',
'*maxcpus': 'int' } }
+
+##
+# @x-query-roms:
+#
+# Query information on the registered ROMS
+#
+# Returns: registered ROMs
+#
+# Since: 6.2
+##
+{ 'command': 'x-query-roms',
+ 'returns': 'HumanReadableText' }
--
2.31.1
- [PULL 00/18] HMP-to-QMP info command patches, Daniel P . Berrangé, 2021/11/02
- [PULL 01/18] monitor: remove 'info ioapic' HMP command, Daniel P . Berrangé, 2021/11/02
- [PULL 02/18] monitor: make hmp_handle_error return a boolean, Daniel P . Berrangé, 2021/11/02
- [PULL 03/18] docs/devel: rename file for writing monitor commands, Daniel P . Berrangé, 2021/11/02
- [PULL 04/18] docs/devel: tweak headings in monitor command docs, Daniel P . Berrangé, 2021/11/02
- [PULL 05/18] docs/devel: update error handling guidance for HMP commands, Daniel P . Berrangé, 2021/11/02
- [PULL 06/18] monitor: introduce HumanReadableText and HMP support, Daniel P . Berrangé, 2021/11/02
- [PULL 07/18] docs/devel: document expectations for QAPI data modelling for QMP, Daniel P . Berrangé, 2021/11/02
- [PULL 08/18] docs/devel: add example of command returning unstructured text, Daniel P . Berrangé, 2021/11/02
- [PULL 09/18] docs/devel: document expectations for HMP commands in the future, Daniel P . Berrangé, 2021/11/02
- [PULL 10/18] qapi: introduce x-query-roms QMP command,
Daniel P . Berrangé <=
- [PULL 11/18] qapi: introduce x-query-profile QMP command, Daniel P . Berrangé, 2021/11/02
- [PULL 12/18] qapi: introduce x-query-numa QMP command, Daniel P . Berrangé, 2021/11/02
- [PULL 13/18] qapi: introduce x-query-usb QMP command, Daniel P . Berrangé, 2021/11/02
- [PULL 14/18] qapi: introduce x-query-rdma QMP command, Daniel P . Berrangé, 2021/11/02
- [PULL 15/18] qapi: introduce x-query-ramblock QMP command, Daniel P . Berrangé, 2021/11/02
- [PULL 16/18] qapi: introduce x-query-irq QMP command, Daniel P . Berrangé, 2021/11/02
- [PULL 17/18] qapi: introduce x-query-jit QMP command, Daniel P . Berrangé, 2021/11/02
- [PULL 18/18] qapi: introduce x-query-opcount QMP command, Daniel P . Berrangé, 2021/11/02
- Re: [PULL 00/18] HMP-to-QMP info command patches, Richard Henderson, 2021/11/03