|
|
1bdc94 |
From ca9184bc1b0c0748b2c2e1395518f402be6f69e3 Mon Sep 17 00:00:00 2001
|
|
|
1bdc94 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
1bdc94 |
Date: Tue, 26 Jun 2018 09:48:43 +0200
|
|
|
1bdc94 |
Subject: [PATCH 74/89] qemu-iotests: Add iotests.img_info_log()
|
|
|
1bdc94 |
|
|
|
1bdc94 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
1bdc94 |
Message-id: <20180626094856.6924-61-kwolf@redhat.com>
|
|
|
1bdc94 |
Patchwork-id: 81082
|
|
|
1bdc94 |
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH v2 60/73] qemu-iotests: Add iotests.img_info_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 filter function to postprocess 'qemu-img info' input
|
|
|
1bdc94 |
(similar to what _img_info does), and an img_info_log() function that
|
|
|
1bdc94 |
calls 'qemu-img info' and logs the filtered output.
|
|
|
1bdc94 |
|
|
|
1bdc94 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
1bdc94 |
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
|
|
1bdc94 |
Reviewed-by: Jeff Cody <jcody@redhat.com>
|
|
|
1bdc94 |
(cherry picked from commit 6b605adec4d7491488d9cfb50bc256e667d8caf1)
|
|
|
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 | 18 ++++++++++++++++++
|
|
|
1bdc94 |
1 file changed, 18 insertions(+)
|
|
|
1bdc94 |
|
|
|
1bdc94 |
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
|
|
|
1bdc94 |
index bc5731a..4b0760f 100644
|
|
|
1bdc94 |
--- a/tests/qemu-iotests/iotests.py
|
|
|
1bdc94 |
+++ b/tests/qemu-iotests/iotests.py
|
|
|
1bdc94 |
@@ -109,6 +109,12 @@ def qemu_img_pipe(*args):
|
|
|
1bdc94 |
sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args))))
|
|
|
1bdc94 |
return subp.communicate()[0]
|
|
|
1bdc94 |
|
|
|
1bdc94 |
+def img_info_log(filename, filter_path=None):
|
|
|
1bdc94 |
+ output = qemu_img_pipe('info', '-f', imgfmt, filename)
|
|
|
1bdc94 |
+ if not filter_path:
|
|
|
1bdc94 |
+ filter_path = filename
|
|
|
1bdc94 |
+ log(filter_img_info(output, filter_path))
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
def qemu_io(*args):
|
|
|
1bdc94 |
'''Run qemu-io and return the stdout data'''
|
|
|
1bdc94 |
args = qemu_io_args + list(args)
|
|
|
1bdc94 |
@@ -219,6 +225,18 @@ 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 filter_img_info(output, filename):
|
|
|
1bdc94 |
+ lines = []
|
|
|
1bdc94 |
+ for line in output.split('\n'):
|
|
|
1bdc94 |
+ if 'disk size' in line or 'actual-size' in line:
|
|
|
1bdc94 |
+ continue
|
|
|
1bdc94 |
+ line = line.replace(filename, 'TEST_IMG') \
|
|
|
1bdc94 |
+ .replace(imgfmt, 'IMGFMT')
|
|
|
1bdc94 |
+ line = re.sub('iters: [0-9]+', 'iters: XXX', line)
|
|
|
1bdc94 |
+ line = re.sub('uuid: [-a-f0-9]+', 'uuid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', line)
|
|
|
1bdc94 |
+ lines.append(line)
|
|
|
1bdc94 |
+ return '\n'.join(lines)
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
def log(msg, filters=[]):
|
|
|
1bdc94 |
for flt in filters:
|
|
|
1bdc94 |
msg = flt(msg)
|
|
|
1bdc94 |
--
|
|
|
1bdc94 |
1.8.3.1
|
|
|
1bdc94 |
|