]> xenbits.xensource.com Git - people/pauldu/qemu.git/commitdiff
iotests: Add iotests.image_size
authorFam Zheng <famz@redhat.com>
Wed, 20 Apr 2016 02:48:35 +0000 (10:48 +0800)
committerKevin Wolf <kwolf@redhat.com>
Wed, 20 Apr 2016 14:52:55 +0000 (16:52 +0200)
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>
tests/qemu-iotests/iotests.py

index d9ef60ef0337c300bb2dcf1a32217983ea493ecd..56f988ab3d017e0eaae0f18bc0d0f49556e4b99a 100644 (file)
@@ -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)