396 lines
14 KiB
Diff
396 lines
14 KiB
Diff
From c811bd72130364673dd4a0d2a997a1d8f675eb71 Mon Sep 17 00:00:00 2001
|
|
Message-Id: <c811bd72130364673dd4a0d2a997a1d8f675eb71@dist-git>
|
|
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
|
|
Date: Wed, 4 Mar 2020 12:42:42 +0100
|
|
Subject: [PATCH] conf: add virtiofs-related elements and attributes
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Add more elements for tuning the virtiofsd daemon
|
|
and the vhost-user-fs device:
|
|
|
|
<driver type='virtiofs' queue='1024' xattr='on'>
|
|
<binary path='/usr/libexec/virtiofsd'>
|
|
<cache mode='always'/>
|
|
<lock posix='off' flock='off'/>
|
|
</binary>
|
|
</driver>
|
|
|
|
Signed-off-by: Ján Tomko <jtomko@redhat.com>
|
|
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
|
|
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
|
|
Tested-by: Andrea Bolognani <abologna@redhat.com>
|
|
(cherry picked from commit 66079339847dc942b9b673e3040b56b055a8d8f5)
|
|
Signed-off-by: Ján Tomko <jtomko@redhat.com>
|
|
https://bugzilla.redhat.com/show_bug.cgi?id=1694166
|
|
Message-Id: <506d0532c6043a9b8c946bdc42c3d9c5529f6fb8.1583322090.git.jtomko@redhat.com>
|
|
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
---
|
|
docs/formatdomain.html.in | 25 ++++-
|
|
docs/schemas/domaincommon.rng | 48 ++++++++
|
|
src/conf/domain_conf.c | 104 +++++++++++++++++-
|
|
src/conf/domain_conf.h | 15 +++
|
|
src/libvirt_private.syms | 1 +
|
|
.../vhost-user-fs-fd-memory.xml | 6 +-
|
|
.../vhost-user-fs-hugepages.xml | 1 +
|
|
7 files changed, 197 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
|
|
index 337ab01316..e9830ab231 100644
|
|
--- a/docs/formatdomain.html.in
|
|
+++ b/docs/formatdomain.html.in
|
|
@@ -3936,7 +3936,11 @@
|
|
<readonly/>
|
|
</filesystem>
|
|
<filesystem type='mount' accessmode='passthrough'>
|
|
- <driver type='virtiofs'/>
|
|
+ <driver type='virtiofs queue='1024'/>
|
|
+ <binary path='/usr/libexec/virtiofsd' xattr='on'>
|
|
+ <cache mode='always'/>
|
|
+ <lock posix='on' flock='on'/>
|
|
+ </binary>
|
|
<source dir='/path'/>
|
|
<target dir='mount_tag'/>
|
|
</filesystem>
|
|
@@ -4063,9 +4067,28 @@
|
|
<a href="#elementsVirtio">Virtio-specific options</a> can also be
|
|
set. (<span class="since">Since 3.5.0</span>)
|
|
</li>
|
|
+ <li>
|
|
+ For <code>virtiofs</code>, the <code>queue</code> attribute can be used
|
|
+ to specify the queue size (i.e. how many requests can the queue fit).
|
|
+ (<span class="since">Since 6.2.0</span>)
|
|
+ </li>
|
|
</ul>
|
|
</dd>
|
|
|
|
+ <dt><code>binary</code></dt>
|
|
+ <dd>
|
|
+ The optional <code>binary</code> element can tune the options for virtiofsd.
|
|
+ All of the following attributes and elements are optional.
|
|
+ The attribute <code>path</code> can be used to override the path to the daemon.
|
|
+ Attribute <code>xattr</code> enables the use of filesystem extended attributes.
|
|
+ Caching can be tuned via the <code>cache</code> element, possible <code>mode</code>
|
|
+ values being <code>none</code> and <code>always</code>.
|
|
+ Locking can be controlled via the <code>lock</code>
|
|
+ element - attributes <code>posix</code> and <code>flock</code> both accepting
|
|
+ values <code>on</code> or <code>off</code>.
|
|
+ (<span class="since">Since 6.2.0</span>)
|
|
+ </dd>
|
|
+
|
|
<dt><code>source</code></dt>
|
|
<dd>
|
|
The resource on the host that is being accessed in the guest. The
|
|
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
|
|
index 5a9291b443..aa70e340b9 100644
|
|
--- a/docs/schemas/domaincommon.rng
|
|
+++ b/docs/schemas/domaincommon.rng
|
|
@@ -2500,6 +2500,9 @@
|
|
<optional>
|
|
<ref name="fsDriver"/>
|
|
</optional>
|
|
+ <optional>
|
|
+ <ref name="fsBinary"/>
|
|
+ </optional>
|
|
<interleave>
|
|
<element name="source">
|
|
<attribute name="dir">
|
|
@@ -2649,12 +2652,57 @@
|
|
<attribute name="type">
|
|
<value>virtiofs</value>
|
|
</attribute>
|
|
+ <optional>
|
|
+ <attribute name="queue">
|
|
+ <ref name="unsignedInt"/>
|
|
+ </attribute>
|
|
+ </optional>
|
|
<ref name='virtioOptions'/>
|
|
</group>
|
|
<empty/>
|
|
</choice>
|
|
</element>
|
|
</define>
|
|
+ <define name="fsBinary">
|
|
+ <element name="binary">
|
|
+ <optional>
|
|
+ <attribute name="path">
|
|
+ <ref name="absFilePath"/>
|
|
+ </attribute>
|
|
+ </optional>
|
|
+ <optional>
|
|
+ <attribute name="xattr">
|
|
+ <ref name="virOnOff"/>
|
|
+ </attribute>
|
|
+ </optional>
|
|
+ <optional>
|
|
+ <element name="cache">
|
|
+ <optional>
|
|
+ <attribute name="mode">
|
|
+ <choice>
|
|
+ <value>none</value>
|
|
+ <value>always</value>
|
|
+ </choice>
|
|
+ </attribute>
|
|
+ </optional>
|
|
+ </element>
|
|
+ </optional>
|
|
+ <optional>
|
|
+ <element name="lock">
|
|
+ <optional>
|
|
+ <attribute name="posix">
|
|
+ <ref name="virOnOff"/>
|
|
+ </attribute>
|
|
+ </optional>
|
|
+ <optional>
|
|
+ <attribute name="flock">
|
|
+ <ref name="virOnOff"/>
|
|
+ </attribute>
|
|
+ </optional>
|
|
+ </element>
|
|
+ </optional>
|
|
+ </element>
|
|
+ </define>
|
|
|
|
<define name="interface-network-attributes">
|
|
<attribute name="network">
|
|
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
index 31d4828802..3a370e6b90 100644
|
|
--- a/src/conf/domain_conf.c
|
|
+++ b/src/conf/domain_conf.c
|
|
@@ -500,6 +500,14 @@ VIR_ENUM_IMPL(virDomainFSModel,
|
|
"virtio-non-transitional",
|
|
);
|
|
|
|
+VIR_ENUM_IMPL(virDomainFSCacheMode,
|
|
+ VIR_DOMAIN_FS_CACHE_MODE_LAST,
|
|
+ "default",
|
|
+ "none",
|
|
+ "always",
|
|
+);
|
|
+
|
|
+
|
|
VIR_ENUM_IMPL(virDomainNet,
|
|
VIR_DOMAIN_NET_TYPE_LAST,
|
|
"user",
|
|
@@ -2322,6 +2330,7 @@ void virDomainFSDefFree(virDomainFSDefPtr def)
|
|
virDomainDeviceInfoClear(&def->info);
|
|
VIR_FREE(def->virtio);
|
|
virObjectUnref(def->privateData);
|
|
+ VIR_FREE(def->binary);
|
|
|
|
VIR_FREE(def);
|
|
}
|
|
@@ -11293,6 +11302,63 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|
}
|
|
}
|
|
|
|
+ if (def->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS) {
|
|
+ g_autofree char *queue_size = virXPathString("string(./driver/@queue)", ctxt);
|
|
+ g_autofree char *binary = virXPathString("string(./binary/@path)", ctxt);
|
|
+ g_autofree char *xattr = virXPathString("string(./binary/@xattr)", ctxt);
|
|
+ g_autofree char *cache = virXPathString("string(./binary/cache/@mode)", ctxt);
|
|
+ g_autofree char *posix_lock = virXPathString("string(./binary/lock/@posix)", ctxt);
|
|
+ g_autofree char *flock = virXPathString("string(./binary/lock/@flock)", ctxt);
|
|
+ int val;
|
|
+
|
|
+ if (queue_size && virStrToLong_ull(queue_size, NULL, 10, &def->queue_size) < 0) {
|
|
+ virReportError(VIR_ERR_XML_ERROR,
|
|
+ _("cannot parse queue size '%s' for virtiofs"),
|
|
+ queue_size);
|
|
+ goto error;
|
|
+ }
|
|
+
|
|
+ if (binary)
|
|
+ def->binary = virFileSanitizePath(binary);
|
|
+
|
|
+ if (xattr) {
|
|
+ if ((val = virTristateSwitchTypeFromString(xattr)) <= 0) {
|
|
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
+ _("unknown xattr value '%s'"), xattr);
|
|
+ goto error;
|
|
+ }
|
|
+ def->xattr = val;
|
|
+ }
|
|
+
|
|
+ if (cache) {
|
|
+ if ((val = virDomainFSCacheModeTypeFromString(cache)) <= 0) {
|
|
+ virReportError(VIR_ERR_XML_ERROR,
|
|
+ _("cannot parse cache mode '%s' for virtiofs"),
|
|
+ cache);
|
|
+ goto error;
|
|
+ }
|
|
+ def->cache = val;
|
|
+ }
|
|
+
|
|
+ if (posix_lock) {
|
|
+ if ((val = virTristateSwitchTypeFromString(posix_lock)) <= 0) {
|
|
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
+ _("unknown posix lock value '%s'"), posix_lock);
|
|
+ goto error;
|
|
+ }
|
|
+ def->posix_lock = val;
|
|
+ }
|
|
+
|
|
+ if (flock) {
|
|
+ if ((val = virTristateSwitchTypeFromString(flock)) <= 0) {
|
|
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
+ _("unknown flock value '%s'"), flock);
|
|
+ goto error;
|
|
+ }
|
|
+ def->flock = val;
|
|
+ }
|
|
+ }
|
|
+
|
|
if (format) {
|
|
if ((def->format = virStorageFileFormatTypeFromString(format)) <= 0) {
|
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
|
@@ -24994,6 +25060,9 @@ virDomainFSDefFormat(virBufferPtr buf,
|
|
const char *wrpolicy = virDomainFSWrpolicyTypeToString(def->wrpolicy);
|
|
const char *src = def->src->path;
|
|
g_auto(virBuffer) driverAttrBuf = VIR_BUFFER_INITIALIZER;
|
|
+ g_auto(virBuffer) driverBuf = VIR_BUFFER_INIT_CHILD(buf);
|
|
+ g_auto(virBuffer) binaryAttrBuf = VIR_BUFFER_INITIALIZER;
|
|
+ g_auto(virBuffer) binaryBuf = VIR_BUFFER_INIT_CHILD(buf);
|
|
|
|
if (!type) {
|
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
@@ -25017,6 +25086,8 @@ virDomainFSDefFormat(virBufferPtr buf,
|
|
virBufferAddLit(buf, ">\n");
|
|
|
|
virBufferAdjustIndent(buf, 2);
|
|
+ virBufferAdjustIndent(&driverBuf, 2);
|
|
+ virBufferAdjustIndent(&binaryBuf, 2);
|
|
if (def->fsdriver) {
|
|
virBufferAsprintf(&driverAttrBuf, " type='%s'", fsdriver);
|
|
|
|
@@ -25028,11 +25099,42 @@ virDomainFSDefFormat(virBufferPtr buf,
|
|
if (def->wrpolicy)
|
|
virBufferAsprintf(&driverAttrBuf, " wrpolicy='%s'", wrpolicy);
|
|
|
|
+ if (def->queue_size)
|
|
+ virBufferAsprintf(&driverAttrBuf, " queue='%llu'", def->queue_size);
|
|
+
|
|
+ }
|
|
+
|
|
+ if (def->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS) {
|
|
+ g_auto(virBuffer) lockAttrBuf = VIR_BUFFER_INITIALIZER;
|
|
+ virBufferEscapeString(&binaryAttrBuf, " path='%s'", def->binary);
|
|
+
|
|
+ if (def->xattr != VIR_TRISTATE_SWITCH_ABSENT) {
|
|
+ virBufferAsprintf(&binaryAttrBuf, " xattr='%s'",
|
|
+ virTristateSwitchTypeToString(def->xattr));
|
|
+ }
|
|
+
|
|
+ if (def->cache != VIR_DOMAIN_FS_CACHE_MODE_DEFAULT) {
|
|
+ virBufferAsprintf(&binaryBuf, "<cache mode='%s'/>\n",
|
|
+ virDomainFSCacheModeTypeToString(def->cache));
|
|
+ }
|
|
+
|
|
+ if (def->posix_lock != VIR_TRISTATE_SWITCH_ABSENT) {
|
|
+ virBufferAsprintf(&lockAttrBuf, " posix='%s'",
|
|
+ virTristateSwitchTypeToString(def->posix_lock));
|
|
+ }
|
|
+
|
|
+ if (def->flock != VIR_TRISTATE_SWITCH_ABSENT) {
|
|
+ virBufferAsprintf(&lockAttrBuf, " flock='%s'",
|
|
+ virTristateSwitchTypeToString(def->flock));
|
|
+ }
|
|
+
|
|
+ virXMLFormatElement(&binaryBuf, "lock", &lockAttrBuf, NULL);
|
|
}
|
|
|
|
virDomainVirtioOptionsFormat(&driverAttrBuf, def->virtio);
|
|
|
|
- virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL);
|
|
+ virXMLFormatElement(buf, "driver", &driverAttrBuf, &driverBuf);
|
|
+ virXMLFormatElement(buf, "binary", &binaryAttrBuf, &binaryBuf);
|
|
|
|
switch (def->type) {
|
|
case VIR_DOMAIN_FS_TYPE_MOUNT:
|
|
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
|
|
index 921cc42a57..2a382ede72 100644
|
|
--- a/src/conf/domain_conf.h
|
|
+++ b/src/conf/domain_conf.h
|
|
@@ -802,6 +802,14 @@ typedef enum {
|
|
VIR_DOMAIN_FS_MODEL_LAST
|
|
} virDomainFSModel;
|
|
|
|
+typedef enum {
|
|
+ VIR_DOMAIN_FS_CACHE_MODE_DEFAULT = 0,
|
|
+ VIR_DOMAIN_FS_CACHE_MODE_NONE,
|
|
+ VIR_DOMAIN_FS_CACHE_MODE_ALWAYS,
|
|
+
|
|
+ VIR_DOMAIN_FS_CACHE_MODE_LAST
|
|
+} virDomainFSCacheMode;
|
|
+
|
|
struct _virDomainFSDef {
|
|
int type;
|
|
int fsdriver; /* enum virDomainFSDriverType */
|
|
@@ -817,6 +825,12 @@ struct _virDomainFSDef {
|
|
unsigned long long space_hard_limit; /* in bytes */
|
|
unsigned long long space_soft_limit; /* in bytes */
|
|
bool symlinksResolved;
|
|
+ char *binary;
|
|
+ unsigned long long queue_size;
|
|
+ virTristateSwitch xattr;
|
|
+ virDomainFSCacheMode cache;
|
|
+ virTristateSwitch posix_lock;
|
|
+ virTristateSwitch flock;
|
|
virDomainVirtioOptionsPtr virtio;
|
|
virObjectPtr privateData;
|
|
};
|
|
@@ -3437,6 +3451,7 @@ VIR_ENUM_DECL(virDomainFSDriver);
|
|
VIR_ENUM_DECL(virDomainFSAccessMode);
|
|
VIR_ENUM_DECL(virDomainFSWrpolicy);
|
|
VIR_ENUM_DECL(virDomainFSModel);
|
|
+VIR_ENUM_DECL(virDomainFSCacheMode);
|
|
VIR_ENUM_DECL(virDomainNet);
|
|
VIR_ENUM_DECL(virDomainNetBackend);
|
|
VIR_ENUM_DECL(virDomainNetVirtioTxMode);
|
|
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
|
index bc2858fc00..5dc99e03cf 100644
|
|
--- a/src/libvirt_private.syms
|
|
+++ b/src/libvirt_private.syms
|
|
@@ -389,6 +389,7 @@ virDomainDiskSourceFormat;
|
|
virDomainDiskTranslateSourcePool;
|
|
virDomainFeatureTypeFromString;
|
|
virDomainFeatureTypeToString;
|
|
+virDomainFSCacheModeTypeToString;
|
|
virDomainFSDefFree;
|
|
virDomainFSDefNew;
|
|
virDomainFSDriverTypeToString;
|
|
diff --git a/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.xml b/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.xml
|
|
index a6b6279fb8..f6bb663e97 100644
|
|
--- a/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.xml
|
|
+++ b/tests/qemuxml2argvdata/vhost-user-fs-fd-memory.xml
|
|
@@ -27,7 +27,11 @@
|
|
<controller type='usb' index='0' model='none'/>
|
|
<controller type='pci' index='0' model='pci-root'/>
|
|
<filesystem type='mount' accessmode='passthrough'>
|
|
- <driver type='virtiofs'/>
|
|
+ <driver type='virtiofs' queue='1024'/>
|
|
+ <binary path='/usr/libexec/virtiofsd' xattr='on'>
|
|
+ <cache mode='always'/>
|
|
+ <lock posix='off' flock='off'/>
|
|
+ </binary>
|
|
<source dir='/path'/>
|
|
<target dir='mount_tag'/>
|
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
|
|
diff --git a/tests/qemuxml2argvdata/vhost-user-fs-hugepages.xml b/tests/qemuxml2argvdata/vhost-user-fs-hugepages.xml
|
|
index 70df7b890d..96b9774704 100644
|
|
--- a/tests/qemuxml2argvdata/vhost-user-fs-hugepages.xml
|
|
+++ b/tests/qemuxml2argvdata/vhost-user-fs-hugepages.xml
|
|
@@ -63,6 +63,7 @@
|
|
</controller>
|
|
<filesystem type='mount' accessmode='passthrough'>
|
|
<driver type='virtiofs'/>
|
|
+ <binary path='/usr/libexec/virtiofsd'/>
|
|
<source dir='/path'/>
|
|
<target dir='mount_tag'/>
|
|
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
|
|
--
|
|
2.25.1
|
|
|