qemu-iotests: Add _default_cache_mode and _supported_cache_modes
authorFam Zheng <famz@redhat.com>
Wed, 4 Dec 2013 01:07:00 +0000 (09:07 +0800)
committerStefan Hajnoczi <stefanha@redhat.com>
Wed, 4 Dec 2013 10:55:13 +0000 (11:55 +0100)
This replaces _unsupported_qemu_io_options and check for support of
current cache mode, and allow to provide a default if user didn't
specify.

Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
tests/qemu-iotests/026
tests/qemu-iotests/039
tests/qemu-iotests/052
tests/qemu-iotests/common.rc

index ebe29d0168d0682d287b20033126f3fa51f9b257..c9c5f839363e20ba9c76edceaabeb7f99a89a8db 100755 (executable)
@@ -44,7 +44,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 _supported_fmt qcow2
 _supported_proto generic
 _supported_os Linux
-
+_default_cache_mode "writethrough"
+_supported_cache_modes "writethrough" "none"
 
 echo "Errors while writing 128 kB"
 echo
index 8bade92a803d498ed1904250a1ecc8daf9ae9cce..6abf47267f61d68c8965aa0acc971601ccf6f270 100755 (executable)
@@ -44,7 +44,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 _supported_fmt qcow2
 _supported_proto generic
 _supported_os Linux
-_unsupported_qemu_io_options --nocache
+_default_cache_mode "writethrough"
+_supported_cache_modes "writethrough"
 
 size=128M
 
index f5f9683e684856ddae3fb768f9ca663dcefe7159..4d4e411339d97b45cd25ea5556afdef527ecca26 100755 (executable)
@@ -41,8 +41,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 _supported_fmt generic
 _supported_proto generic
 _supported_os Linux
-_unsupported_qemu_io_options --nocache
-
+_default_cache_mode "writethrough"
+_supported_cache_modes "writethrough"
 
 size=128M
 _make_test_img $size
index 7f6245770a5d9c48073b5eb17762994c4178b560..47cef6dbe47f24d7e57d6dc7e25d1f0cbd20e6b0 100644 (file)
@@ -387,18 +387,23 @@ _supported_os()
     _notrun "not suitable for this OS: $HOSTOS"
 }
 
-_unsupported_qemu_io_options()
+_supported_cache_modes()
 {
-    for bad_opt
-    do
-        for opt in $QEMU_IO_OPTIONS
-        do
-            if [ "$bad_opt" = "$opt" ]
-            then
-                _notrun "not suitable for qemu-io option: $bad_opt"
-            fi
-        done
+    for mode; do
+        if [ "$mode" = "$CACHEMODE" ]; then
+            return
+        fi
     done
+    _notrun "not suitable for cache mode: $CACHEMODE"
+}
+
+_default_cache_mode()
+{
+    if $CACHEMODE_IS_DEFAULT; then
+        CACHEMODE="$1"
+        QEMU_IO="$QEMU_IO --cache $1"
+        return
+    fi
 }
 
 # this test requires that a specified command (executable) exists