Since the last patch in v1 didn't work, I bit the bullet and converted the whole thing to coroutines (patches 4-6). This in turns allows a more elegant solution to wait for CURLStates to get free (patch 7).
I tested this by lowering CURL_NUM_STATES to 2. With this change, the buggy case triggers a couple times while booting a Fedora netinst image. Paolo Paolo Bonzini (7): curl: strengthen assertion in curl_clean_state curl: never invoke callbacks with s->mutex held curl: avoid recursive locking of BDRVCURLState mutex curl: split curl_find_state/curl_init_state curl: convert CURLAIOCB to byte values curl: convert readv to coroutines curl: do not do aio_poll when waiting for a free CURLState block/curl.c | 216 +++++++++++++++++++++++++--------------------- 1 files changed, 120 insertions(+), 96 deletions(-) -- 2.12.2