cryptospore / rpms / qemu-kvm

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