mirror of
https://github.com/qemu/qemu.git
synced 2024-11-23 19:03:38 +08:00
iotests: Add iothread cases to 155
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> Message-Id: <20200310113831.27293-7-kwolf@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
30dd65f307
commit
6a5f6403a1
@ -49,11 +49,14 @@ target_img = os.path.join(iotests.test_dir, 'target.' + iotests.imgfmt)
|
|||||||
# chain opened right away. If False, blockdev-add
|
# chain opened right away. If False, blockdev-add
|
||||||
# opens it without a backing file and job completion
|
# opens it without a backing file and job completion
|
||||||
# is supposed to open the backing chain.
|
# 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):
|
class BaseClass(iotests.QMPTestCase):
|
||||||
target_blockdev_backing = None
|
target_blockdev_backing = None
|
||||||
target_real_backing = None
|
target_real_backing = None
|
||||||
target_open_with_backing = True
|
target_open_with_backing = True
|
||||||
|
use_iothread = False
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
qemu_img('create', '-f', iotests.imgfmt, back0_img, '1440K')
|
qemu_img('create', '-f', iotests.imgfmt, back0_img, '1440K')
|
||||||
@ -69,7 +72,16 @@ class BaseClass(iotests.QMPTestCase):
|
|||||||
'file': {'driver': 'file',
|
'file': {'driver': 'file',
|
||||||
'filename': source_img}}
|
'filename': source_img}}
|
||||||
self.vm.add_blockdev(self.vm.qmp_to_opts(blockdev))
|
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.vm.launch()
|
||||||
|
|
||||||
self.assertIntactSourceBackingChain()
|
self.assertIntactSourceBackingChain()
|
||||||
@ -182,24 +194,21 @@ class MirrorBaseClass(BaseClass):
|
|||||||
def testFull(self):
|
def testFull(self):
|
||||||
self.runMirror('full')
|
self.runMirror('full')
|
||||||
|
|
||||||
node = self.findBlockNode('target',
|
node = self.findBlockNode('target', 'qdev0')
|
||||||
'/machine/peripheral/qdev0/virtio-backend')
|
|
||||||
self.assertCorrectBackingImage(node, None)
|
self.assertCorrectBackingImage(node, None)
|
||||||
self.assertIntactSourceBackingChain()
|
self.assertIntactSourceBackingChain()
|
||||||
|
|
||||||
def testTop(self):
|
def testTop(self):
|
||||||
self.runMirror('top')
|
self.runMirror('top')
|
||||||
|
|
||||||
node = self.findBlockNode('target',
|
node = self.findBlockNode('target', 'qdev0')
|
||||||
'/machine/peripheral/qdev0/virtio-backend')
|
|
||||||
self.assertCorrectBackingImage(node, back2_img)
|
self.assertCorrectBackingImage(node, back2_img)
|
||||||
self.assertIntactSourceBackingChain()
|
self.assertIntactSourceBackingChain()
|
||||||
|
|
||||||
def testNone(self):
|
def testNone(self):
|
||||||
self.runMirror('none')
|
self.runMirror('none')
|
||||||
|
|
||||||
node = self.findBlockNode('target',
|
node = self.findBlockNode('target', 'qdev0')
|
||||||
'/machine/peripheral/qdev0/virtio-backend')
|
|
||||||
self.assertCorrectBackingImage(node, source_img)
|
self.assertCorrectBackingImage(node, source_img)
|
||||||
self.assertIntactSourceBackingChain()
|
self.assertIntactSourceBackingChain()
|
||||||
|
|
||||||
@ -252,6 +261,9 @@ class TestBlockdevMirrorReopen(MirrorBaseClass):
|
|||||||
backing="backing")
|
backing="backing")
|
||||||
self.assert_qmp(result, 'return', {})
|
self.assert_qmp(result, 'return', {})
|
||||||
|
|
||||||
|
class TestBlockdevMirrorReopenIothread(TestBlockdevMirrorReopen):
|
||||||
|
use_iothread = True
|
||||||
|
|
||||||
# Attach the backing chain only during completion, with blockdev-snapshot
|
# Attach the backing chain only during completion, with blockdev-snapshot
|
||||||
class TestBlockdevMirrorSnapshot(MirrorBaseClass):
|
class TestBlockdevMirrorSnapshot(MirrorBaseClass):
|
||||||
cmd = 'blockdev-mirror'
|
cmd = 'blockdev-mirror'
|
||||||
@ -268,6 +280,9 @@ class TestBlockdevMirrorSnapshot(MirrorBaseClass):
|
|||||||
overlay="target")
|
overlay="target")
|
||||||
self.assert_qmp(result, 'return', {})
|
self.assert_qmp(result, 'return', {})
|
||||||
|
|
||||||
|
class TestBlockdevMirrorSnapshotIothread(TestBlockdevMirrorSnapshot):
|
||||||
|
use_iothread = True
|
||||||
|
|
||||||
class TestCommit(BaseClass):
|
class TestCommit(BaseClass):
|
||||||
existing = False
|
existing = False
|
||||||
|
|
||||||
@ -283,8 +298,7 @@ class TestCommit(BaseClass):
|
|||||||
|
|
||||||
self.vm.event_wait('BLOCK_JOB_COMPLETED')
|
self.vm.event_wait('BLOCK_JOB_COMPLETED')
|
||||||
|
|
||||||
node = self.findBlockNode(None,
|
node = self.findBlockNode(None, 'qdev0')
|
||||||
'/machine/peripheral/qdev0/virtio-backend')
|
|
||||||
self.assert_qmp(node, 'image' + '/backing-image' * 0 + '/filename',
|
self.assert_qmp(node, 'image' + '/backing-image' * 0 + '/filename',
|
||||||
back1_img)
|
back1_img)
|
||||||
self.assert_qmp(node, 'image' + '/backing-image' * 1 + '/filename',
|
self.assert_qmp(node, 'image' + '/backing-image' * 1 + '/filename',
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
.........................
|
...............................
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Ran 25 tests
|
Ran 31 tests
|
||||||
|
|
||||||
OK
|
OK
|
||||||
|
Loading…
Reference in New Issue
Block a user