* [PATCH] block: Handle curl 7.55.0, 7.85.0 version changes
@ 2023-01-23 20:14 Anton Johansson via
2023-01-24 7:55 ` Philippe Mathieu-Daudé
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Anton Johansson via @ 2023-01-23 20:14 UTC (permalink / raw)
To: qemu-devel; +Cc: ale, kwolf, hreitz
* 7.55.0 deprecates CURLINFO_CONTENT_LENGTH_DOWNLOAD in favour of a *_T
version, which returns curl_off_t instead of a double.
* 7.85.0 deprecates CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS in
favour of *_STR variants, specifying the desired protocols via a
string.
Signed-off-by: Anton Johansson <anjo@rev.ng>
---
block/curl.c | 44 +++++++++++++++++++++++++++++++++++++-------
1 file changed, 37 insertions(+), 7 deletions(-)
diff --git a/block/curl.c b/block/curl.c
index cba4c4cac7..0b125095e3 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -37,8 +37,15 @@
// #define DEBUG_VERBOSE
+/* CURL 7.85.0 switches to a string based API for specifying
+ * the desired protocols.
+ */
+#if LIBCURL_VERSION_NUM >= 0x075500
+#define PROTOCOLS "HTTP,HTTPS,FTP,FTPS"
+#else
#define PROTOCOLS (CURLPROTO_HTTP | CURLPROTO_HTTPS | \
CURLPROTO_FTP | CURLPROTO_FTPS)
+#endif
#define CURL_NUM_STATES 8
#define CURL_NUM_ACB 8
@@ -509,9 +516,18 @@ static int curl_init_state(BDRVCURLState *s, CURLState *state)
* obscure protocols. For example, do not allow POP3/SMTP/IMAP see
* CVE-2013-0249.
*
- * Restricting protocols is only supported from 7.19.4 upwards.
+ * Restricting protocols is only supported from 7.19.4 upwards. Note:
+ * version 7.85.0 deprecates CURLOPT_*PROTOCOLS in favour of a string
+ * based CURLOPT_*PROTOCOLS_STR API.
*/
-#if LIBCURL_VERSION_NUM >= 0x071304
+#if LIBCURL_VERSION_NUM >= 0x075500
+ if (curl_easy_setopt(state->curl,
+ CURLOPT_PROTOCOLS_STR, PROTOCOLS) ||
+ curl_easy_setopt(state->curl,
+ CURLOPT_REDIR_PROTOCOLS_STR, PROTOCOLS)) {
+ goto err;
+ }
+#elif LIBCURL_VERSION_NUM >= 0x071304
if (curl_easy_setopt(state->curl, CURLOPT_PROTOCOLS, PROTOCOLS) ||
curl_easy_setopt(state->curl, CURLOPT_REDIR_PROTOCOLS, PROTOCOLS)) {
goto err;
@@ -669,7 +685,12 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
const char *file;
const char *cookie;
const char *cookie_secret;
- double d;
+ /* CURL >= 7.55.0 uses curl_off_t for content length instead of a double */
+#if LIBCURL_VERSION_NUM >= 0x073700
+ curl_off_t cl;
+#else
+ double cl;
+#endif
const char *secretid;
const char *protocol_delimiter;
int ret;
@@ -796,27 +817,36 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
}
if (curl_easy_perform(state->curl))
goto out;
- if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d)) {
+ /* CURL 7.55.0 deprecates CURLINFO_CONTENT_LENGTH_DOWNLOAD in favour of
+ * the *_T version which returns a more sensible type for content length.
+ */
+#if LIBCURL_VERSION_NUM >= 0x073700
+ if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &cl)) {
+ goto out;
+ }
+#else
+ if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl)) {
goto out;
}
+#endif
/* Prior CURL 7.19.4 return value of 0 could mean that the file size is not
* know or the size is zero. From 7.19.4 CURL returns -1 if size is not
* known and zero if it is really zero-length file. */
#if LIBCURL_VERSION_NUM >= 0x071304
- if (d < 0) {
+ if (cl < 0) {
pstrcpy(state->errmsg, CURL_ERROR_SIZE,
"Server didn't report file size.");
goto out;
}
#else
- if (d <= 0) {
+ if (cl <= 0) {
pstrcpy(state->errmsg, CURL_ERROR_SIZE,
"Unknown file size or zero-length file.");
goto out;
}
#endif
- s->len = d;
+ s->len = cl;
if ((!strncasecmp(s->url, "http://", strlen("http://"))
|| !strncasecmp(s->url, "https://", strlen("https://")))
--
2.39.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] block: Handle curl 7.55.0, 7.85.0 version changes
2023-01-23 20:14 [PATCH] block: Handle curl 7.55.0, 7.85.0 version changes Anton Johansson via
@ 2023-01-24 7:55 ` Philippe Mathieu-Daudé
2023-01-24 9:51 ` Peter Maydell
2023-02-13 13:28 ` Peter Maydell
2 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-01-24 7:55 UTC (permalink / raw)
To: Anton Johansson, qemu-devel; +Cc: ale, kwolf, hreitz
On 23/1/23 21:14, Anton Johansson via wrote:
> * 7.55.0 deprecates CURLINFO_CONTENT_LENGTH_DOWNLOAD in favour of a *_T
> version, which returns curl_off_t instead of a double.
> * 7.85.0 deprecates CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS in
> favour of *_STR variants, specifying the desired protocols via a
> string.
>
> Signed-off-by: Anton Johansson <anjo@rev.ng>
> ---
> block/curl.c | 44 +++++++++++++++++++++++++++++++++++++-------
> 1 file changed, 37 insertions(+), 7 deletions(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] block: Handle curl 7.55.0, 7.85.0 version changes
2023-01-23 20:14 [PATCH] block: Handle curl 7.55.0, 7.85.0 version changes Anton Johansson via
2023-01-24 7:55 ` Philippe Mathieu-Daudé
@ 2023-01-24 9:51 ` Peter Maydell
2023-02-13 13:28 ` Peter Maydell
2 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2023-01-24 9:51 UTC (permalink / raw)
To: Anton Johansson; +Cc: qemu-devel, ale, kwolf, hreitz
On Mon, 23 Jan 2023 at 20:15, Anton Johansson via <qemu-devel@nongnu.org> wrote:
>
> * 7.55.0 deprecates CURLINFO_CONTENT_LENGTH_DOWNLOAD in favour of a *_T
> version, which returns curl_off_t instead of a double.
> * 7.85.0 deprecates CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS in
> favour of *_STR variants, specifying the desired protocols via a
> string.
>
> Signed-off-by: Anton Johansson <anjo@rev.ng>
We should note that this
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1440
There also seems to be a different set of patches that
somebody attached to that bug report, but yours wins
since you actually submitted it :-)
thanks
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] block: Handle curl 7.55.0, 7.85.0 version changes
2023-01-23 20:14 [PATCH] block: Handle curl 7.55.0, 7.85.0 version changes Anton Johansson via
2023-01-24 7:55 ` Philippe Mathieu-Daudé
2023-01-24 9:51 ` Peter Maydell
@ 2023-02-13 13:28 ` Peter Maydell
2023-02-13 14:32 ` Kevin Wolf
2 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2023-02-13 13:28 UTC (permalink / raw)
To: Anton Johansson; +Cc: qemu-devel, ale, kwolf, hreitz
On Mon, 23 Jan 2023 at 20:15, Anton Johansson via <qemu-devel@nongnu.org> wrote:
>
> * 7.55.0 deprecates CURLINFO_CONTENT_LENGTH_DOWNLOAD in favour of a *_T
> version, which returns curl_off_t instead of a double.
> * 7.85.0 deprecates CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS in
> favour of *_STR variants, specifying the desired protocols via a
> string.
>
> Signed-off-by: Anton Johansson <anjo@rev.ng>
Block folks -- this patch has been reviewed, are you going to
pick it up (with the Resolves: line added) ?
I'm interested because one of the machines I use has just updated
to the new libcurl and so QEMU no longer compiles there because
of the deprecation warnings :-)
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] block: Handle curl 7.55.0, 7.85.0 version changes
2023-02-13 13:28 ` Peter Maydell
@ 2023-02-13 14:32 ` Kevin Wolf
2023-02-20 15:09 ` Alex Bennée
0 siblings, 1 reply; 6+ messages in thread
From: Kevin Wolf @ 2023-02-13 14:32 UTC (permalink / raw)
To: Peter Maydell; +Cc: Anton Johansson, qemu-devel, ale, hreitz
Am 13.02.2023 um 14:28 hat Peter Maydell geschrieben:
> On Mon, 23 Jan 2023 at 20:15, Anton Johansson via <qemu-devel@nongnu.org> wrote:
> >
> > * 7.55.0 deprecates CURLINFO_CONTENT_LENGTH_DOWNLOAD in favour of a *_T
> > version, which returns curl_off_t instead of a double.
> > * 7.85.0 deprecates CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS in
> > favour of *_STR variants, specifying the desired protocols via a
> > string.
> >
> > Signed-off-by: Anton Johansson <anjo@rev.ng>
>
> Block folks -- this patch has been reviewed, are you going to
> pick it up (with the Resolves: line added) ?
Yes, I'm going through the patches right now that were stuck because the
previous pull request was blocked by CI.
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] block: Handle curl 7.55.0, 7.85.0 version changes
2023-02-13 14:32 ` Kevin Wolf
@ 2023-02-20 15:09 ` Alex Bennée
0 siblings, 0 replies; 6+ messages in thread
From: Alex Bennée @ 2023-02-20 15:09 UTC (permalink / raw)
To: Kevin Wolf; +Cc: Peter Maydell, Anton Johansson, ale, hreitz, qemu-devel
Kevin Wolf <kwolf@redhat.com> writes:
> Am 13.02.2023 um 14:28 hat Peter Maydell geschrieben:
>> On Mon, 23 Jan 2023 at 20:15, Anton Johansson via <qemu-devel@nongnu.org> wrote:
>> >
>> > * 7.55.0 deprecates CURLINFO_CONTENT_LENGTH_DOWNLOAD in favour of a *_T
>> > version, which returns curl_off_t instead of a double.
>> > * 7.85.0 deprecates CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS in
>> > favour of *_STR variants, specifying the desired protocols via a
>> > string.
>> >
>> > Signed-off-by: Anton Johansson <anjo@rev.ng>
>>
>> Block folks -- this patch has been reviewed, are you going to
>> pick it up (with the Resolves: line added) ?
>
> Yes, I'm going through the patches right now that were stuck because the
> previous pull request was blocked by CI.
>
> Thanks, applied to the block branch.
I've also applied to my testing/next (for the same reason) just in case
the block branch doesn't go in soon.
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-02-20 15:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-23 20:14 [PATCH] block: Handle curl 7.55.0, 7.85.0 version changes Anton Johansson via
2023-01-24 7:55 ` Philippe Mathieu-Daudé
2023-01-24 9:51 ` Peter Maydell
2023-02-13 13:28 ` Peter Maydell
2023-02-13 14:32 ` Kevin Wolf
2023-02-20 15:09 ` Alex Bennée
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.