summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2016-04-20 10:48:35 +0800
committerTimothy Pearson <tpearson@raptorengineering.com>2019-11-29 20:03:49 -0600
commitc84454727f65659814e9ffb509d0bba9d029a92b (patch)
tree8b64c5e45ce5f41adaf1a3593037f2cb1d1db8ac
parent4d771a24df0715d25339c6856aefbc4c16d41274 (diff)
downloadhqemu-c84454727f65659814e9ffb509d0bba9d029a92b.zip
hqemu-c84454727f65659814e9ffb509d0bba9d029a92b.tar.gz
iotests: Add iotests.image_size
This retrieves the virtual size of the image out of qemu-img info. Signed-off-by: Fam Zheng <famz@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Jeff Cody <jcody@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--tests/qemu-iotests/iotests.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index d9ef60e..56f988a 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -28,6 +28,7 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'scripts', '
import qmp
import qtest
import struct
+import json
# This will not work if arguments contain spaces but is necessary if we
@@ -103,6 +104,11 @@ def create_image(name, size):
i = i + 512
file.close()
+def image_size(img):
+ '''Return image's virtual size'''
+ r = qemu_img_pipe('info', '--output=json', '-f', imgfmt, img)
+ return json.loads(r)['virtual-size']
+
test_dir_re = re.compile(r"%s" % test_dir)
def filter_test_dir(msg):
return test_dir_re.sub("TEST_DIR", msg)
OpenPOWER on IntegriCloud