From patchwork Wed Sep 25 12:12:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 277823 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AA60E2C0094 for ; Wed, 25 Sep 2013 22:13:14 +1000 (EST) Received: from localhost ([::1]:52090 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOnxw-0004Bm-C5 for incoming@patchwork.ozlabs.org; Wed, 25 Sep 2013 08:13:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37926) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOnxJ-000412-N5 for qemu-devel@nongnu.org; Wed, 25 Sep 2013 08:12:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VOnxD-0002CF-NO for qemu-devel@nongnu.org; Wed, 25 Sep 2013 08:12:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3007) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOnxD-0002C4-Fo for qemu-devel@nongnu.org; Wed, 25 Sep 2013 08:12:27 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r8PCCQOV015286 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 25 Sep 2013 08:12:26 -0400 Received: from localhost ([10.3.112.14]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r8PCCPmp026798 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Wed, 25 Sep 2013 08:12:26 -0400 From: Jeff Cody To: qemu-devel@nongnu.org Date: Wed, 25 Sep 2013 08:12:20 -0400 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, stefanha@redhat.com Subject: [Qemu-devel] [PATCH v3 1/3] block: qemu-iotests - add basic ability to use binary sample images X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org For image formats that are not "QEMU native", but supported for compatibility, it is useful to verify that an image created with the 'gold standard' native tool can be read / written to successfully by QEMU. In addition to testing non-native images, this could also be useful to test against image files created by older versions of QEMU. This provides a directory to store small sample images, for use by scripts in tests/qemu-iotests. The MANIFEST file should be updated when a new image is added to the directory, to give some idea about the nature of the image and the data store therein. Image files should be compressed with bzip2. To use a sample image from a bash script, the _use_sample_img function will copy and decompress the image into $TEST_DIR, and set $TEST_IMG to be the decompressed sample image copy. To cleanup, call _cleanup_test_img as normal. Signed-off-by: Jeff Cody Reviewed-by: Stefan Hajnoczi --- tests/qemu-iotests/common.config | 11 +++++++++++ tests/qemu-iotests/common.rc | 16 ++++++++++++++++ tests/qemu-iotests/sample_images/README | 8 ++++++++ 3 files changed, 35 insertions(+) create mode 100644 tests/qemu-iotests/sample_images/README diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config index d794e62..d90a8bc 100644 --- a/tests/qemu-iotests/common.config +++ b/tests/qemu-iotests/common.config @@ -125,6 +125,17 @@ fi export TEST_DIR +if [ -z "$SAMPLE_IMG_DIR" ]; then + SAMPLE_IMG_DIR=`pwd`/sample_images +fi + +if [ ! -d "$SAMPLE_IMG_DIR" ]; then + echo "common.config: Error: \$SAMPLE_IMG_DIR ($SAMPLE_IMG_DIR) is not a directory" + exit 1 +fi + +export SAMPLE_IMG_DIR + _readlink() { if [ $# -ne 1 ]; then diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc index 28b39e4..6730955 100644 --- a/tests/qemu-iotests/common.rc +++ b/tests/qemu-iotests/common.rc @@ -91,6 +91,18 @@ _set_default_imgopts() fi } +_use_sample_img() +{ + SAMPLE_IMG_FILE="${1%\.bz2}" + TEST_IMG="$TEST_DIR/$SAMPLE_IMG_FILE" + bzcat "$SAMPLE_IMG_DIR/$1" > "$TEST_IMG" + if [ $? -ne 0 ] + then + echo "_use_sample_img error, cannot extract '$SAMPLE_IMG_DIR/$1'" + exit 1 + fi +} + _make_test_img() { # extra qemu-img options can be added by tests @@ -158,6 +170,10 @@ _cleanup_test_img() rm -f $TEST_DIR/t.$IMGFMT rm -f $TEST_DIR/t.$IMGFMT.orig rm -f $TEST_DIR/t.$IMGFMT.base + if [ -n "$SAMPLE_IMG_FILE" ] + then + rm -f "$TEST_DIR/$SAMPLE_IMG_FILE" + fi ;; rbd) diff --git a/tests/qemu-iotests/sample_images/README b/tests/qemu-iotests/sample_images/README new file mode 100644 index 0000000..507af5f --- /dev/null +++ b/tests/qemu-iotests/sample_images/README @@ -0,0 +1,8 @@ +This is for small sample images to be used with qemu-iotests, intended for +non-native formats that QEMU supports for compatibility. The idea is to use +the native tool to create the sample image. + +For instance, a VHDX image in this directory would be an image created not by +QEMU itself, but rather created by Hyper-V. + +Sample images added here must be compressed with bzip2.