Skip to content
  • Kevin Wolf's avatar
    dea97c1f
    block-coroutine-wrapper: Take AioContext lock in no_co_wrappers · dea97c1f
    Kevin Wolf authored
    
    
    All of the functions that currently take a BlockDriverState, BdrvChild
    or BlockBackend as their first parameter expect the associated
    AioContext to be locked when they are called. In the case of
    no_co_wrappers, they are called from bottom halves directly in the main
    loop, so no other caller can be expected to take the lock for them. This
    can result in assertion failures because a lock that isn't taken is
    released in nested event loops.
    
    Looking at the first parameter is already done by co_wrappers to decide
    where the coroutine should run, so doing the same in no_co_wrappers is
    only consistent. Take the lock in the generated bottom halves to fix the
    problem.
    
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    Message-Id: <20230525124713.401149-2-kwolf@redhat.com>
    Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    dea97c1f
    block-coroutine-wrapper: Take AioContext lock in no_co_wrappers
    Kevin Wolf authored
    
    
    All of the functions that currently take a BlockDriverState, BdrvChild
    or BlockBackend as their first parameter expect the associated
    AioContext to be locked when they are called. In the case of
    no_co_wrappers, they are called from bottom halves directly in the main
    loop, so no other caller can be expected to take the lock for them. This
    can result in assertion failures because a lock that isn't taken is
    released in nested event loops.
    
    Looking at the first parameter is already done by co_wrappers to decide
    where the coroutine should run, so doing the same in no_co_wrappers is
    only consistent. Take the lock in the generated bottom halves to fix the
    problem.
    
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    Message-Id: <20230525124713.401149-2-kwolf@redhat.com>
    Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
Loading