yeahuh / rpms / qemu-kvm

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