Blame SOURCES/kvm-qemu-iotests-Add-VM.qmp_log.patch

1bdc94
From d44774708b8db31c5e2658ea64ee930ffdae39be Mon Sep 17 00:00:00 2001
1bdc94
From: Kevin Wolf <kwolf@redhat.com>
1bdc94
Date: Tue, 26 Jun 2018 09:48:42 +0200
1bdc94
Subject: [PATCH 73/89] qemu-iotests: Add VM.qmp_log()
1bdc94
1bdc94
RH-Author: Kevin Wolf <kwolf@redhat.com>
1bdc94
Message-id: <20180626094856.6924-60-kwolf@redhat.com>
1bdc94
Patchwork-id: 81067
1bdc94
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH v2 59/73] qemu-iotests: Add VM.qmp_log()
1bdc94
Bugzilla: 1513543
1bdc94
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
1bdc94
RH-Acked-by: Max Reitz <mreitz@redhat.com>
1bdc94
RH-Acked-by: Fam Zheng <famz@redhat.com>
1bdc94
1bdc94
This adds a helper function that logs both the QMP request and the
1bdc94
received response before returning it.
1bdc94
1bdc94
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1bdc94
Reviewed-by: Jeff Cody <jcody@redhat.com>
1bdc94
Reviewed-by: Max Reitz <mreitz@redhat.com>
1bdc94
(cherry picked from commit e234398a8e142fd0cfe571f7efb0e6a2f34fe73d)
1bdc94
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1bdc94
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
1bdc94
---
1bdc94
 tests/qemu-iotests/iotests.py | 11 +++++++++++
1bdc94
 1 file changed, 11 insertions(+)
1bdc94
1bdc94
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
1bdc94
index 7e311ed..bc5731a 100644
1bdc94
--- a/tests/qemu-iotests/iotests.py
1bdc94
+++ b/tests/qemu-iotests/iotests.py
1bdc94
@@ -215,6 +215,10 @@ def filter_qmp_event(event):
1bdc94
         event['timestamp']['microseconds'] = 'USECS'
1bdc94
     return event
1bdc94
 
1bdc94
+def filter_testfiles(msg):
1bdc94
+    prefix = os.path.join(test_dir, "%s-" % (os.getpid()))
1bdc94
+    return msg.replace(prefix, 'TEST_DIR/PID-')
1bdc94
+
1bdc94
 def log(msg, filters=[]):
1bdc94
     for flt in filters:
1bdc94
         msg = flt(msg)
1bdc94
@@ -398,6 +402,13 @@ class VM(qtest.QEMUQtestMachine):
1bdc94
             result.append(filter_qmp_event(ev))
1bdc94
         return result
1bdc94
 
1bdc94
+    def qmp_log(self, cmd, filters=[filter_testfiles], **kwargs):
1bdc94
+        logmsg = "{'execute': '%s', 'arguments': %s}" % (cmd, kwargs)
1bdc94
+        log(logmsg, filters)
1bdc94
+        result = self.qmp(cmd, **kwargs)
1bdc94
+        log(str(result), filters)
1bdc94
+        return result
1bdc94
+
1bdc94
 
1bdc94
 index_re = re.compile(r'([^\[]+)\[([^\]]+)\]')
1bdc94
 
1bdc94
-- 
1bdc94
1.8.3.1
1bdc94