@samitouri / QOSamiQemu / commits / 6f7b0a23a6

block/curl: fix concurrent completion handling

curl_multi_check_completion would bail upon the first completed transfer even if more completion messages were available thus leaving some in flight IOs stuck. Rework a bit the loop to make the iterations clearer and drop the breaks. The original hang can be somewhat reproduced with the following command: $ qemu-img convert -p -m 16 -O qcow2 -c --image-opts \ 'file.driver=https,file.url=https://scaleway.testdebit.info/10G.iso,file.readahead=1M' \ /tmp/test.qcow2 Fixes: 1f2cead32443 ("curl: Ensure all informationals are checked for completion") Cc: qemu-stable@nongnu.org Signed-off-by: Antoine Damhet <adamhet@scaleway.com> Message-ID: <20260212162730.440855-2-adamhet@scaleway.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>

Antoine Damhet committed Feb 12, 2026 at 17:27 UTC 6f7b0a23a6ea0cc72ad222ab37936248d99d4256
1 file changed +2 -9
block/curl.c
+2 -9
@@ -324,17 +324,11 @@ curl_find_buf(BDRVCURLState *s, uint64_t start, uint64_t len, CURLAIOCB *acb)
324 static void curl_multi_check_completion(BDRVCURLState *s)
325 {
326 int msgs_in_queue;
327 + CURLMsg *msg;
328
329 /* Try to find done transfers, so we can free the easy
330 * handle again. */
330 - for (;;) {
331 - CURLMsg *msg;
332 - msg = curl_multi_info_read(s->multi, &msgs_in_queue);
333 -
334 - /* Quit when there are no more completions */
335 - if (!msg)
336 - break;
337 -
331 + while ((msg = curl_multi_info_read(s->multi, &msgs_in_queue))) {
332 if (msg->msg == CURLMSG_DONE) {
333 int i;
334 CURLState *state = NULL;
@@ -397,7 +391,6 @@ static void curl_multi_check_completion(BDRVCURLState *s)
391 }
392
393 curl_clean_state(state);
400 - break;
394 }
395 }
396 }