cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
ddf19c
From 2366cd9066e79d6c93a3a28710aea987b2c8f454 Mon Sep 17 00:00:00 2001
ddf19c
From: Kevin Wolf <kwolf@redhat.com>
ddf19c
Date: Fri, 13 Mar 2020 12:34:38 +0000
ddf19c
Subject: [PATCH 18/20] iotests: Add iothread cases to 155
ddf19c
ddf19c
RH-Author: Kevin Wolf <kwolf@redhat.com>
ddf19c
Message-id: <20200313123439.10548-13-kwolf@redhat.com>
ddf19c
Patchwork-id: 94289
ddf19c
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH v2 12/13] iotests: Add iothread cases to 155
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
This patch adds test cases for attaching the backing chain to a mirror
ddf19c
job target right before finalising the job, where the image is in a
ddf19c
non-mainloop AioContext (i.e. the backing chain needs to be moved to the
ddf19c
AioContext of the mirror target).
ddf19c
ddf19c
This requires switching the test case from virtio-blk to virtio-scsi
ddf19c
because virtio-blk only actually starts using the iothreads when the
ddf19c
guest driver initialises the device (which never happens in a test case
ddf19c
without a guest OS). virtio-scsi always keeps its block nodes in the
ddf19c
AioContext of the the requested iothread without guest interaction.
ddf19c
ddf19c
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ddf19c
Message-Id: <20200310113831.27293-7-kwolf@redhat.com>
ddf19c
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
ddf19c
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ddf19c
(cherry picked from commit 6a5f6403a11307794ec79d277a065c137cfc12b2)
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/155     | 32 +++++++++++++++++++++++---------
ddf19c
 tests/qemu-iotests/155.out |  4 ++--
ddf19c
 2 files changed, 25 insertions(+), 11 deletions(-)
ddf19c
ddf19c
diff --git a/tests/qemu-iotests/155 b/tests/qemu-iotests/155
ddf19c
index 3053e50..b552d1f 100755
ddf19c
--- a/tests/qemu-iotests/155
ddf19c
+++ b/tests/qemu-iotests/155
ddf19c
@@ -49,11 +49,14 @@ target_img = os.path.join(iotests.test_dir, 'target.' + iotests.imgfmt)
ddf19c
 #                           chain opened right away. If False, blockdev-add
ddf19c
 #                           opens it without a backing file and job completion
ddf19c
 #                           is supposed to open the backing chain.
ddf19c
+# use_iothread: If True, an iothread is configured for the virtio-blk device
ddf19c
+#               that uses the image being mirrored
ddf19c
 
ddf19c
 class BaseClass(iotests.QMPTestCase):
ddf19c
     target_blockdev_backing = None
ddf19c
     target_real_backing = None
ddf19c
     target_open_with_backing = True
ddf19c
+    use_iothread = False
ddf19c
 
ddf19c
     def setUp(self):
ddf19c
         qemu_img('create', '-f', iotests.imgfmt, back0_img, '1440K')
ddf19c
@@ -69,7 +72,16 @@ class BaseClass(iotests.QMPTestCase):
ddf19c
                     'file': {'driver': 'file',
ddf19c
                              'filename': source_img}}
ddf19c
         self.vm.add_blockdev(self.vm.qmp_to_opts(blockdev))
ddf19c
-        self.vm.add_device('virtio-blk,id=qdev0,drive=source')
ddf19c
+
ddf19c
+        if self.use_iothread:
ddf19c
+            self.vm.add_object('iothread,id=iothread0')
ddf19c
+            iothread = ",iothread=iothread0"
ddf19c
+        else:
ddf19c
+            iothread = ""
ddf19c
+
ddf19c
+        self.vm.add_device('virtio-scsi%s' % iothread)
ddf19c
+        self.vm.add_device('scsi-hd,id=qdev0,drive=source')
ddf19c
+
ddf19c
         self.vm.launch()
ddf19c
 
ddf19c
         self.assertIntactSourceBackingChain()
ddf19c
@@ -182,24 +194,21 @@ class MirrorBaseClass(BaseClass):
ddf19c
     def testFull(self):
ddf19c
         self.runMirror('full')
ddf19c
 
ddf19c
-        node = self.findBlockNode('target',
ddf19c
-                                  '/machine/peripheral/qdev0/virtio-backend')
ddf19c
+        node = self.findBlockNode('target', 'qdev0')
ddf19c
         self.assertCorrectBackingImage(node, None)
ddf19c
         self.assertIntactSourceBackingChain()
ddf19c
 
ddf19c
     def testTop(self):
ddf19c
         self.runMirror('top')
ddf19c
 
ddf19c
-        node = self.findBlockNode('target',
ddf19c
-                                  '/machine/peripheral/qdev0/virtio-backend')
ddf19c
+        node = self.findBlockNode('target', 'qdev0')
ddf19c
         self.assertCorrectBackingImage(node, back2_img)
ddf19c
         self.assertIntactSourceBackingChain()
ddf19c
 
ddf19c
     def testNone(self):
ddf19c
         self.runMirror('none')
ddf19c
 
ddf19c
-        node = self.findBlockNode('target',
ddf19c
-                                  '/machine/peripheral/qdev0/virtio-backend')
ddf19c
+        node = self.findBlockNode('target', 'qdev0')
ddf19c
         self.assertCorrectBackingImage(node, source_img)
ddf19c
         self.assertIntactSourceBackingChain()
ddf19c
 
ddf19c
@@ -252,6 +261,9 @@ class TestBlockdevMirrorReopen(MirrorBaseClass):
ddf19c
                                  backing="backing")
ddf19c
             self.assert_qmp(result, 'return', {})
ddf19c
 
ddf19c
+class TestBlockdevMirrorReopenIothread(TestBlockdevMirrorReopen):
ddf19c
+    use_iothread = True
ddf19c
+
ddf19c
 # Attach the backing chain only during completion, with blockdev-snapshot
ddf19c
 class TestBlockdevMirrorSnapshot(MirrorBaseClass):
ddf19c
     cmd = 'blockdev-mirror'
ddf19c
@@ -268,6 +280,9 @@ class TestBlockdevMirrorSnapshot(MirrorBaseClass):
ddf19c
                                  overlay="target")
ddf19c
             self.assert_qmp(result, 'return', {})
ddf19c
 
ddf19c
+class TestBlockdevMirrorSnapshotIothread(TestBlockdevMirrorSnapshot):
ddf19c
+    use_iothread = True
ddf19c
+
ddf19c
 class TestCommit(BaseClass):
ddf19c
     existing = False
ddf19c
 
ddf19c
@@ -283,8 +298,7 @@ class TestCommit(BaseClass):
ddf19c
 
ddf19c
         self.vm.event_wait('BLOCK_JOB_COMPLETED')
ddf19c
 
ddf19c
-        node = self.findBlockNode(None,
ddf19c
-                                  '/machine/peripheral/qdev0/virtio-backend')
ddf19c
+        node = self.findBlockNode(None, 'qdev0')
ddf19c
         self.assert_qmp(node, 'image' + '/backing-image' * 0 + '/filename',
ddf19c
                         back1_img)
ddf19c
         self.assert_qmp(node, 'image' + '/backing-image' * 1 + '/filename',
ddf19c
diff --git a/tests/qemu-iotests/155.out b/tests/qemu-iotests/155.out
ddf19c
index 4fd1c2d..ed714d5 100644
ddf19c
--- a/tests/qemu-iotests/155.out
ddf19c
+++ b/tests/qemu-iotests/155.out
ddf19c
@@ -1,5 +1,5 @@
ddf19c
-.........................
ddf19c
+...............................
ddf19c
 ----------------------------------------------------------------------
ddf19c
-Ran 25 tests
ddf19c
+Ran 31 tests
ddf19c
 
ddf19c
 OK
ddf19c
-- 
ddf19c
1.8.3.1
ddf19c