diff mbox

[for-2.9] block/curl: Prefer URL in options over filename

Message ID 20161126235405.1357-1-mreitz@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Max Reitz Nov. 26, 2016, 11:54 p.m. UTC
Currently, the curl block driver will replace any URL specified through
the options QDict by a filename, if one has been given. However, the
options QDict should generally take precedence, which is implemented by
this patch.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
Not really critical, so getting this into 2.9 is sufficient.
---
 block/curl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Fam Zheng Nov. 28, 2016, 6:50 a.m. UTC | #1
On Sun, 11/27 00:54, Max Reitz wrote:
> Currently, the curl block driver will replace any URL specified through
> the options QDict by a filename, if one has been given. However, the
> options QDict should generally take precedence, which is implemented by
> this patch.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
> Not really critical, so getting this into 2.9 is sufficient.
> ---
>  block/curl.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/block/curl.c b/block/curl.c
> index 0404c1b..2e9a45c 100644
> --- a/block/curl.c
> +++ b/block/curl.c
> @@ -531,7 +531,9 @@ static void curl_clean_state(CURLState *s)
>  static void curl_parse_filename(const char *filename, QDict *options,
>                                  Error **errp)
>  {
> -    qdict_put(options, CURL_BLOCK_OPT_URL, qstring_from_str(filename));
> +    if (!qdict_haskey(options, CURL_BLOCK_OPT_URL)) {
> +        qdict_put(options, CURL_BLOCK_OPT_URL, qstring_from_str(filename));
> +    }
>  }
>  
>  static void curl_detach_aio_context(BlockDriverState *bs)
> -- 
> 2.10.2
> 
> 

Reviewed-by: Fam Zheng <famz@redhat.com>
diff mbox

Patch

diff --git a/block/curl.c b/block/curl.c
index 0404c1b..2e9a45c 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -531,7 +531,9 @@  static void curl_clean_state(CURLState *s)
 static void curl_parse_filename(const char *filename, QDict *options,
                                 Error **errp)
 {
-    qdict_put(options, CURL_BLOCK_OPT_URL, qstring_from_str(filename));
+    if (!qdict_haskey(options, CURL_BLOCK_OPT_URL)) {
+        qdict_put(options, CURL_BLOCK_OPT_URL, qstring_from_str(filename));
+    }
 }
 
 static void curl_detach_aio_context(BlockDriverState *bs)