]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Add support for http(s) query strings
authorPeter Krempa <pkrempa@redhat.com>
Mon, 30 Mar 2020 12:54:02 +0000 (14:54 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 30 Mar 2020 14:30:34 +0000 (16:30 +0200)
Add a new attribute for holding the query part for http(s) disks.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
docs/formatdomain.html.in
docs/schemas/domaincommon.rng
src/conf/domain_conf.c
src/util/virstoragefile.c
src/util/virstoragefile.h
tests/qemuxml2argvdata/disk-network-http.xml
tests/qemuxml2xmloutdata/disk-network-http.x86_64-latest.xml

index 6dbf449698740f3fbec21e62ac822309fae6e1ec..aaeb05961fbb4468214e4a6c34474cd830a27bb9 100644 (file)
   &lt;/disk&gt;
   &lt;disk type='network' device='cdrom'&gt;
     &lt;driver name='qemu' type='raw'/&gt;
-    &lt;source protocol="http" name="url_path"&gt;
+    &lt;source protocol="http" name="url_path" query="foo=bar&amp;amp;baz=flurb&gt;
       &lt;host name="hostname" port="80"/&gt;
       &lt;cookies&gt;
         &lt;cookie name="test"&gt;somevalue&lt;/cookie&gt;
               ('tls' <span class="since">Since 4.5.0</span>)
               </p>
 
+              <p>For protocols <code>http</code> and <code>https</code> an
+              optional attribute <code>query</code> specifies the query string.
+              (<span class="since">Since 6.2.0</span>)
+              </p>
+
               <p>For "iscsi" (<span class="since">since 1.0.4</span>), the
               <code>name</code> attribute may include a logical unit number,
               separated from the target's name by a slash (e.g.,
index 5de17593c1574a9cd4891f5be457f901e677ccda..1807df521c2d95ac4e1526a5047c1ec36424f2f1 100644 (file)
           </choice>
         </attribute>
         <attribute name="name"/>
+        <optional>
+          <attribute name="query"/>
+        </optional>
         <ref name="diskSourceCommon"/>
         <ref name="diskSourceNetworkHost"/>
         <optional>
           </choice>
         </attribute>
         <attribute name="name"/>
+        <optional>
+          <attribute name="query"/>
+        </optional>
         <ref name="diskSourceCommon"/>
         <ref name="diskSourceNetworkHost"/>
         <optional>
index 27bc5a797bbe0f08ecd5e1e5cccda4bb08d1c68c..914e03c7050904cdaa7edfc44352ef31b8aa8e90 100644 (file)
@@ -9482,6 +9482,10 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
     /* config file currently only works with remote disks */
     src->configFile = virXPathString("string(./config/@file)", ctxt);
 
+    if (src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTP ||
+        src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTPS)
+        src->query = virXMLPropString(node, "query");
+
     if (virDomainStorageNetworkParseHosts(node, &src->hosts, &src->nhosts) < 0)
         return -1;
 
@@ -24591,6 +24595,7 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf,
         path = g_strdup_printf("%s/%s", src->volume, src->path);
 
     virBufferEscapeString(attrBuf, " name='%s'", path ? path : src->path);
+    virBufferEscapeString(attrBuf, " query='%s'", src->query);
 
     if (src->haveTLS != VIR_TRISTATE_BOOL_ABSENT &&
         !(flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE &&
index c43e52d1f64dd61458ea2c91c07ad5323a89722d..1fc2520be16430c546f1c67b5540e54ac96367bb 100644 (file)
@@ -2418,6 +2418,7 @@ virStorageSourceCopy(const virStorageSource *src,
     def->compat = g_strdup(src->compat);
     def->tlsAlias = g_strdup(src->tlsAlias);
     def->tlsCertdir = g_strdup(src->tlsCertdir);
+    def->query = g_strdup(src->query);
 
     if (src->sliceStorage)
         def->sliceStorage = virStorageSourceSliceCopy(src->sliceStorage);
@@ -2696,6 +2697,7 @@ virStorageSourceClear(virStorageSourcePtr def)
     VIR_FREE(def->volume);
     VIR_FREE(def->snapshot);
     VIR_FREE(def->configFile);
+    VIR_FREE(def->query);
     virStorageSourceNetCookiesClear(def);
     virStorageSourcePoolDefFree(def->srcpool);
     virBitmapFree(def->features);
index 9427057f94e5a3bf8e77c50fed8980e36e4cd5eb..7939c09cd521ce4184ac2543644a221d411ec799 100644 (file)
@@ -284,6 +284,7 @@ struct _virStorageSource {
     char *snapshot; /* for storage systems supporting internal snapshots */
     char *configFile; /* some storage systems use config file as part of
                          the source definition */
+    char *query; /* query string for HTTP based protocols */
     size_t nhosts;
     virStorageNetHostDefPtr hosts;
     size_t ncookies;
index 93e6617433c5afcf98c5984644fdd8b48235fb20..3abf4990196f449de5eebe56fafccf390edc881f 100644 (file)
@@ -42,7 +42,7 @@
     </disk>
     <disk type='network' device='disk'>
       <driver name='qemu' type='raw'/>
-      <source protocol='https' name='test4.img'>
+      <source protocol='https' name='test4.img' query='par=val&amp;other=ble'>
         <host name='example.org' port='1234'/>
         <ssl verify='no'/>
         <cookies>
index cf363312866368082fc87c3322adc02497391433..aaae21c5af61548853eaf1a228745e0e683df7e5 100644 (file)
@@ -49,7 +49,7 @@
     </disk>
     <disk type='network' device='disk'>
       <driver name='qemu' type='raw'/>
-      <source protocol='https' name='test4.img'>
+      <source protocol='https' name='test4.img' query='par=val&amp;other=ble'>
         <host name='example.org' port='1234'/>
         <ssl verify='no'/>
         <cookies>