]> git.proxmox.com Git - qemu.git/commit
block: fix streaming/closing race
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 30 Mar 2012 11:17:11 +0000 (13:17 +0200)
committerKevin Wolf <kwolf@redhat.com>
Thu, 5 Apr 2012 12:54:40 +0000 (14:54 +0200)
commit3e914655f268f627ef004a8f1ea0355311b5aca6
treed58c2d239b697aa5f7b87fd5074447317dbd8b80
parent12bde0eed6b740787bca2c998a838b20c556d0ec
block: fix streaming/closing race

Streaming can issue I/O while qcow2_close is running.  This causes the
L2 caches to become very confused or, alternatively, could cause a
segfault when the streaming coroutine is reentered after closing its
block device.  The fix is to cancel streaming jobs when closing their
underlying device.

The cancellation must be synchronous, on the other hand qemu_aio_wait
will not restart a coroutine that is sleeping in co_sleep.  So add
a flag saying whether streaming has in-flight I/O.  If the busy flag
is false, the coroutine is quiescent and, when cancelled, will not
issue any new I/O.

This protects streaming against closing, but not against deleting.
We have a reference count protecting us against concurrent deletion,
but I still added an assertion to ensure nothing bad happens.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c
block/stream.c
block_int.h