9ae3a8
From 9188bcfc8f33c9340acdb6279d01d09ca6fec591 Mon Sep 17 00:00:00 2001
9ae3a8
From: Jeffrey Cody <jcody@redhat.com>
9ae3a8
Date: Wed, 20 Nov 2013 19:43:44 +0100
9ae3a8
Subject: [PATCH 01/25] block: qemu-iotests for vhdx, read sample dynamic image
9ae3a8
9ae3a8
RH-Author: Jeffrey Cody <jcody@redhat.com>
9ae3a8
Message-id: <b119331204efa951904aa6f73857c90665607fb2.1384975172.git.jcody@redhat.com>
9ae3a8
Patchwork-id: 55794
9ae3a8
O-Subject: [RHEL7 qemu-kvm PATCH 01/26] block: qemu-iotests for vhdx, read sample dynamic image
9ae3a8
Bugzilla: 879234
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Fam Zheng <famz@redhat.com>
9ae3a8
9ae3a8
This adds the VHDX format to the qemu-iotests format, and adds
9ae3a8
a read test.  The test reads from an existing sample image, that
9ae3a8
was created with Hyper-V under Windwos Server 2012.
9ae3a8
9ae3a8
The image file is a 1GB dynamic image, with 32MB blocks.
9ae3a8
9ae3a8
The pattern 0xa5 exists from 0MB-33MB (past a block size boundary)
9ae3a8
9ae3a8
The pattern 0x96 exists from 33MB-66MB (past another block boundary,
9ae3a8
and leaving a partial blank block)
9ae3a8
9ae3a8
>From 66MB-1024MB, all reads should return 0.
9ae3a8
9ae3a8
Although 1GB dynamic image with 66MB of data, the bzip2'ed image
9ae3a8
file size is only 874 bytes.
9ae3a8
9ae3a8
This also adds in the IMGFMT_GENERIC flag, so r/o images can be
9ae3a8
tested (e.g. ./check -vhdx) without failing tests that assume
9ae3a8
r/w support.
9ae3a8
9ae3a8
Signed-off-by: Jeff Cody <jcody@redhat.com>
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
(cherry picked from commit 89e911816a1d5cdbc9480d5464c571d216cf5ea8)
9ae3a8
---
9ae3a8
 tests/qemu-iotests/064                             |  62 +++++++++++++++++++++
9ae3a8
 tests/qemu-iotests/064.out                         |  14 +++++
9ae3a8
 tests/qemu-iotests/common                          |   8 +++
9ae3a8
 tests/qemu-iotests/common.rc                       |   2 +-
9ae3a8
 tests/qemu-iotests/group                           |   1 +
9ae3a8
 .../sample_images/iotest-dynamic-1G.vhdx.bz2       | Bin 0 -> 874 bytes
9ae3a8
 6 files changed, 86 insertions(+), 1 deletion(-)
9ae3a8
 create mode 100755 tests/qemu-iotests/064
9ae3a8
 create mode 100644 tests/qemu-iotests/064.out
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 tests/qemu-iotests/064       |   62 ++++++++++++++++++++++++++++++++++++++++++
9ae3a8
 tests/qemu-iotests/064.out   |   14 +++++++++
9ae3a8
 tests/qemu-iotests/common    |    8 +++++
9ae3a8
 tests/qemu-iotests/common.rc |    2 +-
9ae3a8
 tests/qemu-iotests/group     |    1 +
9ae3a8
 5 files changed, 86 insertions(+), 1 deletions(-)
9ae3a8
 create mode 100755 tests/qemu-iotests/064
9ae3a8
 create mode 100644 tests/qemu-iotests/064.out
9ae3a8
9ae3a8
diff --git a/tests/qemu-iotests/064 b/tests/qemu-iotests/064
9ae3a8
new file mode 100755
9ae3a8
index 0000000..6789aa6
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qemu-iotests/064
9ae3a8
@@ -0,0 +1,62 @@
9ae3a8
+#!/bin/bash
9ae3a8
+#
9ae3a8
+# Test VHDX read/write from a sample image created with Hyper-V
9ae3a8
+#
9ae3a8
+# Copyright (C) 2013 Red Hat, Inc.
9ae3a8
+#
9ae3a8
+# This program is free software; you can redistribute it and/or modify
9ae3a8
+# it under the terms of the GNU General Public License as published by
9ae3a8
+# the Free Software Foundation; either version 2 of the License, or
9ae3a8
+# (at your option) any later version.
9ae3a8
+#
9ae3a8
+# This program is distributed in the hope that it will be useful,
9ae3a8
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
9ae3a8
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9ae3a8
+# GNU General Public License for more details.
9ae3a8
+#
9ae3a8
+# You should have received a copy of the GNU General Public License
9ae3a8
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
9ae3a8
+#
9ae3a8
+
9ae3a8
+# creator
9ae3a8
+owner=jcody@redhat.com
9ae3a8
+
9ae3a8
+seq=`basename $0`
9ae3a8
+echo "QA output created by $seq"
9ae3a8
+
9ae3a8
+here=`pwd`
9ae3a8
+tmp=/tmp/$$
9ae3a8
+status=1	# failure is the default!
9ae3a8
+
9ae3a8
+_cleanup()
9ae3a8
+{
9ae3a8
+    _cleanup_test_img
9ae3a8
+}
9ae3a8
+trap "_cleanup; exit \$status" 0 1 2 3 15
9ae3a8
+
9ae3a8
+# get standard environment, filters and checks
9ae3a8
+. ./common.rc
9ae3a8
+. ./common.filter
9ae3a8
+
9ae3a8
+_supported_fmt vhdx
9ae3a8
+_supported_proto generic
9ae3a8
+_supported_os Linux
9ae3a8
+
9ae3a8
+_use_sample_img iotest-dynamic-1G.vhdx.bz2
9ae3a8
+
9ae3a8
+echo
9ae3a8
+echo "=== Verify pattern 0xa5, 0 - 33MB ==="
9ae3a8
+$QEMU_IO -r -c "read -pP 0xa5 0 33M" "$TEST_IMG" | _filter_qemu_io
9ae3a8
+
9ae3a8
+echo
9ae3a8
+echo "=== Verify pattern 0x96, 33M - 66M ==="
9ae3a8
+$QEMU_IO -r -c "read -pP 0x96 33M 33M" "$TEST_IMG" | _filter_qemu_io
9ae3a8
+
9ae3a8
+echo
9ae3a8
+echo "=== Verify pattern 0x00, 66M - 1024M ==="
9ae3a8
+$QEMU_IO -r -c "read -pP 0x00 66M 958M" "$TEST_IMG" | _filter_qemu_io
9ae3a8
+
9ae3a8
+# success, all done
9ae3a8
+echo "*** done"
9ae3a8
+rm -f $seq.full
9ae3a8
+status=0
9ae3a8
diff --git a/tests/qemu-iotests/064.out b/tests/qemu-iotests/064.out
9ae3a8
new file mode 100644
9ae3a8
index 0000000..b9e8e4a
9ae3a8
--- /dev/null
9ae3a8
+++ b/tests/qemu-iotests/064.out
9ae3a8
@@ -0,0 +1,14 @@
9ae3a8
+QA output created by 064
9ae3a8
+
9ae3a8
+=== Verify pattern 0xa5, 0 - 33MB ===
9ae3a8
+read 34603008/34603008 bytes at offset 0
9ae3a8
+33 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
9ae3a8
+
9ae3a8
+=== Verify pattern 0x96, 33M - 66M ===
9ae3a8
+read 34603008/34603008 bytes at offset 34603008
9ae3a8
+33 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
9ae3a8
+
9ae3a8
+=== Verify pattern 0x00, 66M - 1024M ===
9ae3a8
+read 1004535808/1004535808 bytes at offset 69206016
9ae3a8
+958 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
9ae3a8
+*** done
9ae3a8
diff --git a/tests/qemu-iotests/common b/tests/qemu-iotests/common
9ae3a8
index fecaf85..2932e14 100644
9ae3a8
--- a/tests/qemu-iotests/common
9ae3a8
+++ b/tests/qemu-iotests/common
9ae3a8
@@ -45,6 +45,7 @@ valgrind=false
9ae3a8
 rm -f $tmp.list $tmp.tmp $tmp.sed
9ae3a8
 
9ae3a8
 export IMGFMT=raw
9ae3a8
+export IMGFMT_GENERIC=true
9ae3a8
 export IMGPROTO=file
9ae3a8
 export IMGOPTS=""
9ae3a8
 export QEMU_IO_OPTIONS=""
9ae3a8
@@ -133,6 +134,7 @@ check options
9ae3a8
     -qed                test qed
9ae3a8
     -vdi                test vdi
9ae3a8
     -vpc                test vpc
9ae3a8
+    -vhdx               test vhdx
9ae3a8
     -vmdk               test vmdk
9ae3a8
     -rbd                test rbd
9ae3a8
     -sheepdog           test sheepdog
9ae3a8
@@ -195,6 +197,12 @@ testlist options
9ae3a8
             xpand=false
9ae3a8
             ;;
9ae3a8
 
9ae3a8
+        -vhdx)
9ae3a8
+            IMGFMT=vhdx
9ae3a8
+            xpand=false
9ae3a8
+            IMGFMT_GENERIC=false
9ae3a8
+            ;;
9ae3a8
+
9ae3a8
         -rbd)
9ae3a8
             IMGPROTO=rbd
9ae3a8
             xpand=false
9ae3a8
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
9ae3a8
index 227c003..4e82604 100644
9ae3a8
--- a/tests/qemu-iotests/common.rc
9ae3a8
+++ b/tests/qemu-iotests/common.rc
9ae3a8
@@ -339,7 +339,7 @@ _fail()
9ae3a8
 _supported_fmt()
9ae3a8
 {
9ae3a8
     for f; do
9ae3a8
-        if [ "$f" = "$IMGFMT" -o "$f" = "generic" ]; then
9ae3a8
+        if [ "$f" = "$IMGFMT" -o "$f" = "generic" -a "$IMGFMT_GENERIC" = "true" ]; then
9ae3a8
             return
9ae3a8
         fi
9ae3a8
     done
9ae3a8
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
9ae3a8
index 4a211bf..1a182ed 100644
9ae3a8
--- a/tests/qemu-iotests/group
9ae3a8
+++ b/tests/qemu-iotests/group
9ae3a8
@@ -64,6 +64,7 @@
9ae3a8
 059 rw auto
9ae3a8
 060 rw auto
9ae3a8
 063 rw auto
9ae3a8
+064 rw auto
9ae3a8
 065 rw auto
9ae3a8
 067 rw auto
9ae3a8
 068 rw auto
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8