Skip to content

Commit

Permalink
block: Fix locking in qmp_block_resize()
Browse files Browse the repository at this point in the history
The drain functions assume that we hold the AioContext lock of the
drained block node. Make sure to actually take the lock.

Cc: [email protected]
Fixes: eb94b81
Signed-off-by: Kevin Wolf <[email protected]>
Message-Id: <[email protected]>
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
  • Loading branch information
kevmw committed Dec 11, 2020
1 parent d9dbf25 commit 8089eab
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion blockdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2481,13 +2481,16 @@ void coroutine_fn qmp_block_resize(bool has_device, const char *device,
return;
}

bdrv_co_lock(bs);
bdrv_drained_begin(bs);
bdrv_co_unlock(bs);

old_ctx = bdrv_co_enter(bs);
blk_truncate(blk, size, false, PREALLOC_MODE_OFF, 0, errp);
bdrv_co_leave(bs, old_ctx);
bdrv_drained_end(bs);

bdrv_co_lock(bs);
bdrv_drained_end(bs);
blk_unref(blk);
bdrv_co_unlock(bs);
}
Expand Down

0 comments on commit 8089eab

Please sign in to comment.