tests/qemu-iotests: add qmp_qemu_io()
Add qmp_qemu_io() method as a QMP counterpart to hmp_qemu_io(), using the x-qemu-io QMP command instead of human-monitor-command. The x-qemu-io command takes separate 'device' (or 'qdev') and 'command' arguments, and returns the error string. Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Marc-Andre Lureau <marcandre.lureau@redhat.com> Message-ID: <20260828-qemu-no-hmp-v5-25-9227de146347@redhat.com>
Marc-André Lureau committed
Aug 28, 2026 at 16:04 UTC
6e80a91a99b56c9f2e97ff88bbbff497840dbdce
1 file changed
+14
tests/qemu-iotests/iotests.py
+14
@@ -953,6 +953,20 @@ class VM(qtest.QEMUQtestMachine):
953
d = '-d ' if qdev else ''
954
return self.hmp(f'qemu-io {d}{drive} "{cmd}"', use_log=use_log)
955
956
+ def qmp_qemu_io(self, drive: str, cmd: str,
957
+ use_log: bool = False, qdev: bool = False) -> str:
958
+ """Write to a given drive using the x-qemu-io QMP command"""
959
+ kwargs: Dict[str, Any] = {'command': cmd}
960
+ if qdev:
961
+ kwargs['qdev'] = drive
962
+ else:
963
+ kwargs['device'] = drive
964
+ if use_log:
965
+ res = self.qmp_log('x-qemu-io', **kwargs)
966
+ else:
967
+ res = self.qmp('x-qemu-io', **kwargs)
968
+ return res.get('error', {}).get('desc', '')
969
+
970
def flatten_qmp_object(self, obj, output=None, basestr=''):
971
if output is None:
972
output = {}