All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, pkrempa@redhat.com, qemu-devel@nongnu.org,
	mreitz@redhat.com
Subject: [PATCH v2 6/7] iotests: Add iothread cases to 155
Date: Tue, 10 Mar 2020 12:38:30 +0100	[thread overview]
Message-ID: <20200310113831.27293-7-kwolf@redhat.com> (raw)
In-Reply-To: <20200310113831.27293-1-kwolf@redhat.com>

This patch adds test cases for attaching the backing chain to a mirror
job target right before finalising the job, where the image is in a
non-mainloop AioContext (i.e. the backing chain needs to be moved to the
AioContext of the mirror target).

This requires switching the test case from virtio-blk to virtio-scsi
because virtio-blk only actually starts using the iothreads when the
guest driver initialises the device (which never happens in a test case
without a guest OS). virtio-scsi always keeps its block nodes in the
AioContext of the the requested iothread without guest interaction.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 tests/qemu-iotests/155     | 32 +++++++++++++++++++++++---------
 tests/qemu-iotests/155.out |  4 ++--
 2 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/tests/qemu-iotests/155 b/tests/qemu-iotests/155
index 74ddefc849..571bce9de4 100755
--- a/tests/qemu-iotests/155
+++ b/tests/qemu-iotests/155
@@ -49,11 +49,14 @@ target_img = os.path.join(iotests.test_dir, 'target.' + iotests.imgfmt)
 #                           chain opened right away. If False, blockdev-add
 #                           opens it without a backing file and job completion
 #                           is supposed to open the backing chain.
+# use_iothread: If True, an iothread is configured for the virtio-blk device
+#               that uses the image being mirrored
 
 class BaseClass(iotests.QMPTestCase):
     target_blockdev_backing = None
     target_real_backing = None
     target_open_with_backing = True
+    use_iothread = False
 
     def setUp(self):
         qemu_img('create', '-f', iotests.imgfmt, back0_img, '1440K')
@@ -69,7 +72,16 @@ class BaseClass(iotests.QMPTestCase):
                     'file': {'driver': 'file',
                              'filename': source_img}}
         self.vm.add_blockdev(self.vm.qmp_to_opts(blockdev))
-        self.vm.add_device('virtio-blk,id=qdev0,drive=source')
+
+        if self.use_iothread:
+            self.vm.add_object('iothread,id=iothread0')
+            iothread = ",iothread=iothread0"
+        else:
+            iothread = ""
+
+        self.vm.add_device('virtio-scsi%s' % iothread)
+        self.vm.add_device('scsi-hd,id=qdev0,drive=source')
+
         self.vm.launch()
 
         self.assertIntactSourceBackingChain()
@@ -182,24 +194,21 @@ class MirrorBaseClass(BaseClass):
     def testFull(self):
         self.runMirror('full')
 
-        node = self.findBlockNode('target',
-                                  '/machine/peripheral/qdev0/virtio-backend')
+        node = self.findBlockNode('target', 'qdev0')
         self.assertCorrectBackingImage(node, None)
         self.assertIntactSourceBackingChain()
 
     def testTop(self):
         self.runMirror('top')
 
-        node = self.findBlockNode('target',
-                                  '/machine/peripheral/qdev0/virtio-backend')
+        node = self.findBlockNode('target', 'qdev0')
         self.assertCorrectBackingImage(node, back2_img)
         self.assertIntactSourceBackingChain()
 
     def testNone(self):
         self.runMirror('none')
 
-        node = self.findBlockNode('target',
-                                  '/machine/peripheral/qdev0/virtio-backend')
+        node = self.findBlockNode('target', 'qdev0')
         self.assertCorrectBackingImage(node, source_img)
         self.assertIntactSourceBackingChain()
 
@@ -252,6 +261,9 @@ class TestBlockdevMirrorReopen(MirrorBaseClass):
                                  backing="backing")
             self.assert_qmp(result, 'return', {})
 
+class TestBlockdevMirrorReopenIothread(TestBlockdevMirrorReopen):
+    use_iothread = True
+
 # Attach the backing chain only during completion, with blockdev-snapshot
 class TestBlockdevMirrorSnapshot(MirrorBaseClass):
     cmd = 'blockdev-mirror'
@@ -268,6 +280,9 @@ class TestBlockdevMirrorSnapshot(MirrorBaseClass):
                                  overlay="target")
             self.assert_qmp(result, 'return', {})
 
+class TestBlockdevMirrorSnapshotIothread(TestBlockdevMirrorSnapshot):
+    use_iothread = True
+
 class TestCommit(BaseClass):
     existing = False
 
@@ -283,8 +298,7 @@ class TestCommit(BaseClass):
 
         self.vm.event_wait('BLOCK_JOB_COMPLETED')
 
-        node = self.findBlockNode(None,
-                                  '/machine/peripheral/qdev0/virtio-backend')
+        node = self.findBlockNode(None, 'qdev0')
         self.assert_qmp(node, 'image' + '/backing-image' * 0 + '/filename',
                         back1_img)
         self.assert_qmp(node, 'image' + '/backing-image' * 1 + '/filename',
diff --git a/tests/qemu-iotests/155.out b/tests/qemu-iotests/155.out
index 4fd1c2dcd2..ed714d5263 100644
--- a/tests/qemu-iotests/155.out
+++ b/tests/qemu-iotests/155.out
@@ -1,5 +1,5 @@
-.........................
+...............................
 ----------------------------------------------------------------------
-Ran 25 tests
+Ran 31 tests
 
 OK
-- 
2.20.1



  parent reply	other threads:[~2020-03-10 11:43 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-10 11:38 [PATCH v2 0/7] block: Relax restrictions for blockdev-snapshot Kevin Wolf
2020-03-10 11:38 ` [PATCH v2 1/7] block: Make bdrv_get_cumulative_perm() public Kevin Wolf
2020-03-10 13:10   ` Peter Krempa
2020-03-10 11:38 ` [PATCH v2 2/7] block: Relax restrictions for blockdev-snapshot Kevin Wolf
2020-03-10 13:15   ` Peter Krempa
2020-03-10 13:27     ` Kevin Wolf
2020-03-10 11:38 ` [PATCH v2 3/7] iotests: Fix run_job() with use_log=False Kevin Wolf
2020-03-10 13:16   ` Peter Krempa
2020-03-10 11:38 ` [PATCH v2 4/7] iotests: Test mirror with temporarily disabled target backing file Kevin Wolf
2020-03-10 13:25   ` Peter Krempa
2020-03-10 11:38 ` [PATCH v2 5/7] block: Fix cross-AioContext blockdev-snapshot Kevin Wolf
2020-03-10 13:27   ` Peter Krempa
2020-03-10 11:38 ` Kevin Wolf [this message]
2020-03-10 13:28   ` [PATCH v2 6/7] iotests: Add iothread cases to 155 Peter Krempa
2020-03-10 11:38 ` [PATCH v2 7/7] qapi: Add '@allow-write-only-overlay' feature for 'blockdev-snapshot' Kevin Wolf
2020-03-10 17:43 ` [PATCH v2 0/7] block: Relax restrictions for blockdev-snapshot Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200310113831.27293-7-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pkrempa@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.