mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 16:23:55 -06:00
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>
This commit is contained in:
parent
12bde0eed6
commit
3e914655f2
3 changed files with 22 additions and 2 deletions
|
@ -83,6 +83,7 @@ struct BlockJob {
|
|||
const BlockJobType *job_type;
|
||||
BlockDriverState *bs;
|
||||
bool cancelled;
|
||||
bool busy;
|
||||
|
||||
/* These fields are published by the query-block-jobs QMP API */
|
||||
int64_t offset;
|
||||
|
@ -311,6 +312,7 @@ void block_job_complete(BlockJob *job, int ret);
|
|||
int block_job_set_speed(BlockJob *job, int64_t value);
|
||||
void block_job_cancel(BlockJob *job);
|
||||
bool block_job_is_cancelled(BlockJob *job);
|
||||
void block_job_cancel_sync(BlockJob *job);
|
||||
|
||||
int stream_start(BlockDriverState *bs, BlockDriverState *base,
|
||||
const char *base_id, BlockDriverCompletionFunc *cb,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue