From f5a4bbd91348ad765ac2a5d760216f2c3e0261f4 Mon Sep 17 00:00:00 2001
From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Date: Sun, 31 Oct 2010 16:10:20 -0400
Subject: [PATCH] qemu-iotests: add support for qed format

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 tests/qemu-iotests/017       | 2 +-
 tests/qemu-iotests/018       | 2 +-
 tests/qemu-iotests/019       | 2 +-
 tests/qemu-iotests/020       | 2 +-
 tests/qemu-iotests/024       | 4 ++--
 tests/qemu-iotests/027       | 2 +-
 tests/qemu-iotests/028       | 2 +-
 tests/qemu-iotests/common    | 6 ++++++
 tests/qemu-iotests/common.rc | 3 ++-
 9 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/tests/qemu-iotests/017 b/tests/qemu-iotests/017
index d861961db2..29dd53fb29 100755
--- a/tests/qemu-iotests/017
+++ b/tests/qemu-iotests/017
@@ -40,7 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.pattern
 
 # Any format supporting backing files
-_supported_fmt qcow qcow2 vmdk
+_supported_fmt qcow qcow2 vmdk qed
 _supported_os Linux
 
 TEST_OFFSETS="0 4294967296"
diff --git a/tests/qemu-iotests/018 b/tests/qemu-iotests/018
index 0a348feb61..f155b4961e 100755
--- a/tests/qemu-iotests/018
+++ b/tests/qemu-iotests/018
@@ -40,7 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.pattern
 
 # Any format supporting backing files
-_supported_fmt qcow qcow2 vmdk
+_supported_fmt qcow qcow2 vmdk qed
 _supported_os Linux
 
 TEST_OFFSETS="0 4294967296"
diff --git a/tests/qemu-iotests/019 b/tests/qemu-iotests/019
index e0187b1ffa..4c82be2b52 100755
--- a/tests/qemu-iotests/019
+++ b/tests/qemu-iotests/019
@@ -44,7 +44,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.pattern
 
 # Any format supporting backing files
-_supported_fmt qcow qcow2 vmdk
+_supported_fmt qcow qcow2 vmdk qed
 _supported_os Linux
 
 TEST_OFFSETS="0 4294967296"
diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020
index 546e074498..b065a53640 100755
--- a/tests/qemu-iotests/020
+++ b/tests/qemu-iotests/020
@@ -42,7 +42,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.pattern
 
 # Any format supporting backing files
-_supported_fmt qcow qcow2 vmdk
+_supported_fmt qcow qcow2 vmdk qed
 _supported_os Linux
 
 TEST_OFFSETS="0 4294967296"
diff --git a/tests/qemu-iotests/024 b/tests/qemu-iotests/024
index 48680ca048..ff6e9842c9 100755
--- a/tests/qemu-iotests/024
+++ b/tests/qemu-iotests/024
@@ -41,8 +41,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.filter
 . ./common.pattern
 
-# Currently only qcow2 supports rebasing
-_supported_fmt qcow2
+# Currently only qcow2 and qed support rebasing
+_supported_fmt qcow2 qed
 _supported_os Linux
 
 CLUSTER_SIZE=65536
diff --git a/tests/qemu-iotests/027 b/tests/qemu-iotests/027
index 67ecffcfdc..543c48ffaf 100755
--- a/tests/qemu-iotests/027
+++ b/tests/qemu-iotests/027
@@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common.rc
 . ./common.filter
 
-_supported_fmt vmdk qcow qcow2
+_supported_fmt vmdk qcow qcow2 qed
 _supported_os Linux
 
 
diff --git a/tests/qemu-iotests/028 b/tests/qemu-iotests/028
index 0ca220e88e..cb8b25517a 100755
--- a/tests/qemu-iotests/028
+++ b/tests/qemu-iotests/028
@@ -44,7 +44,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # Any format supporting backing files except vmdk and qcow which do not support
 # smaller backing files.
-_supported_fmt qcow2
+_supported_fmt qcow2 qed
 _supported_os Linux
 
 # Choose a size that is not necessarily a cluster size multiple for image
diff --git a/tests/qemu-iotests/common b/tests/qemu-iotests/common
index 988fd5eb37..d95ba4cddc 100644
--- a/tests/qemu-iotests/common
+++ b/tests/qemu-iotests/common
@@ -119,6 +119,7 @@ check options
     -cow                test cow
     -qcow               test qcow
     -qcow2              test qcow2
+    -qed                test qed
     -vdi                test vdi
     -vpc                test vpc
     -vmdk               test vmdk
@@ -158,6 +159,11 @@ testlist options
 	    xpand=false
 	    ;;
 
+	-qed)
+	    IMGFMT=qed
+	    xpand=false
+	    ;;
+
 	-vdi)
 	    IMGFMT=vdi
 	    xpand=false
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
index da58f92561..f2db92e985 100644
--- a/tests/qemu-iotests/common.rc
+++ b/tests/qemu-iotests/common.rc
@@ -55,7 +55,7 @@ _make_test_img()
     # at least one argument (the image size) needs to be added
     local extra_img_options=$*
 
-    if [ "$IMGFMT" = "qcow2" -a -n "$CLUSTER_SIZE" ]; then
+    if [ \( "$IMGFMT" = "qcow2" -o "$IMGFMT" = "qed" \) -a -n "$CLUSTER_SIZE" ]; then
         extra_img_options="-o cluster_size=$CLUSTER_SIZE $extra_img_options"
     fi
 
@@ -65,6 +65,7 @@ _make_test_img()
     	sed -e "s#$IMGFMT#IMGFMT#g" | \
 	sed -e "s# encryption=off##g" | \
 	sed -e "s# cluster_size=0##g" | \
+	sed -e "s# table_size=0##g" | \
 	sed -e "s# compat6=off##g" | \
 	sed -e "s# static=off##g"
 }