render / rpms / libvirt

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