curl: avoid recursive locking of BDRVCURLState mutex
The curl driver has a ugly hack where, if it cannot find an empty CURLState,
it just uses aio_poll to wait for one to be empty. This is probably
buggy when used together with dataplane, and the simplest way to fix it
is to use coroutines instead.
A more immediate effect of the bug however is that it can cause a
recursive call to curl_readv_bh_cb and recursively taking the
BDRVCURLState mutex. This causes a deadlock.
The fix is to unlock the mutex around aio_poll, but for cleanliness we
should also take the mutex around all calls to curl_init_state, even if
reaching the unlock/lock pair is impossible. The same is true for
curl_clean_state.
Reported-by: Kun Wei <[email protected]>
Tested-by: Richard W.M. Jones <[email protected]>
Reviewed-by: Max Reitz <[email protected]>
Reviewed-by: Jeff Cody <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Message-id:
20170515100059[email protected]
Cc: [email protected]
Cc: Jeff Cody <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
Signed-off-by: Jeff Cody <[email protected]>