]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Add support for setting timeout and readahead size for network disks
authorPeter Krempa <pkrempa@redhat.com>
Thu, 5 Mar 2020 15:50:46 +0000 (16:50 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 16 Mar 2020 14:51:44 +0000 (15:51 +0100)
Some disk backends support configuring the readahead buffer or timeout
for requests. Add the knobs to the XML.

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/genericxml2xmlindata/disk-network-http.xml

index 9430ccdee192fe1879dd0981abc0878dcdd3bfa2..b6ddfa8e0cc7a64c73fe8f59ad41b5cc01d7ccbd 100644 (file)
       &lt;cookies&gt;
         &lt;cookie name="test"&gt;somevalue&lt;/cookie&gt;
       &lt;/cookies&gt;
+      &lt;readahead size='65536'/&gt;
+      &lt;timeout seconds='6'/&gt;
     &lt;/source&gt;
     &lt;target dev='hde' bus='ide' tray='open'/&gt;
     &lt;readonly/&gt;
             must conform to the HTTP specification.
             <span class="since">Since 6.2.0</span>
           </dd>
+          <dt><code>readahead</code></dt>
+          <dd>
+            Specifies the size of the readahead buffer for protocols
+            which support it. (all 'curl' based drivers in qemu). The size
+            is in bytes. Note that '0' is considered as if the value is not
+            provided.
+            <span class="since">Since 6.2.0</span>
+          </dd>
+          <dt><code>timeout</code></dt>
+          <dd>
+            Specifies the connection timeout for protocols which support it.
+            Note that '0' is considered as if the value is not provided.
+            <span class="since">Since 6.2.0</span>
+          </dd>
         </dl>
 
         <p>
index 85d6484dbdfa32100c5416739e25ca8d65592fe8..68054204519f0f4ccb8ebd1f312367359bb7ad2b 100644 (file)
     </element>
   </define>
 
+  <define name="diskSourceNetworkProtocolPropsCommon">
+    <optional>
+      <element name="readahead">
+        <attribute name="size">
+          <ref name="positiveInteger"/>
+        </attribute>
+        <empty/>
+      </element>
+    </optional>
+    <optional>
+      <element name="timeout">
+        <attribute name="seconds">
+          <ref name="positiveInteger"/>
+        </attribute>
+        <empty/>
+      </element>
+    </optional>
+  </define>
+
   <define name="diskSourceNetworkProtocolSSLVerify">
     <element name="ssl">
       <attribute name="verify">
       <optional>
         <ref name="diskSourceNetworkProtocolHTTPCookies"/>
       </optional>
+      <ref name="diskSourceNetworkProtocolPropsCommon"/>
     </element>
   </define>
 
       <optional>
         <ref name="diskSourceNetworkProtocolHTTPCookies"/>
       </optional>
+      <ref name="diskSourceNetworkProtocolPropsCommon"/>
     </element>
   </define>
 
       <optional>
         <ref name="diskSourceNetworkProtocolSSLVerify"/>
       </optional>
+      <ref name="diskSourceNetworkProtocolPropsCommon"/>
     </element>
   </define>
 
       <optional>
         <ref name="encryption"/>
       </optional>
+      <ref name="diskSourceNetworkProtocolPropsCommon"/>
     </element>
   </define>
 
index f3de76efe4814ad24c98a3f8528e6a66681fa998..71535f53f57a0721858b1ea983792c3ae63e75fe 100644 (file)
@@ -9500,6 +9500,19 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
             return -1;
     }
 
+    if (src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTP ||
+        src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTPS ||
+        src->protocol == VIR_STORAGE_NET_PROTOCOL_FTP ||
+        src->protocol == VIR_STORAGE_NET_PROTOCOL_FTPS) {
+
+        if (virXPathULongLong("string(./readahead/@size)", ctxt, &src->readahead) == -2 ||
+            virXPathULongLong("string(./timeout/@seconds)", ctxt, &src->timeout) == -2) {
+            virReportError(VIR_ERR_XML_ERROR, "%s",
+                          _("invalid readahead size or timeout"));
+            return -1;
+        }
+    }
+
     return 0;
 }
 
@@ -24632,6 +24645,12 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf,
 
     virDomainDiskSourceFormatNetworkCookies(childBuf, src);
 
+    if (src->readahead)
+        virBufferAsprintf(childBuf, "<readahead size='%llu'/>\n", src->readahead);
+
+    if (src->timeout)
+        virBufferAsprintf(childBuf, "<timeout seconds='%llu'/>\n", src->timeout);
+
     return 0;
 }
 
index 266e9c489e5a8e5edfb26c63fe20260dc1e71388..a80bffa015305093eb8f438bb7997b29f33639c3 100644 (file)
@@ -2383,6 +2383,8 @@ virStorageSourceCopy(const virStorageSource *src,
     def->discard = src->discard;
     def->detect_zeroes = src->detect_zeroes;
     def->sslverify = src->sslverify;
+    def->readahead = src->readahead;
+    def->timeout = src->timeout;
 
     /* storage driver metadata are not copied */
     def->drv = NULL;
index 95d9501dd8f2cd738622ac0dd5d13d2ec8e98036..dd2186c4ff4292e8b000cebec082b45c4994ce01 100644 (file)
@@ -295,6 +295,9 @@ struct _virStorageSource {
     bool encryptionInherited;
     virStoragePRDefPtr pr;
     virTristateBool sslverify;
+    /* both values below have 0 as default value */
+    unsigned long long readahead; /* size of the readahead buffer in bytes */
+    unsigned long long timeout; /* connection timeout in seconds */
 
     virStorageSourceNVMeDefPtr nvme; /* type == VIR_STORAGE_TYPE_NVME */
 
index bafb77c8ecd24322dec63ef2b1c5889441f72c46..a8430b83655d67472fa73dc6fe96fc5a52cd15b7 100644 (file)
@@ -49,6 +49,8 @@
           <cookie name='test'>testcookievalue</cookie>
           <cookie name='test2'>blurb</cookie>
         </cookies>
+        <readahead size='65536'/>
+        <timeout seconds='10'/>
       </source>
       <target dev='vdd' bus='virtio'/>
     </disk>