Blame SOURCES/libvirt-virStorageSourceParseBackingURI-Preserve-query-string-of-URI-for-http-s.patch

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