]> xenbits.xensource.com Git - libvirt.git/commitdiff
virStorageSourceParseBackingURI: Preserve query string of URI for http(s)
authorPeter Krempa <pkrempa@redhat.com>
Fri, 27 Mar 2020 15:26:50 +0000 (16:26 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 30 Mar 2020 14:30:34 +0000 (16:30 +0200)
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>
src/util/virstoragefile.c
tests/virstoragetest.c

index 1fc2520be16430c546f1c67b5540e54ac96367bb..ffc8bdb3446f0b6ba85ff158568745e0e02d4f9e 100644 (file)
@@ -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 */
index 10d542115075c8d14544e934ea73f6f6003b77fb..6e8ebeba134b8b6ede2bf7be5682ec27204aa6c1 100644 (file)
@@ -1632,7 +1632,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&amp;dsName=esx6.5-matrix'>\n"
                            "  <host name='host' port='443'/>\n"
                            "  <ssl verify='no'/>\n"
                            "  <cookies>\n"
@@ -1647,7 +1647,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&amp;dsName=esx6.5-matrix'>\n"
                            "  <host name='host' port='443'/>\n"
                            "  <ssl verify='no'/>\n"
                            "  <cookies>\n"