On 25/8/26 21:09, Marc-André Lureau wrote:
Add an x-qemu-io QMP command that runs qemu-io commands on block
devices. The command accepts a device name (block backend name,
node-name, or qdev ID) and a qemu-io command string.

Refactor hmp_qemu_io() to be a thin wrapper around the new QMP
command, following the standard HMP-over-QMP pattern used by other
block commands.

This change is also required for the qtest qemu-io command in the
following patch.

Reviewed-by: Daniel P. Berrangé <[email protected]>
Signed-off-by: Marc-André Lureau <[email protected]>
---
  block/monitor/block-hmp-cmds.c | 60 ++------------------------------
  block/monitor/meson.build      |  1 +
  block/monitor/qmp-cmds.c       | 79 ++++++++++++++++++++++++++++++++++++++++++
  qapi/block.json                | 34 ++++++++++++++++++
  4 files changed, 117 insertions(+), 57 deletions(-)


diff --git a/qapi/block.json b/qapi/block.json
index 46955bbb3e34..012a9d73333b 100644
--- a/qapi/block.json
+++ b/qapi/block.json
@@ -603,3 +603,37 @@
             '*boundaries-zap': ['uint64'],
             '*boundaries-flush': ['uint64'] },
    'allow-preconfig': true }
+
+##
+# @x-qemu-io:
+#
+# Run a qemu-io command on a block device.  Take either a block
+# backend name or a qdev ID to identify the device.
+#
+# @device: the block backend name, node-name to run the
+#     command on.
+#
+# @qdev: the qdev ID of the block device to run the
+#     command on.
+#
+# @command: the qemu-io command string to execute.
+#
+# Features:
+#
+# @unstable: This command is for testing only.
+#
+# Since: 11.2
+#
+# .. qmp-example::
+#
+#     -> { "execute": "x-qemu-io",
+#          "arguments": { "device": "virtio0",
+#                         "command": "read 0 512" } }
+#     <- { "return": {} }
+##
+{ 'command': 'x-qemu-io',
+  'data': { '*device': 'str',
+            '*qdev': 'str',
+            'command': 'str' },
+  'features': [ 'unstable' ],
+  'allow-preconfig': true }

'qemu-io' HMP command was a bad name decision. This is a good
opportunity to clean it: can we add QMP 'x-block-io' or
'x-block-cmd' / 'x-block-command' instead? Keeping the legacy
HMP name (or adding an HMP alias)?


Reply via email to