render / rpms / libvirt

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