Skip to contentSkip to conversation

Add cache mode option to qemu-iotests

PATCH Superseded Fam Zheng 2 participants 5 messages Nov 19, 2013

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

v2 cover Add cache mode option to qemu-iotests

The first patch adds "-c <mode>" option to ./check and convert "-nocache" to an alias to "-c none". The mode is used in qemu-io.

The second patch modifies iotests.py to use the cache mode option in qemu drive command line.

Fam Zheng (2):
qemu-iotests: Add "-c <cache-mode>" option
qemu-iotests: Honour cache mode in iotests.py

 tests/qemu-iotests/common     | 18 ++++++++++++++++--
 tests/qemu-iotests/iotests.py |  3 ++-
 2 files changed, 18 insertions(+), 3 deletions(-)
Signature · 1 line
1.8.4.2
author
#1 lore raw

PATCH v2 1/2 qemu-iotests: Add "-c <cache-mode>" option

The option sets cache mode used in the tests. "-nocache" is changed to an alias to "-c none", and internally passes "-t none" to qemu-io.

Python scripts will make use of option this in the next commit.

---
 tests/qemu-iotests/common | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
tests/qemu-iotests/common +16 -2
index 8cde7f1..5314314 100644
@@ -42,12 +42,14 @@ expunge=true
 have_test_arg=false
 randomize=false
 valgrind=false
+cachemode=false
 rm -f $tmp.list $tmp.tmp $tmp.sed
 
 export IMGFMT=raw
 export IMGFMT_GENERIC=true
 export IMGPROTO=file
 export IMGOPTS=""
+export CACHEMODE="writethrough"
 export QEMU_IO_OPTIONS=""
 
 for r
@@ -113,7 +115,11 @@ s/ .*//p
         IMGOPTS="$r"
         imgopts=false
         continue
-
+    elif $cachemode
+    then
+        CACHEMODE="$r"
+        cachemode=false
+        continue
     fi
 
     xpand=true
@@ -147,6 +153,7 @@ check options
     -o options          -o options to pass to qemu-img create/convert
     -T                        output timestamps
     -r                         randomize test order
+    -c                  cache mode
 
 testlist options
     -g group[,group...]        include tests from these groups
@@ -219,7 +226,7 @@ testlist options
             xpand=false
             ;;
         -nocache)
-            QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --nocache"
+            CACHEMODE="none"
             xpand=false
             ;;
 
@@ -258,6 +265,10 @@ testlist options
             imgopts=true
             xpand=false
             ;;
+        -c)
+            cachemode=true
+            xpand=false
+            ;;
         -r)        # randomize test order
             randomize=true
             xpand=false
@@ -334,6 +345,9 @@ BEGIN        { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
 
 done
 
+# Set qemu-io cache mode with $CACHEMODE we have
+QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS -t $CACHEMODE"
+
 # Set default options for qemu-img create -o if they were not specified
 _set_default_imgopts
 
Signature · 1 line
1.8.4.2
author
#2 lore raw

PATCH v2 2/2 qemu-iotests: Honour cache mode in iotests.py

In reply to Fam Zheng

This will allow overriding cache mode from the "-c mode" option.

---
 tests/qemu-iotests/iotests.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tests/qemu-iotests/iotests.py +2 -1
index fb10ff4..c84a1a5 100644
@@ -37,6 +37,7 @@ qemu_args = os.environ.get('QEMU', 'qemu').strip().split(' ')
 imgfmt = os.environ.get('IMGFMT', 'raw')
 imgproto = os.environ.get('IMGPROTO', 'file')
 test_dir = os.environ.get('TEST_DIR', '/var/tmp')
+cachemode = os.environ.get('CACHEMODE')
 
 socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_helper')
 
@@ -96,7 +97,7 @@ class VM(object):
         '''Add a virtio-blk drive to the VM'''
         options = ['if=virtio',
                    'format=%s' % imgfmt,
-                   'cache=none',
+                   'cache=%s' % cachemode,
                    'file=%s' % path,
                    'id=drive%d' % self._num_drives]
         if opts:
Signature · 1 line
1.8.4.2
Reviewed-by on the v2 series
#3 lore raw
In reply to Fam Zheng

Am 19.11.2013 um 07:45 hat Fam Zheng geschrieben:

Quoted 6 lines

The first patch adds "-c <mode>" option to ./check and convert "-nocache" to an alias to "-c none". The mode is used in qemu-io.

The second patch modifies iotests.py to use the cache mode option in qemu drive command line.

Quoted 7 lines

Fam Zheng (2):
qemu-iotests: Add "-c <cache-mode>" option
qemu-iotests: Honour cache mode in iotests.py

 tests/qemu-iotests/common     | 18 ++++++++++++++++--
 tests/qemu-iotests/iotests.py |  3 ++-
 2 files changed, 18 insertions(+), 3 deletions(-)
#4 lore raw
In reply to Fam Zheng

Am 19.11.2013 um 07:45 hat Fam Zheng geschrieben:

Quoted 5 lines

The first patch adds "-c <mode>" option to ./check and convert "-nocache" to an alias to "-c none". The mode is used in qemu-io.

The second patch modifies iotests.py to use the cache mode option in qemu drive command line.

Okay, I gave it some testing, too, and it looks like we need some additional changes. There are some test cases that use:

_unsupported_qemu_io_options --nocache

Which obviously doesn't work any more. We need to replace it by a check against $CACHEMODE (or, perhaps preferably, even override it automatically, so that test cases aren't left out just because of the cache mode)

Test case 026 uses the option of having a 026.out.nocache, which differs from the normal output. I suspect the correct differentiation is here between writethrough and writeback modes. And of course, grepping for '--nocache' to detect the condition doesn't work any more.

Kevin