libvirt/SOURCES/libvirt-conf-Add-support-for-setting-timeout-and-readahead-size-for-network-disks.patch
2021-10-08 13:11:20 +00:00

206 lines
6.9 KiB
Diff

From 3050ddce41896311b8c3ad06f148bea358e597b8 Mon Sep 17 00:00:00 2001
Message-Id: <3050ddce41896311b8c3ad06f148bea358e597b8@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Mon, 16 Mar 2020 22:11:58 +0100
Subject: [PATCH] conf: Add support for setting timeout and readahead size for
network disks
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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>
(cherry picked from commit 63fd46177367c6653c4c986558f6d0e4a700cfcc)
https://bugzilla.redhat.com/show_bug.cgi?id=1804750
Message-Id: <2694bc6f9a327f89d82da18320e7137152915ad3.1584391727.git.pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
docs/formatdomain.html.in | 16 +++++++++++++
docs/schemas/domaincommon.rng | 23 +++++++++++++++++++
src/conf/domain_conf.c | 19 +++++++++++++++
src/util/virstoragefile.c | 2 ++
src/util/virstoragefile.h | 3 +++
.../disk-network-http.xml | 2 ++
6 files changed, 65 insertions(+)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 5a10d64e83..2b8f9eabc2 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2842,6 +2842,8 @@
&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;
@@ -3392,6 +3394,20 @@
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>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index bdf35e64f6..3a0edbed97 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1808,6 +1808,25 @@
</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">
@@ -1854,6 +1873,7 @@
<optional>
<ref name="diskSourceNetworkProtocolHTTPCookies"/>
</optional>
+ <ref name="diskSourceNetworkProtocolPropsCommon"/>
</element>
</define>
@@ -1873,6 +1893,7 @@
<optional>
<ref name="diskSourceNetworkProtocolHTTPCookies"/>
</optional>
+ <ref name="diskSourceNetworkProtocolPropsCommon"/>
</element>
</define>
@@ -1892,6 +1913,7 @@
<optional>
<ref name="diskSourceNetworkProtocolSSLVerify"/>
</optional>
+ <ref name="diskSourceNetworkProtocolPropsCommon"/>
</element>
</define>
@@ -1910,6 +1932,7 @@
<optional>
<ref name="encryption"/>
</optional>
+ <ref name="diskSourceNetworkProtocolPropsCommon"/>
</element>
</define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d066d3aac1..8aec85e83c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9409,6 +9409,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;
}
@@ -24413,6 +24426,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;
}
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 6350168d73..7893e054c3 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -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;
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 1c7c046ad6..1abdaf89ce 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -296,6 +296,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 */
diff --git a/tests/genericxml2xmlindata/disk-network-http.xml b/tests/genericxml2xmlindata/disk-network-http.xml
index bafb77c8ec..a8430b8365 100644
--- a/tests/genericxml2xmlindata/disk-network-http.xml
+++ b/tests/genericxml2xmlindata/disk-network-http.xml
@@ -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>
--
2.25.1