74 lines
3.5 KiB
Diff
74 lines
3.5 KiB
Diff
From a08b866ca5b7ae45d25a584d5e61855015b80794 Mon Sep 17 00:00:00 2001
|
|
Message-Id: <a08b866ca5b7ae45d25a584d5e61855015b80794@dist-git>
|
|
From: Peter Krempa <pkrempa@redhat.com>
|
|
Date: Mon, 30 Mar 2020 17:21:47 +0200
|
|
Subject: [PATCH] virStorageSourceParseBackingURI: Preserve query string of URI
|
|
for http(s)
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
For http/https URIs we need to preserve the query part as it may be
|
|
important to refer to the image.
|
|
|
|
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
(cherry picked from commit 544ef82d05a675d9c6f939c67635ed46c094b164)
|
|
https://bugzilla.redhat.com/show_bug.cgi?id=1804750
|
|
Message-Id: <ecddbeb737c76791d4372c861343da2fc8611371.1585581552.git.pkrempa@redhat.com>
|
|
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
|
|
---
|
|
src/util/virstoragefile.c | 13 ++++++++++---
|
|
tests/virstoragetest.c | 4 ++--
|
|
2 files changed, 12 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
|
|
index 4082e3f5f7..aba315d93b 100644
|
|
--- a/src/util/virstoragefile.c
|
|
+++ b/src/util/virstoragefile.c
|
|
@@ -2853,9 +2853,16 @@ virStorageSourceParseBackingURI(virStorageSourcePtr src,
|
|
return -1;
|
|
}
|
|
|
|
- /* handle socket stored as a query */
|
|
- if (uri->query)
|
|
- src->hosts->socket = g_strdup(STRSKIP(uri->query, "socket="));
|
|
+ if (uri->query) {
|
|
+ if (src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTP ||
|
|
+ src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTPS) {
|
|
+ src->query = g_strdup(uri->query);
|
|
+ } else {
|
|
+ /* handle socket stored as a query */
|
|
+ if (STRPREFIX(uri->query, "socket="))
|
|
+ src->hosts->socket = g_strdup(STRSKIP(uri->query, "socket="));
|
|
+ }
|
|
+ }
|
|
|
|
/* uri->path is NULL if the URI does not contain slash after host:
|
|
* transport://host:port */
|
|
diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c
|
|
index d9244fdfe8..fe8f6dd36f 100644
|
|
--- a/tests/virstoragetest.c
|
|
+++ b/tests/virstoragetest.c
|
|
@@ -1613,7 +1613,7 @@ mymain(void)
|
|
"\"file.url\": \"https://host/folder/esx6.5-rhel7.7-x86%5f64/esx6.5-rhel7.7-x86%5f64-flat.vmdk?dcPath=data&dsName=esx6.5-matrix\","
|
|
"\"file.timeout\": 2000"
|
|
"}",
|
|
- "<source protocol='https' name='folder/esx6.5-rhel7.7-x86_64/esx6.5-rhel7.7-x86_64-flat.vmdk'>\n"
|
|
+ "<source protocol='https' name='folder/esx6.5-rhel7.7-x86_64/esx6.5-rhel7.7-x86_64-flat.vmdk' query='dcPath=data&dsName=esx6.5-matrix'>\n"
|
|
" <host name='host' port='443'/>\n"
|
|
" <ssl verify='no'/>\n"
|
|
" <cookies>\n"
|
|
@@ -1628,7 +1628,7 @@ mymain(void)
|
|
"\"file.url\": \"https://host/folder/esx6.5-rhel7.7-x86%5f64/esx6.5-rhel7.7-x86%5f64-flat.vmdk?dcPath=data&dsName=esx6.5-matrix\","
|
|
"\"file.timeout\": 2000"
|
|
"}",
|
|
- "<source protocol='https' name='folder/esx6.5-rhel7.7-x86_64/esx6.5-rhel7.7-x86_64-flat.vmdk'>\n"
|
|
+ "<source protocol='https' name='folder/esx6.5-rhel7.7-x86_64/esx6.5-rhel7.7-x86_64-flat.vmdk' query='dcPath=data&dsName=esx6.5-matrix'>\n"
|
|
" <host name='host' port='443'/>\n"
|
|
" <ssl verify='no'/>\n"
|
|
" <cookies>\n"
|
|
--
|
|
2.26.0
|
|
|