thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

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

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