Skip to contentSkip to conversation

iotests: Test migration with filter nodes

PATCH In review Kevin Wolf 3 participants 11 messages Aug 1, 2019 – Aug 6, 2019

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

cover iotests: Test migration with filter nodes

This is the testcase for the copy-on-read fix I merged in a hurry for 4.1.0-rc3.

Kevin Wolf (3):
iotests: Move migration helpers to iotests.py
iotests: Enable -d for Python non-unittest tests
iotests: Test migration with all kinds of filter nodes

 tests/qemu-iotests/194        |  1 +
 tests/qemu-iotests/202        |  1 +
 tests/qemu-iotests/203        |  2 +
 tests/qemu-iotests/206        |  1 +
 tests/qemu-iotests/207        |  1 +
 tests/qemu-iotests/208        |  1 +
 tests/qemu-iotests/210        |  1 +
 tests/qemu-iotests/211        |  1 +
 tests/qemu-iotests/212        |  1 +
 tests/qemu-iotests/213        |  1 +
 tests/qemu-iotests/216        |  2 +
 tests/qemu-iotests/218        |  1 +
 tests/qemu-iotests/219        |  1 +
 tests/qemu-iotests/222        |  1 +
 tests/qemu-iotests/224        |  2 +
 tests/qemu-iotests/228        |  2 +
 tests/qemu-iotests/234        | 30 ++++---------
 tests/qemu-iotests/236        |  1 +
 tests/qemu-iotests/237        |  1 +
 tests/qemu-iotests/246        |  1 +
 tests/qemu-iotests/255        |  1 +
 tests/qemu-iotests/256        |  1 +
 tests/qemu-iotests/262        | 84 +++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/262.out    | 17 +++++++
 tests/qemu-iotests/group      |  1 +
 tests/qemu-iotests/iotests.py | 39 ++++++++++++----
 26 files changed, 166 insertions(+), 30 deletions(-)
 create mode 100755 tests/qemu-iotests/262
 create mode 100644 tests/qemu-iotests/262.out
Signature · 1 line
2.20.1
author
#1 lore raw

PATCH 1/3 iotests: Move migration helpers to iotests.py

234 implements functions that are useful for doing migration between two VMs. Move them to iotests.py so that other test cases can use them, too.

---
 tests/qemu-iotests/234        | 30 +++++++-----------------------
 tests/qemu-iotests/iotests.py | 16 ++++++++++++++++
 2 files changed, 23 insertions(+), 23 deletions(-)
tests/qemu-iotests/234 +7 -23
index c4c26bc21e..34c818c485 100755
@@ -26,22 +26,6 @@ import os
 iotests.verify_image_format(supported_fmts=['qcow2'])
 iotests.verify_platform(['linux'])
 
-def enable_migration_events(vm, name):
-    iotests.log('Enabling migration QMP events on %s...' % name)
-    iotests.log(vm.qmp('migrate-set-capabilities', capabilities=[
-        {
-            'capability': 'events',
-            'state': True
-        }
-    ]))
-
-def wait_migration(vm):
-    while True:
-        event = vm.event_wait('MIGRATION')
-        iotests.log(event, filters=[iotests.filter_qmp_event])
-        if event['data']['status'] == 'completed':
-            break
-
 with iotests.FilePath('img') as img_path, \
      iotests.FilePath('backing') as backing_path, \
      iotests.FilePath('mig_fifo_a') as fifo_a, \
@@ -62,7 +46,7 @@ with iotests.FilePath('img') as img_path, \
          .add_blockdev('%s,file=drive0-backing-file,node-name=drive0-backing' % (iotests.imgfmt))
          .launch())
 
-    enable_migration_events(vm_a, 'A')
+    vm_a.enable_migration_events('A')
 
     iotests.log('Launching destination VM...')
     (vm_b.add_blockdev('file,filename=%s,node-name=drive0-file' % (img_path))
@@ -72,7 +56,7 @@ with iotests.FilePath('img') as img_path, \
          .add_incoming("exec: cat '%s'" % (fifo_a))
          .launch())
 
-    enable_migration_events(vm_b, 'B')
+    vm_b.enable_migration_events('B')
 
     # Add a child node that was created after the parent node. The reverse case
     # is covered by the -blockdev options above.
@@ -85,9 +69,9 @@ with iotests.FilePath('img') as img_path, \
     iotests.log(vm_a.qmp('migrate', uri='exec:cat >%s' % (fifo_a)))
     with iotests.Timeout(3, 'Migration does not complete'):
         # Wait for the source first (which includes setup=setup)
-        wait_migration(vm_a)
+        vm_a.wait_migration()
         # Wait for the destination second (which does not)
-        wait_migration(vm_b)
+        vm_b.wait_migration()
 
     iotests.log(vm_a.qmp('query-migrate')['return']['status'])
     iotests.log(vm_b.qmp('query-migrate')['return']['status'])
@@ -105,7 +89,7 @@ with iotests.FilePath('img') as img_path, \
          .add_incoming("exec: cat '%s'" % (fifo_b))
          .launch())
 
-    enable_migration_events(vm_a, 'A')
+    vm_a.enable_migration_events('A')
 
     iotests.log(vm_a.qmp('blockdev-snapshot', node='drive0-backing',
                          overlay='drive0'))
@@ -114,9 +98,9 @@ with iotests.FilePath('img') as img_path, \
     iotests.log(vm_b.qmp('migrate', uri='exec:cat >%s' % (fifo_b)))
     with iotests.Timeout(3, 'Migration does not complete'):
         # Wait for the source first (which includes setup=setup)
-        wait_migration(vm_b)
+        vm_b.wait_migration()
         # Wait for the destination second (which does not)
-        wait_migration(vm_a)
+        vm_a.wait_migration()
 
     iotests.log(vm_a.qmp('query-migrate')['return']['status'])
     iotests.log(vm_b.qmp('query-migrate')['return']['status'])
tests/qemu-iotests/iotests.py +16 -0
index ce74177ab1..91172c39a5 100644
@@ -583,6 +583,22 @@ class VM(qtest.QEMUQtestMachine):
             elif status == 'null':
                 return error
 
+    def enable_migration_events(self, name):
+        log('Enabling migration QMP events on %s...' % name)
+        log(self.qmp('migrate-set-capabilities', capabilities=[
+            {
+                'capability': 'events',
+                'state': True
+            }
+        ]))
+
+    def wait_migration(self):
+        while True:
+            event = self.event_wait('MIGRATION')
+            log(event, filters=[filter_qmp_event])
+            if event['data']['status'] == 'completed':
+                break
+
     def node_info(self, node_name):
         nodes = self.qmp('query-named-block-nodes')
         for x in nodes['return']:
Signature · 1 line
2.20.1
Reviewed-by on v1 1/3
#2 lore raw

Re: [Qemu-devel] [PATCH 1/3] iotests: Move migration helpers to iotests.py

Quoted 8 lines · Kevin Wolf

234 implements functions that are useful for doing migration between two VMs. Move them to iotests.py so that other test cases can use them, too.

---
 tests/qemu-iotests/234        | 30 +++++++-----------------------
 tests/qemu-iotests/iotests.py | 16 ++++++++++++++++
 2 files changed, 23 insertions(+), 23 deletions(-)
author
#3 lore raw

PATCH 2/3 iotests: Enable -d for Python non-unittest tests

In reply to Kevin Wolf

The part of iotests.main() that is related to the implementation of the debug option -d and enables QEMU and QMP logging is not only useful in tests that use the Python unittest framework, but also in tests that work by comparing with a reference output.

Factor these parts out into iotests.init() and call it from the test cases that currently lack support for debug output.

---
 tests/qemu-iotests/194        |  1 +
 tests/qemu-iotests/202        |  1 +
 tests/qemu-iotests/203        |  2 ++
 tests/qemu-iotests/206        |  1 +
 tests/qemu-iotests/207        |  1 +
 tests/qemu-iotests/208        |  1 +
 tests/qemu-iotests/210        |  1 +
 tests/qemu-iotests/211        |  1 +
 tests/qemu-iotests/212        |  1 +
 tests/qemu-iotests/213        |  1 +
 tests/qemu-iotests/216        |  2 ++
 tests/qemu-iotests/218        |  1 +
 tests/qemu-iotests/219        |  1 +
 tests/qemu-iotests/222        |  1 +
 tests/qemu-iotests/224        |  2 ++
 tests/qemu-iotests/228        |  2 ++
 tests/qemu-iotests/234        |  2 ++
 tests/qemu-iotests/236        |  1 +
 tests/qemu-iotests/237        |  1 +
 tests/qemu-iotests/246        |  1 +
 tests/qemu-iotests/255        |  1 +
 tests/qemu-iotests/256        |  1 +
 tests/qemu-iotests/iotests.py | 23 +++++++++++++++--------
 23 files changed, 42 insertions(+), 8 deletions(-)
tests/qemu-iotests/194 +1 -0
index d746ab1e21..cd6928fbd9 100755
@@ -21,6 +21,7 @@
 
 import iotests
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['qcow2', 'qed', 'raw'])
 iotests.verify_platform(['linux'])
 
tests/qemu-iotests/202 +1 -0
index 581ca34d79..86a3b94586 100755
@@ -24,6 +24,7 @@
 
 import iotests
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['qcow2'])
 iotests.verify_platform(['linux'])
 
tests/qemu-iotests/203 +2 -0
index 4874a1a0d8..fe25c249fb 100755
@@ -27,6 +27,8 @@ import iotests
 iotests.verify_image_format(supported_fmts=['qcow2'])
 iotests.verify_platform(['linux'])
 
+iotests.init()
+
 with iotests.FilePath('disk0.img') as disk0_img_path, \
      iotests.FilePath('disk1.img') as disk1_img_path, \
      iotests.VM() as vm:
tests/qemu-iotests/206 +1 -0
index 5bb738bf23..481e4b98ea 100755
@@ -23,6 +23,7 @@
 import iotests
 from iotests import imgfmt
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['qcow2'])
 
 def blockdev_create(vm, options):
tests/qemu-iotests/207 +1 -0
index ec8c1d06f0..57c1e900d2 100755
@@ -24,6 +24,7 @@ import iotests
 import subprocess
 import re
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['raw'])
 iotests.verify_protocol(supported=['ssh'])
 
tests/qemu-iotests/208 +1 -0
index 1e202388dc..3b2c732cd4 100755
@@ -22,6 +22,7 @@
 
 import iotests
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['generic'])
 
 with iotests.FilePath('disk.img') as disk_img_path, \
tests/qemu-iotests/210 +1 -0
index 565e3b7b9b..a90db1c067 100755
@@ -23,6 +23,7 @@
 import iotests
 from iotests import imgfmt
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['luks'])
 iotests.verify_protocol(supported=['file'])
 
tests/qemu-iotests/211 +1 -0
index 6afc894f76..e6a0bef332 100755
@@ -23,6 +23,7 @@
 import iotests
 from iotests import imgfmt
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['vdi'])
 iotests.verify_protocol(supported=['file'])
 
tests/qemu-iotests/212 +1 -0
index 42b74f208b..865674191c 100755
@@ -23,6 +23,7 @@
 import iotests
 from iotests import imgfmt
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['parallels'])
 iotests.verify_protocol(supported=['file'])
 
tests/qemu-iotests/213 +1 -0
index 5604f3cebb..8fb94147ff 100755
@@ -23,6 +23,7 @@
 import iotests
 from iotests import imgfmt
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['vhdx'])
 iotests.verify_protocol(supported=['file'])
 
tests/qemu-iotests/216 +2 -0
index 3c0ae54b44..adcb487fb4 100755
@@ -22,6 +22,8 @@
 import iotests
 from iotests import log, qemu_img, qemu_io_silent
 
+iotests.init()
+
 # Need backing file support
 iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk'])
 iotests.verify_platform(['linux'])
tests/qemu-iotests/218 +1 -0
index 2554d84581..18639020ee 100755
@@ -29,6 +29,7 @@
 import iotests
 from iotests import log, qemu_img, qemu_io_silent
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['qcow2', 'raw'])
 
 
tests/qemu-iotests/219 +1 -0
index e0c51662c0..c7265d12c5 100755
@@ -21,6 +21,7 @@
 
 import iotests
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['qcow2'])
 
 img_size = 4 * 1024 * 1024
tests/qemu-iotests/222 +1 -0
index 0ead56d574..bb2b8cc78a 100644
@@ -24,6 +24,7 @@
 import iotests
 from iotests import log, qemu_img, qemu_io, qemu_io_silent
 
+iotests.init()
 iotests.verify_platform(['linux'])
 iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk',
                                             'vhdx', 'raw'])
tests/qemu-iotests/224 +2 -0
index b4dfaa639f..00013473a8 100755
@@ -25,6 +25,8 @@ from iotests import log, qemu_img, qemu_io_silent, filter_qmp_testfiles, \
                     filter_qmp_imgfmt
 import json
 
+iotests.init()
+
 # Need backing file support (for arbitrary backing formats)
 iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed'])
 iotests.verify_platform(['linux'])
tests/qemu-iotests/228 +2 -0
index 9a50afd205..9b9acf8be5 100755
@@ -24,6 +24,8 @@ import iotests
 from iotests import log, qemu_img, filter_testfiles, filter_imgfmt, \
         filter_qmp_testfiles, filter_qmp_imgfmt
 
+iotests.init()
+
 # Need backing file and change-backing-file support
 iotests.verify_image_format(supported_fmts=['qcow2', 'qed'])
 iotests.verify_platform(['linux'])
tests/qemu-iotests/234 +2 -0
index 34c818c485..17c03d2f6a 100755
@@ -26,6 +26,8 @@ import os
 iotests.verify_image_format(supported_fmts=['qcow2'])
 iotests.verify_platform(['linux'])
 
+iotests.init()
+
 with iotests.FilePath('img') as img_path, \
      iotests.FilePath('backing') as backing_path, \
      iotests.FilePath('mig_fifo_a') as fifo_a, \
tests/qemu-iotests/236 +1 -0
index 79a6381f8e..15ef48f0b6 100755
@@ -22,6 +22,7 @@
 import iotests
 from iotests import log
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['generic'])
 size = 64 * 1024 * 1024
 granularity = 64 * 1024
tests/qemu-iotests/237 +1 -0
index 06897f8c87..cbaaeed9eb 100755
@@ -24,6 +24,7 @@ import math
 import iotests
 from iotests import imgfmt
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['vmdk'])
 
 def blockdev_create(vm, options):
tests/qemu-iotests/246 +1 -0
index b0997a392f..7f6da5dced 100755
@@ -22,6 +22,7 @@
 import iotests
 from iotests import log
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['qcow2'])
 size = 64 * 1024 * 1024 * 1024
 gran_small = 32 * 1024
tests/qemu-iotests/255 +1 -0
index 3632d507d0..099617ab59 100755
@@ -23,6 +23,7 @@
 import iotests
 from iotests import imgfmt
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['qcow2'])
 
 def blockdev_create(vm, options):
tests/qemu-iotests/256 +1 -0
index c594a43205..e15f1b1a8a 100755
@@ -23,6 +23,7 @@ import os
 import iotests
 from iotests import log
 
+iotests.init()
 iotests.verify_image_format(supported_fmts=['qcow2'])
 size = 64 * 1024 * 1024
 
tests/qemu-iotests/iotests.py +15 -8
index 91172c39a5..f2ad2b9749 100644
@@ -858,10 +858,7 @@ def skip_if_unsupported(required_formats=[], read_only=False):
         return func_wrapper
     return skip_test_decorator
 
-def main(supported_fmts=[], supported_oses=['linux'], supported_cache_modes=[],
-         unsupported_fmts=[]):
-    '''Run tests'''
-
+def init():
     global debug
 
     # We are using TEST_DIR and QEMU_DEFAULT_MACHINE as proxies to
@@ -873,7 +870,19 @@ def main(supported_fmts=[], supported_oses=['linux'], supported_cache_modes=[],
         sys.exit(os.EX_USAGE)
 
     debug = '-d' in sys.argv
-    verbosity = 1
+    if debug:
+        sys.argv.remove('-d')
+
+    logging.basicConfig(level=(logging.DEBUG if debug else logging.WARN))
+
+def main(supported_fmts=[], supported_oses=['linux'], supported_cache_modes=[],
+         unsupported_fmts=[]):
+    '''Run tests'''
+
+    global debug
+
+    init()
+
     verify_image_format(supported_fmts, unsupported_fmts)
     verify_platform(supported_oses)
     verify_cache_mode(supported_cache_modes)
@@ -881,8 +890,8 @@ def main(supported_fmts=[], supported_oses=['linux'], supported_cache_modes=[],
     if debug:
         output = sys.stdout
         verbosity = 2
-        sys.argv.remove('-d')
     else:
+        verbosity = 1
         # We need to filter out the time taken from the output so that
         # qemu-iotest can reliably diff the results against master output.
         if sys.version_info.major >= 3:
@@ -892,8 +901,6 @@ def main(supported_fmts=[], supported_oses=['linux'], supported_cache_modes=[],
             # 2.x's test runner emits.
             output = io.BytesIO()
 
-    logging.basicConfig(level=(logging.DEBUG if debug else logging.WARN))
-
     class MyTestRunner(unittest.TextTestRunner):
         def __init__(self, stream=output, descriptions=True, verbosity=verbosity):
             unittest.TextTestRunner.__init__(self, stream, descriptions, verbosity)
Signature · 1 line
2.20.1
#4 lore raw

Re: [Qemu-devel] [PATCH 2/3] iotests: Enable -d for Python non-unittest tests

Quoted 7 lines · Kevin Wolf

The part of iotests.main() that is related to the implementation of the debug option -d and enables QEMU and QMP logging is not only useful in tests that use the Python unittest framework, but also in tests that work by comparing with a reference output.

Factor these parts out into iotests.init() and call it from the test cases that currently lack support for debug output.

How does this relate to
https://lists.nongnu.org/archive/html/qemu-block/2019-07/msg01212.html ?

Max

author
#5 lore raw

Re: [Qemu-devel] [PATCH 2/3] iotests: Enable -d for Python non-unittest tests

Am 01.08.2019 um 19:57 hat Max Reitz geschrieben:

Quoted 11 lines · Kevin Wolf
Quoted 7 lines

The part of iotests.main() that is related to the implementation of the debug option -d and enables QEMU and QMP logging is not only useful in tests that use the Python unittest framework, but also in tests that work by comparing with a reference output.

Factor these parts out into iotests.init() and call it from the test cases that currently lack support for debug output.

How does this relate to
https://lists.nongnu.org/archive/html/qemu-block/2019-07/msg01212.html ?

Hm, no idea? :-)

Looks like John's patch depends on some other patches which would then conflict with mine, too, so maybe I'll just drop my patch and wait what happens?

John, any opinion?

Kevin

#6 lore raw

Re: [Qemu-devel] [PATCH 2/3] iotests: Enable -d for Python non-unittest tests

Quoted 15 lines · Kevin Wolf

Am 01.08.2019 um 19:57 hat Max Reitz geschrieben:

Quoted 11 lines · Kevin Wolf
Quoted 7 lines

The part of iotests.main() that is related to the implementation of the debug option -d and enables QEMU and QMP logging is not only useful in tests that use the Python unittest framework, but also in tests that work by comparing with a reference output.

Factor these parts out into iotests.init() and call it from the test cases that currently lack support for debug output.

How does this relate to
https://lists.nongnu.org/archive/html/qemu-block/2019-07/msg01212.html ?

Hm, no idea? :-)

Quoted 8 lines

Looks like John's patch depends on some other patches which would then conflict with mine, too, so maybe I'll just drop my patch and wait what happens?

John, any opinion?

Kevin

My patches do roughly the same plus a little more. If you don't mind waiting, I can take care of this for you when the tree reopens?

--js

author
#7 lore raw

Re: [Qemu-devel] [PATCH 2/3] iotests: Enable -d for Python non-unittest tests

Am 06.08.2019 um 00:19 hat John Snow geschrieben:

Quoted 22 lines · Kevin Wolf
Quoted 19 lines

Am 01.08.2019 um 19:57 hat Max Reitz geschrieben:

Quoted 11 lines · Kevin Wolf
Quoted 7 lines

The part of iotests.main() that is related to the implementation of the debug option -d and enables QEMU and QMP logging is not only useful in tests that use the Python unittest framework, but also in tests that work by comparing with a reference output.

Factor these parts out into iotests.init() and call it from the test cases that currently lack support for debug output.

How does this relate to
https://lists.nongnu.org/archive/html/qemu-block/2019-07/msg01212.html ?

Hm, no idea? :-)

Looks like John's patch depends on some other patches which would then conflict with mine, too, so maybe I'll just drop my patch and wait what happens?

Quoted 7 lines
Quoted 4 lines

John, any opinion?

Kevin

My patches do roughly the same plus a little more. If you don't mind waiting, I can take care of this for you when the tree reopens?

Okay, I'll drop my patch then.

Kevin

#8 lore raw

Re: [Qemu-devel] [PATCH 2/3] iotests: Enable -d for Python non-unittest tests

Quoted 28 lines · Kevin Wolf

Am 06.08.2019 um 00:19 hat John Snow geschrieben:

Quoted 27 lines · Kevin Wolf
Quoted 23 lines

Am 01.08.2019 um 19:57 hat Max Reitz geschrieben:

Quoted 11 lines · Kevin Wolf
Quoted 7 lines

The part of iotests.main() that is related to the implementation of the debug option -d and enables QEMU and QMP logging is not only useful in tests that use the Python unittest framework, but also in tests that work by comparing with a reference output.

Factor these parts out into iotests.init() and call it from the test cases that currently lack support for debug output.

How does this relate to
https://lists.nongnu.org/archive/html/qemu-block/2019-07/msg01212.html ?

Hm, no idea? :-)

Looks like John's patch depends on some other patches which would then conflict with mine, too, so maybe I'll just drop my patch and wait what happens?

John, any opinion?

Kevin

Quoted 7 lines
Quoted 2 lines

My patches do roughly the same plus a little more. If you don't mind waiting, I can take care of this for you when the tree reopens?

Okay, I'll drop my patch then.

Kevin

Thank you! I will try to fix my bitmaps branch ASAP in light of the recent fixes and get this staged in an easy to test way for the 4.2 branch.

--js

author
#9 lore raw

PATCH 3/3 iotests: Test migration with all kinds of filter nodes

In reply to Kevin Wolf

This test case is motivated by commit 2b23f28639 ('block/copy-on-read:
Fix permissions for inactive node'). Instead of just testing copy-on-read on migration, let's stack all sorts of filter nodes on top of each other and try if the resulting VM can still migrate successfully. For good measure, put everything into an iothread, because why not?

---
 tests/qemu-iotests/262     | 84 ++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/262.out | 17 ++++++++
 tests/qemu-iotests/group   |  1 +
 3 files changed, 102 insertions(+)
 create mode 100755 tests/qemu-iotests/262
 create mode 100644 tests/qemu-iotests/262.out
tests/qemu-iotests/262 new file +84 -0
new file mode 100755
index 0000000000..dcd81a6059
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2019 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Creator/Owner: Kevin Wolf <[email protected]>
+#
+# Test migration with filter drivers present. Keep everything in an
+# iothread just for fun.
+
+import iotests
+import os
+
+iotests.verify_image_format(supported_fmts=['qcow2'])
+iotests.verify_platform(['linux'])
+
+iotests.init()
+
+with iotests.FilePath('img') as img_path, \
+     iotests.FilePath('mig_fifo') as fifo, \
+     iotests.VM(path_suffix='a') as vm_a, \
+     iotests.VM(path_suffix='b') as vm_b:
+
+    def add_opts(vm):
+        vm.add_object('iothread,id=iothread0')
+        vm.add_object('throttle-group,id=tg0,x-bps-total=65536')
+        vm.add_blockdev('file,filename=%s,node-name=drive0-file' % (img_path))
+        vm.add_blockdev('%s,file=drive0-file,node-name=drive0-fmt' % (iotests.imgfmt))
+        vm.add_blockdev('copy-on-read,file=drive0-fmt,node-name=drive0-cor')
+        vm.add_blockdev('throttle,file=drive0-cor,node-name=drive0-throttle,throttle-group=tg0')
+        vm.add_blockdev('blkdebug,image=drive0-throttle,node-name=drive0-dbg')
+        vm.add_blockdev('null-co,node-name=null,read-zeroes=on')
+        vm.add_blockdev('blkverify,test=drive0-dbg,raw=null,node-name=drive0-verify')
+
+        if iotests.supports_quorum():
+            vm.add_blockdev('quorum,children.0=drive0-verify,vote-threshold=1,node-name=drive0-quorum')
+            root = "drive0-quorum"
+        else:
+            root = "drive0-verify"
+
+        vm.add_device('virtio-blk,drive=%s,iothread=iothread0' % root)
+
+    iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, img_path, '64M')
+
+    os.mkfifo(fifo)
+
+    iotests.log('Launching source VM...')
+    add_opts(vm_a)
+    vm_a.launch()
+
+    vm_a.enable_migration_events('A')
+
+    iotests.log('Launching destination VM...')
+    add_opts(vm_b)
+    vm_b.add_incoming("exec: cat '%s'" % (fifo))
+    vm_b.launch()
+
+    vm_b.enable_migration_events('B')
+
+    iotests.log('Starting migration to B...')
+    iotests.log(vm_a.qmp('migrate', uri='exec:cat >%s' % (fifo)))
+    with iotests.Timeout(3, 'Migration does not complete'):
+        # Wait for the source first (which includes setup=setup)
+        vm_a.wait_migration()
+        # Wait for the destination second (which does not)
+        vm_b.wait_migration()
+
+    iotests.log(vm_a.qmp('query-migrate')['return']['status'])
+    iotests.log(vm_b.qmp('query-migrate')['return']['status'])
+
+    iotests.log(vm_a.qmp('query-status'))
+    iotests.log(vm_b.qmp('query-status'))
tests/qemu-iotests/262.out new file +17 -0
new file mode 100644
index 0000000000..5a58e5e9f8
@@ -0,0 +1,17 @@
+Launching source VM...
+Enabling migration QMP events on A...
+{"return": {}}
+Launching destination VM...
+Enabling migration QMP events on B...
+{"return": {}}
+Starting migration to B...
+{"return": {}}
+{"data": {"status": "setup"}, "event": "MIGRATION", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
+{"data": {"status": "active"}, "event": "MIGRATION", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
+{"data": {"status": "completed"}, "event": "MIGRATION", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
+{"data": {"status": "active"}, "event": "MIGRATION", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
+{"data": {"status": "completed"}, "event": "MIGRATION", "timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
+completed
+completed
+{"return": {"running": false, "singlestep": false, "status": "postmigrate"}}
+{"return": {"running": true, "singlestep": false, "status": "running"}}
tests/qemu-iotests/group +1 -0
index f13e5f2e23..71ba3c05dc 100644
@@ -271,3 +271,4 @@
 254 rw backing quick
 255 rw quick
 256 rw quick
+262 rw quick migration
Signature · 1 line
2.20.1
Reviewed-by on v1 3/3
#10 lore raw

Re: [Qemu-devel] [PATCH 3/3] iotests: Test migration with all kinds of filter nodes

Quoted 7 lines · Kevin Wolf

This test case is motivated by commit 2b23f28639 ('block/copy-on-read:
Fix permissions for inactive node'). Instead of just testing copy-on-read on migration, let's stack all sorts of filter nodes on top of each other and try if the resulting VM can still migrate successfully. For good measure, put everything into an iothread, because why not?

Quoted 8 lines
---
 tests/qemu-iotests/262     | 84 ++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/262.out | 17 ++++++++
 tests/qemu-iotests/group   |  1 +
 3 files changed, 102 insertions(+)
 create mode 100755 tests/qemu-iotests/262
 create mode 100644 tests/qemu-iotests/262.out