Signed-off-by: Max Reitz <mre...@redhat.com> --- tests/qemu-iotests/151 | 56 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/151.out | 4 +-- 2 files changed, 58 insertions(+), 2 deletions(-)
diff --git a/tests/qemu-iotests/151 b/tests/qemu-iotests/151 index fe53b9f446..e5515c2d37 100755 --- a/tests/qemu-iotests/151 +++ b/tests/qemu-iotests/151 @@ -114,6 +114,62 @@ class TestActiveMirror(iotests.QMPTestCase): def testActiveIOFlushed(self): self.doActiveIO(True) + def testCOR(self): + # Fill the source image + self.vm.hmp_qemu_io('source', + 'write -P 1 0 %i' % self.image_len); + + # Start some background requests + for offset in range(0, self.image_len / 2, 1024 * 1024): + self.vm.hmp_qemu_io('source', 'aio_write -P 2 %i 1M' % offset) + + # Start the block job + result = self.vm.qmp('blockdev-mirror', + job_id='mirror', + filter_node_name='mirror-node', + device='source-node', + target='target-node', + sync='full', + copy_mode='write-blocking') + self.assert_qmp(result, 'return', {}) + + # Stop background request processing + result = self.vm.qmp('job-pause', id='mirror') + + result = self.vm.qmp('blockdev-add', + node_name='cor-node', + driver='copy-on-read', + file='mirror-node') + self.assert_qmp(result, 'return', {}) + + # Now read everything, thus synchronously copying it to the + # target + for offset in range(0, self.image_len, 1024 * 1024): + self.vm.hmp_qemu_io('cor-node', 'read %i 1M' % offset) + + # Resuming the job should make it READY immediately, because + # the read requests from cor-node above should have copied + # everything to target already. + # Set the job speed to 1 before resuming it, so that we can + # see that the READY event really comes immediately. + + result = self.vm.qmp('block-job-set-speed', + device='mirror', + speed=1) + self.assert_qmp(result, 'return', {}) + + result = self.vm.qmp('job-resume', id='mirror') + self.assert_qmp(result, 'return', {}) + + # Wait for the READY event; if we get a timeout here, reading + # from cor-node has failed to copy something to target + self.vm.event_wait(name='BLOCK_JOB_READY', timeout=5.0) + + self.vm.hmp_qemu_io('source', 'aio_flush') + self.potential_writes_in_flight = False + + self.complete_and_wait(drive='mirror', wait_ready=False) + if __name__ == '__main__': diff --git a/tests/qemu-iotests/151.out b/tests/qemu-iotests/151.out index fbc63e62f8..8d7e996700 100644 --- a/tests/qemu-iotests/151.out +++ b/tests/qemu-iotests/151.out @@ -1,5 +1,5 @@ -.. +... ---------------------------------------------------------------------- -Ran 2 tests +Ran 3 tests OK -- 2.17.1