Recently, a few bugs were reported that resulted from an inconsistent state regarding AioContexts. Block nodes can end up in different contexts than their users expect - the AioContext of a node can even change under the feet of a device with no way for the device to forbid this. We recently added a few basic checks to scsi-disk and virtio-blk, but they are by far not enough.
Part 1 solved the first half of the problem and made sure that AioContext changes are propagated through the graph as necessary, so that a bdrv_set_aio_context() correctly pulls everything that uses the node into the right context. This is part 2 that fixes the second half: Attaching new child nodes where the parent and child are already in different AioContexts. This operation may only succeed if we can move one of the node into the context of the other node. After applying this series, unchecked bdrv_set_aio_context() doesn't exist any more and all users call functions that make sure that the AioContext assignments across the graph stays consistent. Kevin Wolf (15): test-block-iothread: Check filter node in test_propagate_mirror block: Add Error to blk_set_aio_context() block: Add BlockBackend.ctx block: Add qdev_prop_drive_iothread property type scsi-disk: Use qdev_prop_drive_iothread block: Adjust AioContexts when attaching nodes test-block-iothread: Test adding parent to iothread node test-block-iothread: BlockBackend AioContext across root node change block: Move node without parents to main AioContext blockdev: Use bdrv_try_set_aio_context() for monitor commands block: Remove wrong bdrv_set_aio_context() calls virtio-scsi-test: Test attaching new overlay with iothreads iotests: Attach new devices to node in non-default iothread test-bdrv-drain: Use bdrv_try_set_aio_context() block: Remove bdrv_set_aio_context() docs/devel/multiple-iothreads.txt | 4 +- include/block/block.h | 9 --- include/block/block_int.h | 1 + include/hw/block/block.h | 7 +- include/hw/qdev-properties.h | 3 + include/hw/scsi/scsi.h | 1 + include/sysemu/block-backend.h | 5 +- tests/libqtest.h | 11 ++++ block.c | 70 ++++++++++++++------ block/backup.c | 3 +- block/block-backend.c | 47 +++++++++----- block/commit.c | 13 ++-- block/crypto.c | 3 +- block/mirror.c | 4 +- block/parallels.c | 3 +- block/qcow.c | 3 +- block/qcow2.c | 6 +- block/qed.c | 3 +- block/sheepdog.c | 3 +- block/vdi.c | 3 +- block/vhdx.c | 3 +- block/vmdk.c | 3 +- block/vpc.c | 3 +- blockdev.c | 48 ++++++++------ blockjob.c | 12 +++- hmp.c | 3 +- hw/block/dataplane/virtio-blk.c | 12 +++- hw/block/dataplane/xen-block.c | 6 +- hw/block/fdc.c | 2 +- hw/block/xen-block.c | 2 +- hw/core/qdev-properties-system.c | 41 +++++++++++- hw/ide/qdev.c | 2 +- hw/scsi/scsi-disk.c | 24 ++++--- hw/scsi/virtio-scsi.c | 25 ++++--- migration/block.c | 3 +- nbd/server.c | 5 +- tests/libqtest.c | 19 ++++++ tests/test-bdrv-drain.c | 50 +++++++------- tests/test-bdrv-graph-mod.c | 5 +- tests/test-block-backend.c | 4 +- tests/test-block-iothread.c | 104 +++++++++++++++++++++++++----- tests/test-blockjob.c | 2 +- tests/test-throttle.c | 6 +- tests/virtio-scsi-test.c | 62 ++++++++++++++++++ tests/qemu-iotests/051 | 24 +++++++ tests/qemu-iotests/051.out | 3 + tests/qemu-iotests/051.pc.out | 27 ++++++++ tests/qemu-iotests/240.out | 2 +- 48 files changed, 531 insertions(+), 173 deletions(-) -- 2.20.1