block: Convert 'block_resize' to coroutine
commiteb94b81a94bce112e6b206df846c1551aaf6cab6
authorKevin Wolf <kwolf@redhat.com>
Mon, 5 Oct 2020 15:58:55 +0000 (5 17:58 +0200)
committerMarkus Armbruster <armbru@redhat.com>
Fri, 9 Oct 2020 05:08:20 +0000 (9 07:08 +0200)
tree50a7bf08af03d1f2c17392ef48c80a56380d2397
parent18c6ac1c6eb7cc541249585836659d0d3ed3a539
block: Convert 'block_resize' to coroutine

block_resize performs some I/O that could potentially take quite some
time, so use it as an example for the new 'coroutine': true annotation
in the QAPI schema.

bdrv_truncate() requires that we're already in the right AioContext for
the BlockDriverState if called in coroutine context. So instead of just
taking the AioContext lock, move the QMP handler coroutine to the
context.

Call blk_unref() only after switching back because blk_unref() may only
be called in the main thread.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20201005155855.256490-15-kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
blockdev.c
hmp-commands.hx
qapi/block-core.json