[PATCH 4/6] iotests: add hmp helper with logging

John Snow posted 6 patches 5 years, 8 months ago
Maintainers: John Snow <jsnow@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Markus Armbruster <armbru@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>, Eric Blake <eblake@redhat.com>, Cleber Rosa <crosa@redhat.com>, Max Reitz <mreitz@redhat.com>
There is a newer version of this series
[PATCH 4/6] iotests: add hmp helper with logging
Posted by John Snow 5 years, 8 months ago
Just a mild cleanup while I was here.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 tests/qemu-iotests/iotests.py | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 8815052eb5..5d2990a0e4 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -525,23 +525,27 @@ def add_incoming(self, addr):
         self._args.append(addr)
         return self
 
+    def hmp(self, command_line, log=False):
+        cmd = 'human-monitor-command'
+        kwargs = { 'command-line': command_line }
+        if log:
+            return self.qmp_log(cmd, **kwargs)
+        return self.qmp(cmd, **kwargs)
+
     def pause_drive(self, drive, event=None):
         '''Pause drive r/w operations'''
         if not event:
             self.pause_drive(drive, "read_aio")
             self.pause_drive(drive, "write_aio")
             return
-        self.qmp('human-monitor-command',
-                    command_line='qemu-io %s "break %s bp_%s"' % (drive, event, drive))
+        self.hmp('qemu-io %s "break %s bp_%s"' % (drive, event, drive))
 
     def resume_drive(self, drive):
-        self.qmp('human-monitor-command',
-                    command_line='qemu-io %s "remove_break bp_%s"' % (drive, drive))
+        self.hmp('qemu-io %s "remove_break bp_%s"' % (drive, drive))
 
-    def hmp_qemu_io(self, drive, cmd):
+    def hmp_qemu_io(self, drive, cmd, log=False):
         '''Write to a given drive using an HMP command'''
-        return self.qmp('human-monitor-command',
-                        command_line='qemu-io %s "%s"' % (drive, cmd))
+        return self.hmp('qemu-io %s "%s"' % (drive, cmd), log=log)
 
     def flatten_qmp_object(self, obj, output=None, basestr=''):
         if output is None:
-- 
2.21.1


Re: [PATCH 4/6] iotests: add hmp helper with logging
Posted by Vladimir Sementsov-Ogievskiy 5 years, 8 months ago
25.02.2020 3:56, John Snow wrote:
> Just a mild cleanup while I was here.
> 
> Signed-off-by: John Snow<jsnow@redhat.com>

Great!

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

-- 
Best regards,
Vladimir