cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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