mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
block: Convert bdrv_is_inserted() to co_wrapper
bdrv_is_inserted() is categorized as an I/O function, and it currently doesn't run in a coroutine. We should let it take a graph rdlock since it traverses the block nodes graph, which however is only possible in a coroutine. Therefore turn it into a co_wrapper to move the actual function into a coroutine where the lock can be taken. At the same time, add also blk_is_inserted as co_wrapper_mixed, since it is called in both coroutine and non-coroutine contexts. Because now this function creates a new coroutine and polls, we need to take the AioContext lock where it is missing, for the only reason that internally c_w_mixed_bdrv_rdlock calls AIO_WAIT_WHILE and it expects to release the AioContext lock. Once the rwlock is ultimated and placed in every place it needs to be, we will poll using AIO_WAIT_WHILE_UNLOCKED and remove the AioContext lock. Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20230113204212.359076-5-kwolf@redhat.com> Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
09d9fc97f8
commit
1e97be9156
8 changed files with 32 additions and 20 deletions
8
block.c
8
block.c
|
@ -6782,7 +6782,7 @@ out:
|
|||
/**
|
||||
* Return TRUE if the media is present
|
||||
*/
|
||||
bool bdrv_is_inserted(BlockDriverState *bs)
|
||||
bool coroutine_fn bdrv_co_is_inserted(BlockDriverState *bs)
|
||||
{
|
||||
BlockDriver *drv = bs->drv;
|
||||
BdrvChild *child;
|
||||
|
@ -6791,11 +6791,11 @@ bool bdrv_is_inserted(BlockDriverState *bs)
|
|||
if (!drv) {
|
||||
return false;
|
||||
}
|
||||
if (drv->bdrv_is_inserted) {
|
||||
return drv->bdrv_is_inserted(bs);
|
||||
if (drv->bdrv_co_is_inserted) {
|
||||
return drv->bdrv_co_is_inserted(bs);
|
||||
}
|
||||
QLIST_FOREACH(child, &bs->children, next) {
|
||||
if (!bdrv_is_inserted(child->bs)) {
|
||||
if (!bdrv_co_is_inserted(child->bs)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue