I can't figure out ownership of aio context during bdrv_close().
As far as I understand bdrv_unref() shold be called with acquired aio context to prevent concurrent operations (at least most usages in blockdev.c explicitly acquire and release context, but not all).
But if refcount reaches zero and bs is going to be deleted in bdrv_close() we need to ensure that drain is finished data is flushed and there are no more pending coroutines and bottomhalves, so drain and flush functions can enter coroutine and perform yield in several places. As a result control returns to coroutine caller that will release aio context and when completion bh will continue cleanup process it will be executed without ownership of context. Is this a valid situation?
Moreover if yield happens bs that is being deleted has zero refcount but is still present in lists graph_bdrv_states and all_bdrv_states and can be accidentally accessed. Shouldn't we remove it from these lists ASAP when deletion process starts as we do from monitor_bdrv_states?