thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-iotests-Refactor-blockdev-reopen-test-for-iothreads.patch

902636
From 7e23b64dc20b64ca6fa887cd06cc5e52374f6268 Mon Sep 17 00:00:00 2001
902636
From: Kevin Wolf <kwolf@redhat.com>
902636
Date: Fri, 13 Mar 2020 12:34:30 +0000
902636
Subject: [PATCH 10/20] iotests: Refactor blockdev-reopen test for iothreads
902636
902636
RH-Author: Kevin Wolf <kwolf@redhat.com>
902636
Message-id: <20200313123439.10548-5-kwolf@redhat.com>
902636
Patchwork-id: 94281
902636
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH v2 04/13] iotests: Refactor blockdev-reopen test for iothreads
902636
Bugzilla: 1790482 1805143
902636
RH-Acked-by: John Snow <jsnow@redhat.com>
902636
RH-Acked-by: Daniel P. Berrange <berrange@redhat.com>
902636
RH-Acked-by: Peter Krempa <pkrempa@redhat.com>
902636
902636
We'll want to test more than one successful case in the future, so
902636
prepare the test for that by a refactoring that runs each scenario in a
902636
separate VM.
902636
902636
test_iothreads_switch_{backing,overlay} currently produce errors, but
902636
these are cases that should actually work, by switching either the
902636
backing file node or the overlay node to the AioContext of the other
902636
node.
902636
902636
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
902636
Tested-by: Peter Krempa <pkrempa@redhat.com>
902636
Message-Id: <20200306141413.30705-2-kwolf@redhat.com>
902636
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
902636
(cherry picked from commit 97518e11c3d902a32386d33797044f6b79bccc6f)
902636
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
902636
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
902636
---
902636
 tests/qemu-iotests/245     | 47 ++++++++++++++++++++++++++++++++++++----------
902636
 tests/qemu-iotests/245.out |  4 ++--
902636
 2 files changed, 39 insertions(+), 12 deletions(-)
902636
902636
diff --git a/tests/qemu-iotests/245 b/tests/qemu-iotests/245
902636
index e66a23c..f69c2fa 100644
902636
--- a/tests/qemu-iotests/245
902636
+++ b/tests/qemu-iotests/245
902636
@@ -968,8 +968,7 @@ class TestBlockdevReopen(iotests.QMPTestCase):
902636
         self.assertEqual(self.get_node('hd1'), None)
902636
         self.assert_qmp(self.get_node('hd2'), 'ro', True)
902636
 
902636
-    # We don't allow setting a backing file that uses a different AioContext
902636
-    def test_iothreads(self):
902636
+    def run_test_iothreads(self, iothread_a, iothread_b, errmsg = None):
902636
         opts = hd_opts(0)
902636
         result = self.vm.qmp('blockdev-add', conv_keys = False, **opts)
902636
         self.assert_qmp(result, 'return', {})
902636
@@ -984,20 +983,48 @@ class TestBlockdevReopen(iotests.QMPTestCase):
902636
         result = self.vm.qmp('object-add', qom_type='iothread', id='iothread1')
902636
         self.assert_qmp(result, 'return', {})
902636
 
902636
-        result = self.vm.qmp('x-blockdev-set-iothread', node_name='hd0', iothread='iothread0')
902636
+        result = self.vm.qmp('device_add', driver='virtio-scsi', id='scsi0',
902636
+                             iothread=iothread_a)
902636
         self.assert_qmp(result, 'return', {})
902636
 
902636
-        self.reopen(opts, {'backing': 'hd2'}, "Cannot use a new backing file with a different AioContext")
902636
-
902636
-        result = self.vm.qmp('x-blockdev-set-iothread', node_name='hd2', iothread='iothread1')
902636
+        result = self.vm.qmp('device_add', driver='virtio-scsi', id='scsi1',
902636
+                             iothread=iothread_b)
902636
         self.assert_qmp(result, 'return', {})
902636
 
902636
-        self.reopen(opts, {'backing': 'hd2'}, "Cannot use a new backing file with a different AioContext")
902636
+        if iothread_a:
902636
+            result = self.vm.qmp('device_add', driver='scsi-hd', drive='hd0',
902636
+                                 share_rw=True, bus="scsi0.0")
902636
+            self.assert_qmp(result, 'return', {})
902636
 
902636
-        result = self.vm.qmp('x-blockdev-set-iothread', node_name='hd2', iothread='iothread0')
902636
-        self.assert_qmp(result, 'return', {})
902636
+        if iothread_b:
902636
+            result = self.vm.qmp('device_add', driver='scsi-hd', drive='hd2',
902636
+                                 share_rw=True, bus="scsi1.0")
902636
+            self.assert_qmp(result, 'return', {})
902636
 
902636
-        self.reopen(opts, {'backing': 'hd2'})
902636
+        # Attaching the backing file may or may not work
902636
+        self.reopen(opts, {'backing': 'hd2'}, errmsg)
902636
+
902636
+        # But removing the backing file should always work
902636
+        self.reopen(opts, {'backing': None})
902636
+
902636
+        self.vm.shutdown()
902636
+
902636
+    # We don't allow setting a backing file that uses a different AioContext if
902636
+    # neither of them can switch to the other AioContext
902636
+    def test_iothreads_error(self):
902636
+        self.run_test_iothreads('iothread0', 'iothread1',
902636
+                                "Cannot use a new backing file with a different AioContext")
902636
+
902636
+    def test_iothreads_compatible_users(self):
902636
+        self.run_test_iothreads('iothread0', 'iothread0')
902636
+
902636
+    def test_iothreads_switch_backing(self):
902636
+        self.run_test_iothreads('iothread0', None,
902636
+                                "Cannot use a new backing file with a different AioContext")
902636
+
902636
+    def test_iothreads_switch_overlay(self):
902636
+        self.run_test_iothreads(None, 'iothread0',
902636
+                                "Cannot use a new backing file with a different AioContext")
902636
 
902636
 if __name__ == '__main__':
902636
     iotests.main(supported_fmts=["qcow2"],
902636
diff --git a/tests/qemu-iotests/245.out b/tests/qemu-iotests/245.out
902636
index a19de52..682b933 100644
902636
--- a/tests/qemu-iotests/245.out
902636
+++ b/tests/qemu-iotests/245.out
902636
@@ -1,6 +1,6 @@
902636
-..................
902636
+.....................
902636
 ----------------------------------------------------------------------
902636
-Ran 18 tests
902636
+Ran 21 tests
902636
 
902636
 OK
902636
 {"execute": "job-finalize", "arguments": {"id": "commit0"}}
902636
-- 
902636
1.8.3.1
902636