* [Qemu-trivial] [PATCH] block/curl: Handle failed reads gracefully.
@ 2011-08-15 9:00 Nicholas Thomas
2011-08-18 23:00 ` [Qemu-trivial] [Qemu-devel] " Kevin Wolf
0 siblings, 1 reply; 2+ messages in thread
From: Nicholas Thomas @ 2011-08-15 9:00 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, nick
Current behaviour if a read fails is for the acb to not get finished.
This causes an infinite loop in bdrv_read_em (block.c). The read failure
never gets reported to the guest and if the error condition clears, the
process never recovers.
With this patch, when curl reports a failure we finish the acb as a
failure. This results in the guest receiving an I/O error (rather than
the read hanging indefinitely) and if the error condition subsequently
clears, retries work as expected.
The simplest test is to put an ISO on a web server you have control over
and open it with qemu-io. Then move the ISO out of the way and attempt
to read some data - you should see behaviour matching the above.
Signed-off-by: Nick Thomas <nick@bytemark.co.uk>
---
block/curl.c | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/block/curl.c b/block/curl.c
index 407f095..52c6463 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -229,6 +229,23 @@ static void curl_multi_do(void *arg)
{
CURLState *state = NULL;
curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, (char**)&state);
+
+ /* ACBs for successful messages get completed in curl_read_cb */
+ if (msg->data.result != CURLM_OK) {
+ int i;
+ for (i = 0; i < CURL_NUM_ACB; i++) {
+ CURLAIOCB *acb = state->acb[i];
+
+ if (acb == NULL) {
+ continue;
+ }
+
+ acb->common.cb(acb->common.opaque, -EIO);
+ qemu_aio_release(acb);
+ state->acb[i] = NULL;
+ }
+ }
+
curl_clean_state(state);
break;
}
@@ -277,7 +294,8 @@ static CURLState *curl_init_state(BDRVCURLState *s)
curl_easy_setopt(state->curl, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(state->curl, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(state->curl, CURLOPT_ERRORBUFFER, state->errmsg);
-
+ curl_easy_setopt(state->curl, CURLOPT_FAILONERROR, 1);
+
#ifdef DEBUG_VERBOSE
curl_easy_setopt(state->curl, CURLOPT_VERBOSE, 1);
#endif
--
1.7.0.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-trivial] [Qemu-devel] [PATCH] block/curl: Handle failed reads gracefully.
2011-08-15 9:00 [Qemu-trivial] [PATCH] block/curl: Handle failed reads gracefully Nicholas Thomas
@ 2011-08-18 23:00 ` Kevin Wolf
0 siblings, 0 replies; 2+ messages in thread
From: Kevin Wolf @ 2011-08-18 23:00 UTC (permalink / raw)
To: Nicholas Thomas; +Cc: qemu-trivial, qemu-devel
Am 15.08.2011 11:00, schrieb Nicholas Thomas:
> Current behaviour if a read fails is for the acb to not get finished.
> This causes an infinite loop in bdrv_read_em (block.c). The read failure
> never gets reported to the guest and if the error condition clears, the
> process never recovers.
>
> With this patch, when curl reports a failure we finish the acb as a
> failure. This results in the guest receiving an I/O error (rather than
> the read hanging indefinitely) and if the error condition subsequently
> clears, retries work as expected.
>
> The simplest test is to put an ISO on a web server you have control over
> and open it with qemu-io. Then move the ISO out of the way and attempt
> to read some data - you should see behaviour matching the above.
>
> Signed-off-by: Nick Thomas <nick@bytemark.co.uk>
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-08-18 22:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-15 9:00 [Qemu-trivial] [PATCH] block/curl: Handle failed reads gracefully Nicholas Thomas
2011-08-18 23:00 ` [Qemu-trivial] [Qemu-devel] " Kevin Wolf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).