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

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

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