[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 07/28] iotests: Test cancelling a job and closing the
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 07/28] iotests: Test cancelling a job and closing the VM |
Date: |
Mon, 3 Jun 2019 17:02:12 +0200 |
From: Max Reitz <address@hidden>
This patch adds a test where we cancel a throttled mirror job and
immediately close the VM before it can be cancelled. Doing so will
invoke bdrv_drain_all() while the mirror job tries to drain the
throttled node. When bdrv_drain_all_end() tries to lift its drain on
the throttle node, the job will exit and replace the current root node
of the BB drive0 (which is the job's filter node) by the throttle node.
Before the previous patch, this replacement did not increase drive0's
quiesce_counter by a sufficient amount, so when
bdrv_parent_drained_end() (invoked by bdrv_do_drained_end(), invoked by
bdrv_drain_all_end()) tried to end the drain on all of the throttle
node's parents, it decreased drive0's quiesce_counter below 0 -- which
fails an assertion.
Signed-off-by: Max Reitz <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
tests/qemu-iotests/255 | 52 ++++++++++++++++++++++++++++++++++++++
tests/qemu-iotests/255.out | 24 ++++++++++++++++++
2 files changed, 76 insertions(+)
diff --git a/tests/qemu-iotests/255 b/tests/qemu-iotests/255
index c0bb37a9b0..49433ec122 100755
--- a/tests/qemu-iotests/255
+++ b/tests/qemu-iotests/255
@@ -35,6 +35,10 @@ def blockdev_create(vm, options):
vm.run_job('job0')
iotests.log("")
+iotests.log('Finishing a commit job with background reads')
+iotests.log('============================================')
+iotests.log('')
+
with iotests.FilePath('t.qcow2') as disk_path, \
iotests.FilePath('t.qcow2.mid') as mid_path, \
iotests.FilePath('t.qcow2.base') as base_path, \
@@ -81,3 +85,51 @@ with iotests.FilePath('t.qcow2') as disk_path, \
auto_dismiss=True)
vm.shutdown()
+
+iotests.log('')
+iotests.log('Closing the VM while a job is being cancelled')
+iotests.log('=============================================')
+iotests.log('')
+
+with iotests.FilePath('src.qcow2') as src_path, \
+ iotests.FilePath('dst.qcow2') as dst_path, \
+ iotests.VM() as vm:
+
+ iotests.log('=== Create images and start VM ===')
+ iotests.log('')
+
+ size = 128 * 1024 * 1024
+ size_str = str(size)
+
+ iotests.qemu_img_log('create', '-f', iotests.imgfmt, src_path, size_str)
+ iotests.qemu_img_log('create', '-f', iotests.imgfmt, dst_path, size_str)
+
+ iotests.log(iotests.qemu_io('-f', iotests.imgfmt, '-c', 'write 0 1M',
+ src_path),
+ filters=[iotests.filter_test_dir, iotests.filter_qemu_io])
+
+ vm.add_object('throttle-group,x-bps-read=4096,id=throttle0')
+
+ vm.add_blockdev('file,node-name=src-file,filename=%s' % (src_path))
+ vm.add_blockdev('%s,node-name=src,file=src-file' % (iotests.imgfmt))
+
+ vm.add_blockdev('file,node-name=dst-file,filename=%s' % (dst_path))
+ vm.add_blockdev('%s,node-name=dst,file=dst-file' % (iotests.imgfmt))
+
+ vm.add_blockdev('throttle,node-name=src-throttled,' +
+ 'throttle-group=throttle0,file=src')
+
+ vm.add_device('virtio-blk,drive=src-throttled')
+
+ vm.launch()
+
+ iotests.log('=== Start a mirror job ===')
+ iotests.log('')
+
+ vm.qmp_log('blockdev-mirror', job_id='job0', device='src-throttled',
+ target='dst', sync='full')
+
+ vm.qmp_log('block-job-cancel', device='job0')
+ vm.qmp_log('quit')
+
+ vm.shutdown()
diff --git a/tests/qemu-iotests/255.out b/tests/qemu-iotests/255.out
index 9a2d7cbb77..348909fdef 100644
--- a/tests/qemu-iotests/255.out
+++ b/tests/qemu-iotests/255.out
@@ -1,3 +1,6 @@
+Finishing a commit job with background reads
+============================================
+
=== Create backing chain and start VM ===
Formatting 'TEST_DIR/PID-t.qcow2.mid', fmt=qcow2 size=134217728
cluster_size=65536 lazy_refcounts=off refcount_bits=16
@@ -14,3 +17,24 @@ Formatting 'TEST_DIR/PID-t.qcow2', fmt=qcow2 size=134217728
cluster_size=65536 l
{"return": {}}
{"data": {"id": "job0", "type": "commit"}, "event": "BLOCK_JOB_PENDING",
"timestamp": {"microseconds": "USECS", "seconds": "SECS"}}
{"data": {"device": "job0", "len": 134217728, "offset": 134217728, "speed": 0,
"type": "commit"}, "event": "BLOCK_JOB_COMPLETED", "timestamp":
{"microseconds": "USECS", "seconds": "SECS"}}
+
+Closing the VM while a job is being cancelled
+=============================================
+
+=== Create images and start VM ===
+
+Formatting 'TEST_DIR/PID-src.qcow2', fmt=qcow2 size=134217728
cluster_size=65536 lazy_refcounts=off refcount_bits=16
+
+Formatting 'TEST_DIR/PID-dst.qcow2', fmt=qcow2 size=134217728
cluster_size=65536 lazy_refcounts=off refcount_bits=16
+
+wrote 1048576/1048576 bytes at offset 0
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+=== Start a mirror job ===
+
+{"execute": "blockdev-mirror", "arguments": {"device": "src-throttled",
"job-id": "job0", "sync": "full", "target": "dst"}}
+{"return": {}}
+{"execute": "block-job-cancel", "arguments": {"device": "job0"}}
+{"return": {}}
+{"execute": "quit", "arguments": {}}
+{"return": {}}
--
2.20.1
- [Qemu-block] [PULL 00/28] Block layer patches, Kevin Wolf, 2019/06/03
- [Qemu-block] [PULL 01/28] block: Drain source node in bdrv_replace_node(), Kevin Wolf, 2019/06/03
- [Qemu-block] [PULL 03/28] blockdev: fix missed target unref for drive-backup, Kevin Wolf, 2019/06/03
- [Qemu-block] [PULL 04/28] tests/perf: Test lseek influence on qcow2 block-status, Kevin Wolf, 2019/06/03
- [Qemu-block] [PULL 02/28] iotests: Test commit job start with concurrent I/O, Kevin Wolf, 2019/06/03
- [Qemu-block] [PULL 05/28] block: avoid recursive block_status call if possible, Kevin Wolf, 2019/06/03
- [Qemu-block] [PULL 06/28] block/io: Delay decrementing the quiesce_counter, Kevin Wolf, 2019/06/03
- [Qemu-block] [PULL 08/28] block/linux-aio: Drop unused BlockAIOCB submission method, Kevin Wolf, 2019/06/03
- [Qemu-block] [PULL 09/28] nvme: add Get/Set Feature Timestamp support, Kevin Wolf, 2019/06/03
- [Qemu-block] [PULL 07/28] iotests: Test cancelling a job and closing the VM,
Kevin Wolf <=
- [Qemu-block] [PULL 10/28] test-block-iothread: Check filter node in test_propagate_mirror, Kevin Wolf, 2019/06/03
- [Qemu-block] [PULL 12/28] block: Add Error to blk_set_aio_context(), Kevin Wolf, 2019/06/03
- [Qemu-block] [PULL 11/28] nbd-server: Call blk_set_allow_aio_context_change(), Kevin Wolf, 2019/06/03
- [Qemu-block] [PULL 13/28] block: Add BlockBackend.ctx, Kevin Wolf, 2019/06/03
- [Qemu-block] [PULL 14/28] block: Add qdev_prop_drive_iothread property type, Kevin Wolf, 2019/06/03
- [Qemu-block] [PULL 15/28] scsi-disk: Use qdev_prop_drive_iothread, Kevin Wolf, 2019/06/03
- [Qemu-block] [PULL 17/28] test-block-iothread: Test adding parent to iothread node, Kevin Wolf, 2019/06/03
- [Qemu-block] [PULL 19/28] block: Move node without parents to main AioContext, Kevin Wolf, 2019/06/03
- [Qemu-block] [PULL 16/28] block: Adjust AioContexts when attaching nodes, Kevin Wolf, 2019/06/03
- [Qemu-block] [PULL 20/28] blockdev: Use bdrv_try_set_aio_context() for monitor commands, Kevin Wolf, 2019/06/03