From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1astC5-00038F-UX for qemu-devel@nongnu.org; Wed, 20 Apr 2016 10:33:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1astC2-0007er-Jq for qemu-devel@nongnu.org; Wed, 20 Apr 2016 10:33:29 -0400 From: Kevin Wolf Date: Wed, 20 Apr 2016 16:32:45 +0200 Message-Id: <1461162766-907-3-git-send-email-kwolf@redhat.com> In-Reply-To: <1461162766-907-1-git-send-email-kwolf@redhat.com> References: <1461162766-907-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH for-2.6 v3 2/3] iotests: Add iotests.image_size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, famz@redhat.com, mreitz@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org From: Fam Zheng This retrieves the virtual size of the image out of qemu-img info. Reviewed-by: Max Reitz Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf --- tests/qemu-iotests/iotests.py | 6 ++++++ 1 file changed, 6 insertions(+) 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) -- 1.8.3.1