diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index aad8d2ce8e..7e7771725c 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -3946,7 +3946,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>
@@ -4073,9 +4077,28 @@
Virtio-specific options can also be
set. (Since 3.5.0 )
+
+ For virtiofs
, the queue
attribute can be used
+ to specify the queue size (i.e. how many requests can the queue fit).
+ (Since 6.2.0 )
+
+ binary
+
+ The optional binary
element can tune the options for virtiofsd.
+ All of the following attributes and elements are optional.
+ The attribute path
can be used to override the path to the daemon.
+ Attribute xattr
enables the use of filesystem extended attributes.
+ Caching can be tuned via the cache
element, possible mode
+ values being none
and always
.
+ Locking can be controlled via the lock
+ element - attributes posix
and flock
both accepting
+ values on
or off
.
+ (Since 6.2.0 )
+
+
source
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 fbe4c554a4..529a98fc05 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2500,6 +2500,9 @@
+
+
+
@@ -2649,12 +2652,57 @@
virtiofs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ none
+ always
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1418d5828f..bfb95dd2ce 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -501,6 +501,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",
@@ -2326,6 +2334,7 @@ void virDomainFSDefFree(virDomainFSDefPtr def)
virDomainDeviceInfoClear(&def->info);
VIR_FREE(def->virtio);
virObjectUnref(def->privateData);
+ VIR_FREE(def->binary);
VIR_FREE(def);
}
@@ -11369,6 +11378,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,
@@ -25206,6 +25272,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,
@@ -25229,6 +25298,8 @@ virDomainFSDefFormat(virBufferPtr buf,
virBufferAddLit(buf, ">\n");
virBufferAdjustIndent(buf, 2);
+ virBufferAdjustIndent(&driverBuf, 2);
+ virBufferAdjustIndent(&binaryBuf, 2);
if (def->fsdriver) {
virBufferAsprintf(&driverAttrBuf, " type='%s'", fsdriver);
@@ -25240,11 +25311,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, " \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 9921c25293..91b776c28a 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -805,6 +805,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 */
@@ -820,6 +828,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;
};
@@ -3451,6 +3465,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 de0c7a3133..8563695c32 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -395,6 +395,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 @@
-
+
+
+
+
+
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 @@
+