From patchwork Tue Apr 19 10:09:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 8878641 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C39F8BF440 for ; Tue, 19 Apr 2016 10:09:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3B84A2022A for ; Tue, 19 Apr 2016 10:09:28 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8BC5A2013A for ; Tue, 19 Apr 2016 10:09:27 +0000 (UTC) Received: from localhost ([::1]:55217 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asSb0-0001C0-SM for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Apr 2016 06:09:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asSam-00016Y-Aw for qemu-devel@nongnu.org; Tue, 19 Apr 2016 06:09:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1asSal-0001Mb-J0 for qemu-devel@nongnu.org; Tue, 19 Apr 2016 06:09:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49343) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asSaj-0001Ly-Dg; Tue, 19 Apr 2016 06:09:09 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2AA5F46267; Tue, 19 Apr 2016 10:09:09 +0000 (UTC) Received: from lemon.redhat.com (vpn1-4-251.pek2.redhat.com [10.72.4.251]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3JA90ke025649; Tue, 19 Apr 2016 06:09:06 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Tue, 19 Apr 2016 18:09:08 +0800 Message-Id: <1461060549-8667-3-git-send-email-famz@redhat.com> In-Reply-To: <1461060549-8667-1-git-send-email-famz@redhat.com> References: <1461060549-8667-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/3] iotests: Add iotests.image_size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Jeff Cody , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This retrieves the virtual size of the image out of qemu-img info. Signed-off-by: Fam Zheng Reviewed-by: Max Reitz --- 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)