|
|
05bba0 |
From 264a2066904d31c46860e0bac8790d57e6498b80 Mon Sep 17 00:00:00 2001
|
|
|
05bba0 |
From: Richard Jones <rjones@redhat.com>
|
|
|
05bba0 |
Date: Thu, 16 Jul 2015 15:41:54 +0200
|
|
|
05bba0 |
Subject: [PATCH 1/5] block/curl: Don't lose original error when a connection
|
|
|
05bba0 |
fails.
|
|
|
05bba0 |
|
|
|
05bba0 |
Message-id: <1437061314-4775-1-git-send-email-rjones@redhat.com>
|
|
|
05bba0 |
Patchwork-id: 67043
|
|
|
05bba0 |
O-Subject: [RHEL-7.2 qemu-kvm PATCH v3] block/curl: Don't lose original error when a connection fails.
|
|
|
05bba0 |
Bugzilla: 1235812
|
|
|
05bba0 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
05bba0 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
05bba0 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
05bba0 |
|
|
|
05bba0 |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
05bba0 |
|
|
|
05bba0 |
Currently if qemu is connected to a curl source (eg. web server), and
|
|
|
05bba0 |
the web server fails / times out / dies, you always see a bogus EIO
|
|
|
05bba0 |
"Input/output error".
|
|
|
05bba0 |
|
|
|
05bba0 |
For example, choose a large file located on any local webserver which
|
|
|
05bba0 |
you control:
|
|
|
05bba0 |
|
|
|
05bba0 |
$ qemu-img convert -p http://example.com/large.iso /tmp/test
|
|
|
05bba0 |
|
|
|
05bba0 |
Once it starts copying the file, stop the webserver and you will see
|
|
|
05bba0 |
qemu-img fail with:
|
|
|
05bba0 |
|
|
|
05bba0 |
qemu-img: error while reading sector 61440: Input/output error
|
|
|
05bba0 |
|
|
|
05bba0 |
This patch does two things: Firstly print the actual error from curl
|
|
|
05bba0 |
so it doesn't get lost. Secondly, change EIO to EPROTO. EPROTO is a
|
|
|
05bba0 |
POSIX.1 compatible errno which more accurately reflects that there was
|
|
|
05bba0 |
a protocol error, rather than some kind of hardware failure.
|
|
|
05bba0 |
|
|
|
05bba0 |
After this patch is applied, the error changes to:
|
|
|
05bba0 |
|
|
|
05bba0 |
$ qemu-img convert -p http://example.com/large.iso /tmp/test
|
|
|
05bba0 |
qemu-img: curl: transfer closed with 469989 bytes remaining to read
|
|
|
05bba0 |
qemu-img: error while reading sector 16384: Protocol error
|
|
|
05bba0 |
|
|
|
05bba0 |
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
05bba0 |
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
05bba0 |
Signed-off-by: Jeff Cody <jcody@redhat.com>
|
|
|
05bba0 |
|
|
|
05bba0 |
BZ: https://bugzilla.redhat.com/1235812
|
|
|
05bba0 |
Brew: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=9529354
|
|
|
05bba0 |
Upstream-status: 796a060bc0fab40953997976a2e30d9d6235bc7b
|
|
|
05bba0 |
---
|
|
|
05bba0 |
block/curl.c | 15 ++++++++++++++-
|
|
|
05bba0 |
1 file changed, 14 insertions(+), 1 deletion(-)
|
|
|
05bba0 |
|
|
|
05bba0 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
05bba0 |
---
|
|
|
05bba0 |
block/curl.c | 15 ++++++++++++++-
|
|
|
05bba0 |
1 file changed, 14 insertions(+), 1 deletion(-)
|
|
|
05bba0 |
|
|
|
05bba0 |
diff --git a/block/curl.c b/block/curl.c
|
|
|
05bba0 |
index 3088329..dfa8cee 100644
|
|
|
05bba0 |
--- a/block/curl.c
|
|
|
05bba0 |
+++ b/block/curl.c
|
|
|
05bba0 |
@@ -22,6 +22,7 @@
|
|
|
05bba0 |
* THE SOFTWARE.
|
|
|
05bba0 |
*/
|
|
|
05bba0 |
#include "qemu-common.h"
|
|
|
05bba0 |
+#include "qemu/error-report.h"
|
|
|
05bba0 |
#include "block/block_int.h"
|
|
|
05bba0 |
#include "qapi/qmp/qbool.h"
|
|
|
05bba0 |
#include <curl/curl.h>
|
|
|
05bba0 |
@@ -294,6 +295,18 @@ static void curl_multi_check_completion(BDRVCURLState *s)
|
|
|
05bba0 |
/* ACBs for successful messages get completed in curl_read_cb */
|
|
|
05bba0 |
if (msg->data.result != CURLE_OK) {
|
|
|
05bba0 |
int i;
|
|
|
05bba0 |
+ static int errcount = 100;
|
|
|
05bba0 |
+
|
|
|
05bba0 |
+ /* Don't lose the original error message from curl, since
|
|
|
05bba0 |
+ * it contains extra data.
|
|
|
05bba0 |
+ */
|
|
|
05bba0 |
+ if (errcount > 0) {
|
|
|
05bba0 |
+ error_report("curl: %s", state->errmsg);
|
|
|
05bba0 |
+ if (--errcount == 0) {
|
|
|
05bba0 |
+ error_report("curl: further errors suppressed");
|
|
|
05bba0 |
+ }
|
|
|
05bba0 |
+ }
|
|
|
05bba0 |
+
|
|
|
05bba0 |
for (i = 0; i < CURL_NUM_ACB; i++) {
|
|
|
05bba0 |
CURLAIOCB *acb = state->acb[i];
|
|
|
05bba0 |
|
|
|
05bba0 |
@@ -301,7 +314,7 @@ static void curl_multi_check_completion(BDRVCURLState *s)
|
|
|
05bba0 |
continue;
|
|
|
05bba0 |
}
|
|
|
05bba0 |
|
|
|
05bba0 |
- acb->common.cb(acb->common.opaque, -EIO);
|
|
|
05bba0 |
+ acb->common.cb(acb->common.opaque, -EPROTO);
|
|
|
05bba0 |
qemu_aio_release(acb);
|
|
|
05bba0 |
state->acb[i] = NULL;
|
|
|
05bba0 |
}
|
|
|
05bba0 |
--
|
|
|
05bba0 |
1.8.3.1
|
|
|
05bba0 |
|