Blame SOURCES/kvm-iotests-Test-blockdev-reopen-with-iothreads-and-thro.patch

0727d3
From ea4d8424fb2053b1cbb9538190b2b06351054125 Mon Sep 17 00:00:00 2001
0727d3
From: Kevin Wolf <kwolf@redhat.com>
0727d3
Date: Thu, 3 Feb 2022 15:05:34 +0100
0727d3
Subject: [PATCH 3/5] iotests: Test blockdev-reopen with iothreads and
0727d3
 throttling
0727d3
0727d3
RH-Author: Kevin Wolf <kwolf@redhat.com>
0727d3
RH-MergeRequest: 142: block: Lock AioContext for drain_end in blockdev-reopen
0727d3
RH-Commit: [2/2] 91d365864c391ca7db7db13260913fb61987b833
0727d3
RH-Bugzilla: 2067118
0727d3
RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
0727d3
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
0727d3
RH-Acked-by: Hanna Reitz <hreitz@redhat.com>
0727d3
0727d3
The 'throttle' block driver implements .bdrv_co_drain_end, so
0727d3
blockdev-reopen will have to wait for it to complete in the polling
0727d3
loop at the end of qmp_blockdev_reopen(). This makes AIO_WAIT_WHILE()
0727d3
release the AioContext lock, which causes a crash if the lock hasn't
0727d3
correctly been taken.
0727d3
0727d3
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0727d3
Message-Id: <20220203140534.36522-3-kwolf@redhat.com>
0727d3
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
0727d3
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0727d3
(cherry picked from commit ee810602376125ca0e0afd6b7c715e13740978ea)
0727d3
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0727d3
---
0727d3
 tests/qemu-iotests/245     | 36 +++++++++++++++++++++++++++++++++---
0727d3
 tests/qemu-iotests/245.out |  4 ++--
0727d3
 2 files changed, 35 insertions(+), 5 deletions(-)
0727d3
0727d3
diff --git a/tests/qemu-iotests/245 b/tests/qemu-iotests/245
0727d3
index 24ac43f70e..8cbed7821b 100755
0727d3
--- a/tests/qemu-iotests/245
0727d3
+++ b/tests/qemu-iotests/245
0727d3
@@ -1138,12 +1138,13 @@ class TestBlockdevReopen(iotests.QMPTestCase):
0727d3
         self.assertEqual(self.get_node('hd1'), None)
0727d3
         self.assert_qmp(self.get_node('hd2'), 'ro', True)
0727d3
 
0727d3
-    def run_test_iothreads(self, iothread_a, iothread_b, errmsg = None):
0727d3
-        opts = hd_opts(0)
0727d3
+    def run_test_iothreads(self, iothread_a, iothread_b, errmsg = None,
0727d3
+                           opts_a = None, opts_b = None):
0727d3
+        opts = opts_a or hd_opts(0)
0727d3
         result = self.vm.qmp('blockdev-add', conv_keys = False, **opts)
0727d3
         self.assert_qmp(result, 'return', {})
0727d3
 
0727d3
-        opts2 = hd_opts(2)
0727d3
+        opts2 = opts_b or hd_opts(2)
0727d3
         result = self.vm.qmp('blockdev-add', conv_keys = False, **opts2)
0727d3
         self.assert_qmp(result, 'return', {})
0727d3
 
0727d3
@@ -1194,6 +1195,35 @@ class TestBlockdevReopen(iotests.QMPTestCase):
0727d3
     def test_iothreads_switch_overlay(self):
0727d3
         self.run_test_iothreads('', 'iothread0')
0727d3
 
0727d3
+    def test_iothreads_with_throttling(self):
0727d3
+        # Create a throttle-group object
0727d3
+        opts = { 'qom-type': 'throttle-group', 'id': 'group0',
0727d3
+                 'limits': { 'iops-total': 1000 } }
0727d3
+        result = self.vm.qmp('object-add', conv_keys = False, **opts)
0727d3
+        self.assert_qmp(result, 'return', {})
0727d3
+
0727d3
+        # Options with a throttle filter between format and protocol
0727d3
+        opts = [
0727d3
+            {
0727d3
+                'driver': iotests.imgfmt,
0727d3
+                'node-name': f'hd{idx}',
0727d3
+                'file' : {
0727d3
+                    'node-name': f'hd{idx}-throttle',
0727d3
+                    'driver': 'throttle',
0727d3
+                    'throttle-group': 'group0',
0727d3
+                    'file': {
0727d3
+                        'driver': 'file',
0727d3
+                        'node-name': f'hd{idx}-file',
0727d3
+                        'filename': hd_path[idx],
0727d3
+                    },
0727d3
+                },
0727d3
+            }
0727d3
+            for idx in (0, 2)
0727d3
+        ]
0727d3
+
0727d3
+        self.run_test_iothreads('iothread0', 'iothread0', None,
0727d3
+                                opts[0], opts[1])
0727d3
+
0727d3
 if __name__ == '__main__':
0727d3
     iotests.activate_logging()
0727d3
     iotests.main(supported_fmts=["qcow2"],
0727d3
diff --git a/tests/qemu-iotests/245.out b/tests/qemu-iotests/245.out
0727d3
index 4eced19294..a4e04a3266 100644
0727d3
--- a/tests/qemu-iotests/245.out
0727d3
+++ b/tests/qemu-iotests/245.out
0727d3
@@ -17,8 +17,8 @@ read 1/1 bytes at offset 262152
0727d3
 read 1/1 bytes at offset 262160
0727d3
 1 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
0727d3
 
0727d3
-...............
0727d3
+................
0727d3
 ----------------------------------------------------------------------
0727d3
-Ran 25 tests
0727d3
+Ran 26 tests
0727d3
 
0727d3
 OK
0727d3
-- 
0727d3
2.27.0
0727d3