All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Cody <jcody@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, famz@redhat.com, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH v2 1/3] block: qemu-iotests - add basic ability to use binary sample images
Date: Fri, 20 Sep 2013 13:12:38 -0400	[thread overview]
Message-ID: <a7da27573dd0b5166d4794ec79734495027e95d8.1379695558.git.jcody@redhat.com> (raw)
In-Reply-To: <cover.1379695558.git.jcody@redhat.com>
In-Reply-To: <cover.1379695558.git.jcody@redhat.com>

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 <jcody@redhat.com>
---
 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.
-- 
1.8.3.1

  reply	other threads:[~2013-09-20 17:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-20 17:12 [Qemu-devel] [PATCH v2 0/3] qemu-iotests with sample images, vhdx test, cleanup Jeff Cody
2013-09-20 17:12 ` Jeff Cody [this message]
2013-09-20 17:12 ` [Qemu-devel] [PATCH v2 2/3] block: qemu-iotests for vhdx, read sample dynamic image Jeff Cody
2013-09-20 17:12 ` [Qemu-devel] [PATCH v2 3/3] block: qemu-iotests - quote $TEST_IMG* and $TEST_DIR usage Jeff Cody
2013-09-23 12:45   ` Stefan Hajnoczi
2013-09-24 21:03     ` Jeff Cody
2013-09-25  8:12 ` [Qemu-devel] [PATCH v2 0/3] qemu-iotests with sample images, vhdx test, cleanup Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a7da27573dd0b5166d4794ec79734495027e95d8.1379695558.git.jcody@redhat.com \
    --to=jcody@redhat.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.