|
|
9ae3a8 |
From 06b79081237eff3ebd8719af55265855d446f3e6 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Richard Jones <rjones@redhat.com>
|
|
|
9ae3a8 |
Date: Thu, 11 Jun 2015 11:40:25 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 25/30] block.curl: adding 'timeout' option
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Message-id: <1434022828-13037-19-git-send-email-rjones@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 65851
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.2 qemu-kvm v3 PATCH 18/21] block.curl: adding 'timeout' option
|
|
|
9ae3a8 |
Bugzilla: 1226684
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
The curl hardcoded timeout (5 seconds) sometimes is not long
|
|
|
9ae3a8 |
enough depending on the remote server configuration and network
|
|
|
9ae3a8 |
traffic. The user should be able to set how much long he is
|
|
|
9ae3a8 |
willing to wait for the connection.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Adding a new option to set this timeout gives the user this
|
|
|
9ae3a8 |
flexibility. The previous default timeout of 5 seconds will be
|
|
|
9ae3a8 |
used if this option is not present.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Reviewed-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
|
|
|
9ae3a8 |
Reviewed-by: Benoit Canet <benoit.canet@nodalink.com>
|
|
|
9ae3a8 |
Tested-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Upstream-status: 212aefaa53d142baa9a22f5aadd2e72eb916c0c0
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Note this intentionally omits the documentation changes in
|
|
|
9ae3a8 |
'qemu-options.hx' from the upstream patch.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block/curl.c | 13 ++++++++++++-
|
|
|
9ae3a8 |
1 file changed, 12 insertions(+), 1 deletion(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/curl.c b/block/curl.c
|
|
|
9ae3a8 |
index 2486449..1f1df4f 100644
|
|
|
9ae3a8 |
--- a/block/curl.c
|
|
|
9ae3a8 |
+++ b/block/curl.c
|
|
|
9ae3a8 |
@@ -63,6 +63,7 @@ static CURLMcode __curl_multi_socket_action(CURLM *multi_handle,
|
|
|
9ae3a8 |
#define CURL_NUM_ACB 8
|
|
|
9ae3a8 |
#define SECTOR_SIZE 512
|
|
|
9ae3a8 |
#define READ_AHEAD_DEFAULT (256 * 1024)
|
|
|
9ae3a8 |
+#define CURL_TIMEOUT_DEFAULT 5
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
#define FIND_RET_NONE 0
|
|
|
9ae3a8 |
#define FIND_RET_OK 1
|
|
|
9ae3a8 |
@@ -71,6 +72,7 @@ static CURLMcode __curl_multi_socket_action(CURLM *multi_handle,
|
|
|
9ae3a8 |
#define CURL_BLOCK_OPT_URL "url"
|
|
|
9ae3a8 |
#define CURL_BLOCK_OPT_READAHEAD "readahead"
|
|
|
9ae3a8 |
#define CURL_BLOCK_OPT_SSLVERIFY "sslverify"
|
|
|
9ae3a8 |
+#define CURL_BLOCK_OPT_TIMEOUT "timeout"
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
struct BDRVCURLState;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -109,6 +111,7 @@ typedef struct BDRVCURLState {
|
|
|
9ae3a8 |
char *url;
|
|
|
9ae3a8 |
size_t readahead_size;
|
|
|
9ae3a8 |
bool sslverify;
|
|
|
9ae3a8 |
+ int timeout;
|
|
|
9ae3a8 |
bool accept_range;
|
|
|
9ae3a8 |
} BDRVCURLState;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -379,7 +382,7 @@ static CURLState *curl_init_state(BDRVCURLState *s)
|
|
|
9ae3a8 |
curl_easy_setopt(state->curl, CURLOPT_URL, s->url);
|
|
|
9ae3a8 |
curl_easy_setopt(state->curl, CURLOPT_SSL_VERIFYPEER,
|
|
|
9ae3a8 |
(long) s->sslverify);
|
|
|
9ae3a8 |
- curl_easy_setopt(state->curl, CURLOPT_TIMEOUT, 5);
|
|
|
9ae3a8 |
+ curl_easy_setopt(state->curl, CURLOPT_TIMEOUT, s->timeout);
|
|
|
9ae3a8 |
curl_easy_setopt(state->curl, CURLOPT_WRITEFUNCTION,
|
|
|
9ae3a8 |
(void *)curl_read_cb);
|
|
|
9ae3a8 |
curl_easy_setopt(state->curl, CURLOPT_WRITEDATA, (void *)state);
|
|
|
9ae3a8 |
@@ -443,6 +446,11 @@ static QemuOptsList runtime_opts = {
|
|
|
9ae3a8 |
.type = QEMU_OPT_BOOL,
|
|
|
9ae3a8 |
.help = "Verify SSL certificate"
|
|
|
9ae3a8 |
},
|
|
|
9ae3a8 |
+ {
|
|
|
9ae3a8 |
+ .name = CURL_BLOCK_OPT_TIMEOUT,
|
|
|
9ae3a8 |
+ .type = QEMU_OPT_NUMBER,
|
|
|
9ae3a8 |
+ .help = "Curl timeout"
|
|
|
9ae3a8 |
+ },
|
|
|
9ae3a8 |
{ /* end of list */ }
|
|
|
9ae3a8 |
},
|
|
|
9ae3a8 |
};
|
|
|
9ae3a8 |
@@ -475,6 +483,9 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
|
|
|
9ae3a8 |
goto out_noclean;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ s->timeout = qemu_opt_get_number(opts, CURL_BLOCK_OPT_TIMEOUT,
|
|
|
9ae3a8 |
+ CURL_TIMEOUT_DEFAULT);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
s->sslverify = qemu_opt_get_bool(opts, CURL_BLOCK_OPT_SSLVERIFY, true);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
file = qemu_opt_get(opts, CURL_BLOCK_OPT_URL);
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|