cryptospore / rpms / qemu-kvm

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