Blame SOURCES/libvirt-conf-Add-support-for-setting-timeout-and-readahead-size-for-network-disks.patch

a41c76
From 3050ddce41896311b8c3ad06f148bea358e597b8 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <3050ddce41896311b8c3ad06f148bea358e597b8@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Mon, 16 Mar 2020 22:11:58 +0100
a41c76
Subject: [PATCH] conf: Add support for setting timeout and readahead size for
a41c76
 network disks
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
Some disk backends support configuring the readahead buffer or timeout
a41c76
for requests. Add the knobs to the XML.
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
(cherry picked from commit 63fd46177367c6653c4c986558f6d0e4a700cfcc)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1804750
a41c76
Message-Id: <2694bc6f9a327f89d82da18320e7137152915ad3.1584391727.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 docs/formatdomain.html.in                     | 16 +++++++++++++
a41c76
 docs/schemas/domaincommon.rng                 | 23 +++++++++++++++++++
a41c76
 src/conf/domain_conf.c                        | 19 +++++++++++++++
a41c76
 src/util/virstoragefile.c                     |  2 ++
a41c76
 src/util/virstoragefile.h                     |  3 +++
a41c76
 .../disk-network-http.xml                     |  2 ++
a41c76
 6 files changed, 65 insertions(+)
a41c76
a41c76
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
a41c76
index 5a10d64e83..2b8f9eabc2 100644
a41c76
--- a/docs/formatdomain.html.in
a41c76
+++ b/docs/formatdomain.html.in
a41c76
@@ -2842,6 +2842,8 @@
a41c76
       <cookies>
a41c76
         <cookie name="test">somevalue</cookie>
a41c76
       </cookies>
a41c76
+      <readahead size='65536'/>
a41c76
+      <timeout seconds='6'/>
a41c76
     </source>
a41c76
     <target dev='hde' bus='ide' tray='open'/>
a41c76
     <readonly/>
a41c76
@@ -3392,6 +3394,20 @@
a41c76
             must conform to the HTTP specification.
a41c76
             Since 6.2.0
a41c76
           
a41c76
+          
readahead
a41c76
+          
a41c76
+            Specifies the size of the readahead buffer for protocols
a41c76
+            which support it. (all 'curl' based drivers in qemu). The size
a41c76
+            is in bytes. Note that '0' is considered as if the value is not
a41c76
+            provided.
a41c76
+            Since 6.2.0
a41c76
+          
a41c76
+          
timeout
a41c76
+          
a41c76
+            Specifies the connection timeout for protocols which support it.
a41c76
+            Note that '0' is considered as if the value is not provided.
a41c76
+            Since 6.2.0
a41c76
+          
a41c76
         
a41c76
 
a41c76
         

a41c76
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
a41c76
index bdf35e64f6..3a0edbed97 100644
a41c76
--- a/docs/schemas/domaincommon.rng
a41c76
+++ b/docs/schemas/domaincommon.rng
a41c76
@@ -1808,6 +1808,25 @@
a41c76
     </element>
a41c76
   </define>
a41c76
 
a41c76
+  <define name="diskSourceNetworkProtocolPropsCommon">
a41c76
+    <optional>
a41c76
+      <element name="readahead">
a41c76
+        <attribute name="size">
a41c76
+          <ref name="positiveInteger"/>
a41c76
+        </attribute>
a41c76
+        <empty/>
a41c76
+      </element>
a41c76
+    </optional>
a41c76
+    <optional>
a41c76
+      <element name="timeout">
a41c76
+        <attribute name="seconds">
a41c76
+          <ref name="positiveInteger"/>
a41c76
+        </attribute>
a41c76
+        <empty/>
a41c76
+      </element>
a41c76
+    </optional>
a41c76
+  </define>
a41c76
+
a41c76
   <define name="diskSourceNetworkProtocolSSLVerify">
a41c76
     <element name="ssl">
a41c76
       <attribute name="verify">
a41c76
@@ -1854,6 +1873,7 @@
a41c76
       <optional>
a41c76
         <ref name="diskSourceNetworkProtocolHTTPCookies"/>
a41c76
       </optional>
a41c76
+      <ref name="diskSourceNetworkProtocolPropsCommon"/>
a41c76
     </element>
a41c76
   </define>
a41c76
 
a41c76
@@ -1873,6 +1893,7 @@
a41c76
       <optional>
a41c76
         <ref name="diskSourceNetworkProtocolHTTPCookies"/>
a41c76
       </optional>
a41c76
+      <ref name="diskSourceNetworkProtocolPropsCommon"/>
a41c76
     </element>
a41c76
   </define>
a41c76
 
a41c76
@@ -1892,6 +1913,7 @@
a41c76
       <optional>
a41c76
         <ref name="diskSourceNetworkProtocolSSLVerify"/>
a41c76
       </optional>
a41c76
+      <ref name="diskSourceNetworkProtocolPropsCommon"/>
a41c76
     </element>
a41c76
   </define>
a41c76
 
a41c76
@@ -1910,6 +1932,7 @@
a41c76
       <optional>
a41c76
         <ref name="encryption"/>
a41c76
       </optional>
a41c76
+      <ref name="diskSourceNetworkProtocolPropsCommon"/>
a41c76
     </element>
a41c76
   </define>
a41c76
 
a41c76
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
a41c76
index d066d3aac1..8aec85e83c 100644
a41c76
--- a/src/conf/domain_conf.c
a41c76
+++ b/src/conf/domain_conf.c
a41c76
@@ -9409,6 +9409,19 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
a41c76
             return -1;
a41c76
     }
a41c76
 
a41c76
+    if (src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTP ||
a41c76
+        src->protocol == VIR_STORAGE_NET_PROTOCOL_HTTPS ||
a41c76
+        src->protocol == VIR_STORAGE_NET_PROTOCOL_FTP ||
a41c76
+        src->protocol == VIR_STORAGE_NET_PROTOCOL_FTPS) {
a41c76
+
a41c76
+        if (virXPathULongLong("string(./readahead/@size)", ctxt, &src->readahead) == -2 ||
a41c76
+            virXPathULongLong("string(./timeout/@seconds)", ctxt, &src->timeout) == -2) {
a41c76
+            virReportError(VIR_ERR_XML_ERROR, "%s",
a41c76
+                          _("invalid readahead size or timeout"));
a41c76
+            return -1;
a41c76
+        }
a41c76
+    }
a41c76
+
a41c76
     return 0;
a41c76
 }
a41c76
 
a41c76
@@ -24413,6 +24426,12 @@ virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf,
a41c76
 
a41c76
     virDomainDiskSourceFormatNetworkCookies(childBuf, src);
a41c76
 
a41c76
+    if (src->readahead)
a41c76
+        virBufferAsprintf(childBuf, "<readahead size='%llu'/>\n", src->readahead);
a41c76
+
a41c76
+    if (src->timeout)
a41c76
+        virBufferAsprintf(childBuf, "<timeout seconds='%llu'/>\n", src->timeout);
a41c76
+
a41c76
     return 0;
a41c76
 }
a41c76
 
a41c76
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
a41c76
index 6350168d73..7893e054c3 100644
a41c76
--- a/src/util/virstoragefile.c
a41c76
+++ b/src/util/virstoragefile.c
a41c76
@@ -2383,6 +2383,8 @@ virStorageSourceCopy(const virStorageSource *src,
a41c76
     def->discard = src->discard;
a41c76
     def->detect_zeroes = src->detect_zeroes;
a41c76
     def->sslverify = src->sslverify;
a41c76
+    def->readahead = src->readahead;
a41c76
+    def->timeout = src->timeout;
a41c76
 
a41c76
     /* storage driver metadata are not copied */
a41c76
     def->drv = NULL;
a41c76
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
a41c76
index 1c7c046ad6..1abdaf89ce 100644
a41c76
--- a/src/util/virstoragefile.h
a41c76
+++ b/src/util/virstoragefile.h
a41c76
@@ -296,6 +296,9 @@ struct _virStorageSource {
a41c76
     bool encryptionInherited;
a41c76
     virStoragePRDefPtr pr;
a41c76
     virTristateBool sslverify;
a41c76
+    /* both values below have 0 as default value */
a41c76
+    unsigned long long readahead; /* size of the readahead buffer in bytes */
a41c76
+    unsigned long long timeout; /* connection timeout in seconds */
a41c76
 
a41c76
     virStorageSourceNVMeDefPtr nvme; /* type == VIR_STORAGE_TYPE_NVME */
a41c76
 
a41c76
diff --git a/tests/genericxml2xmlindata/disk-network-http.xml b/tests/genericxml2xmlindata/disk-network-http.xml
a41c76
index bafb77c8ec..a8430b8365 100644
a41c76
--- a/tests/genericxml2xmlindata/disk-network-http.xml
a41c76
+++ b/tests/genericxml2xmlindata/disk-network-http.xml
a41c76
@@ -49,6 +49,8 @@
a41c76
           <cookie name='test'>testcookievalue</cookie>
a41c76
           <cookie name='test2'>blurb</cookie>
a41c76
         </cookies>
a41c76
+        <readahead size='65536'/>
a41c76
+        <timeout seconds='10'/>
a41c76
       </source>
a41c76
       <target dev='vdd' bus='virtio'/>
a41c76
     </disk>
a41c76
-- 
a41c76
2.25.1
a41c76