yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-block-qemu-iotests-for-vhdx-read-sample-dynamic-imag.patch

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