thebeanogamer / rpms / qemu-kvm

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