diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index ca33a2a570..10584dfe83 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -3734,6 +3734,10 @@ A directory on the host that can be accessed directly from the guest.
The thread pool helps increase the number of requests in flight when used with
storage that has a higher latency. However, it has an overhead, and so for
fast, low latency filesystems, it may be best to turn it off. ( :since:`Since 8.5.0` )
+ Element ``rlimit_profile`` accepts one attribute ``size`` which defines the
+ maximum number of file descriptors. Non-positive values are forbidden.
+ Although numbers greater than 1M are allowed, the virtiofsd documentation
+ states that in this case its set by virtiofsd to the 1M. ( :since:`Since 10.6.0` )
``source``
The resource on the host that is being accessed in the guest. The ``name``
attribute must be used with ``type='template'``, and the ``dir`` attribute
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 32df908d95..6733857a3a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8868,6 +8868,7 @@ virDomainFSDefParseXML(virDomainXMLOption *xmlopt,
g_autofree char *queue_size = virXPathString("string(./driver/@queue)", ctxt);
g_autofree char *binary = virXPathString("string(./binary/@path)", ctxt);
g_autofree char *thread_pool_size = virXPathString("string(./binary/thread_pool/@size)", ctxt);
+ g_autofree char *rlimit_nofile = virXPathString("string(./binary/rlimit_nofile/@size)", ctxt);
xmlNodePtr binary_node = virXPathNode("./binary", ctxt);
xmlNodePtr binary_lock_node = virXPathNode("./binary/lock", ctxt);
xmlNodePtr binary_cache_node = virXPathNode("./binary/cache", ctxt);
@@ -8891,6 +8892,14 @@ virDomainFSDefParseXML(virDomainXMLOption *xmlopt,
goto error;
}
+ if (rlimit_nofile &&
+ virStrToLong_ull(rlimit_nofile, NULL, 10, &def->rlimit_nofile) < 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("cannot parse rlimit_nofile '%1$s' for virtiofs"),
+ rlimit_nofile);
+ goto error;
+ }
+
if (binary)
def->binary = virFileSanitizePath(binary);
@@ -23415,6 +23424,9 @@ virDomainFSDefFormat(virBuffer *buf,
if (def->thread_pool_size >= 0)
virBufferAsprintf(&binaryBuf, "\n", def->thread_pool_size);
+ if (def->rlimit_nofile > 0)
+ virBufferAsprintf(&binaryBuf, "\n", def->rlimit_nofile);
+
}
virDomainVirtioOptionsFormat(&driverAttrBuf, def->virtio);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 0fcc4f1f9b..8283493dfc 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -890,6 +890,7 @@ struct _virDomainFSDef {
bool symlinksResolved;
char *binary;
unsigned long long queue_size;
+ unsigned long long rlimit_nofile;
virTristateSwitch xattr;
virDomainFSCacheMode cache;
virTristateSwitch posix_lock;
diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng
index 2d23fcf123..ab5374d5f0 100644
--- a/src/conf/schemas/domaincommon.rng
+++ b/src/conf/schemas/domaincommon.rng
@@ -3380,6 +3380,15 @@
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxmlconfdata/vhost-user-fs-fd-rlimit.x86_64-latest.args b/tests/qemuxmlconfdata/vhost-user-fs-fd-rlimit.x86_64-latest.args
new file mode 100644
index 0000000000..b4c2e3fe98
--- /dev/null
+++ b/tests/qemuxmlconfdata/vhost-user-fs-fd-rlimit.x86_64-latest.args
@@ -0,0 +1,34 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/var/lib/libvirt/qemu/domain--1-guest \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-guest/.local/share \
+XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-guest/.cache \
+XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-guest/.config \
+/usr/bin/qemu-system-x86_64 \
+-name guest=guest,debug-threads=on \
+-S \
+-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain--1-guest/master-key.aes"}' \
+-machine pc,usb=off,dump-guest-core=off,acpi=off \
+-accel kvm \
+-cpu qemu64 \
+-m size=14680064k \
+-overcommit mem-lock=off \
+-smp 2,sockets=2,cores=1,threads=1 \
+-object '{"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/var/lib/libvirt/qemu/ram/-1-guest/ram-node0","share":true,"size":15032385536}' \
+-numa node,nodeid=0,cpus=0-1,memdev=ram-node0 \
+-uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot strict=on \
+-chardev socket,id=chr-vu-fs0,path=/var/lib/libvirt/qemu/domain--1-guest/fs0-fs.sock \
+-device '{"driver":"vhost-user-fs-pci","id":"fs0","chardev":"chr-vu-fs0","queue-size":1027,"tag":"mount_tag","bus":"pci.0","addr":"0x2"}' \
+-audiodev '{"id":"audio1","driver":"none"}' \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxmlconfdata/vhost-user-fs-fd-rlimit.x86_64-latest.xml b/tests/qemuxmlconfdata/vhost-user-fs-fd-rlimit.x86_64-latest.xml
new file mode 120000
index 0000000000..68c4e8a482
--- /dev/null
+++ b/tests/qemuxmlconfdata/vhost-user-fs-fd-rlimit.x86_64-latest.xml
@@ -0,0 +1 @@
+vhost-user-fs-fd-rlimit.xml
\ No newline at end of file
diff --git a/tests/qemuxmlconfdata/vhost-user-fs-fd-rlimit.xml b/tests/qemuxmlconfdata/vhost-user-fs-fd-rlimit.xml
new file mode 100644
index 0000000000..2983d3f275
--- /dev/null
+++ b/tests/qemuxmlconfdata/vhost-user-fs-fd-rlimit.xml
@@ -0,0 +1,50 @@
+
+ guest
+ 126f2720-6f8e-45ab-a886-ec9277079a67
+ 14680064
+ 14680064
+
+
+
+
+ 2
+
+ hvm
+
+
+
+ qemu64
+
+ |
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu-system-x86_64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c
index 392bb6c0ff..ed6a541249 100644
--- a/tests/qemuxmlconftest.c
+++ b/tests/qemuxmlconftest.c
@@ -2815,6 +2815,7 @@ mymain(void)
DO_TEST_CAPS_ARCH_LATEST("launch-security-s390-pv", "s390x");
DO_TEST_CAPS_LATEST("vhost-user-fs-fd-memory");
+ DO_TEST_CAPS_LATEST("vhost-user-fs-fd-rlimit");
DO_TEST_CAPS_LATEST("vhost-user-fs-hugepages");
DO_TEST_CAPS_LATEST_PARSE_ERROR("vhost-user-fs-readonly");