From nobody Fri Dec 27 02:48:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 172112288324049.773796355563036; Tue, 16 Jul 2024 02:41:23 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id DA8A0B39; Tue, 16 Jul 2024 05:41:21 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id F0A46B01; Tue, 16 Jul 2024 05:40:45 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 31CE5A7E; Tue, 16 Jul 2024 05:40:43 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 5EDE5AD6 for ; Tue, 16 Jul 2024 05:40:42 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-615-K-5YHcAiOnqpnVwivnMFTA-1; Tue, 16 Jul 2024 05:40:40 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7F32F1944B2B for ; Tue, 16 Jul 2024 09:40:39 +0000 (UTC) Received: from ajulis-thinkpadt14gen4.remote.csb (unknown [10.43.2.246]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A402B3000183 for ; Tue, 16 Jul 2024 09:40:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: ** X-Spam-Status: No, score=2.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721122842; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jmnZm43A8E5yAmoD43BtzCah4mkhBHmrJitNMgSzets=; b=Ia9eC5Tn2sayMj462mhgfRAkbE++jY6USm9DpEcd29Dz435rI/HGRj+nzEm3MLh1WAy+Gs z+73W8zqVnchnDHWK5QCjXN2K5Zuq/kfWCqfYuNtHsdKQ99FGE+AK1bnMP2LLqse4ceEq/ a3P2W/VrZlwsiwAKTAy1XIKLIUXjRg0= X-MC-Unique: K-5YHcAiOnqpnVwivnMFTA-1 From: Adam Julis To: devel@lists.libvirt.org Subject: [PATCH] conf: virtiofs: add rlimit_nofile element Date: Tue, 16 Jul 2024 11:40:36 +0200 Message-ID: <38fa5735d96972b79738179555715698d9a6712a.1721122769.git.ajulis@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: EY6PF4X4WISTESMNMO6LHFW75233A7UE X-Message-ID-Hash: EY6PF4X4WISTESMNMO6LHFW75233A7UE X-MailFrom: ajulis@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1721122884279116600 Content-Type: text/plain; charset="utf-8"; x-default="true" Add an element to configure the rlimit nofile size: ... ... Non-positive values are forbidden in 'domaincommon.rng'. Added separate test file, created by modifying the 'vhost-user-fs-fd-memory.xml'. Resolves: https://gitlab.com/libvirt/libvirt/-/issues/485 Signed-off-by: Adam Julis Reviewed-by: Michal Privoznik --- docs/formatdomain.rst | 4 ++ src/conf/domain_conf.c | 12 +++++ src/conf/domain_conf.h | 1 + src/conf/schemas/domaincommon.rng | 9 ++++ ...vhost-user-fs-fd-rlimit.x86_64-latest.args | 34 +++++++++++++ .../vhost-user-fs-fd-rlimit.x86_64-latest.xml | 50 +++++++++++++++++++ .../vhost-user-fs-fd-rlimit.xml | 50 +++++++++++++++++++ tests/qemuxmlconftest.c | 1 + 8 files changed, 161 insertions(+) create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-fd-rlimit.x86_64-la= test.args create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-fd-rlimit.x86_64-la= test.xml create mode 100644 tests/qemuxmlconfdata/vhost-user-fs-fd-rlimit.xml 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 directl= y from the guest. The thread pool helps increase the number of requests in flight when us= ed 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 documentati= on + states that in this case its set by virtiofsd to the 1M. ( :since:`Sinc= e 10.6.0` ) ``source`` The resource on the host that is being accessed in the guest. The ``nam= e`` attribute must be used with ``type=3D'template'``, and the ``dir`` attr= ibute 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 =3D virXPathString("string(./driver/@q= ueue)", ctxt); g_autofree char *binary =3D virXPathString("string(./binary/@path)= ", ctxt); g_autofree char *thread_pool_size =3D virXPathString("string(./bin= ary/thread_pool/@size)", ctxt); + g_autofree char *rlimit_nofile =3D virXPathString("string(./binary= /rlimit_nofile/@size)", ctxt); xmlNodePtr binary_node =3D virXPathNode("./binary", ctxt); xmlNodePtr binary_lock_node =3D virXPathNode("./binary/lock", ctxt= ); xmlNodePtr binary_cache_node =3D virXPathNode("./binary/cache", ct= xt); @@ -8891,6 +8892,14 @@ virDomainFSDefParseXML(virDomainXMLOption *xmlopt, goto error; } =20 + 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 virtio= fs"), + rlimit_nofile); + goto error; + } + if (binary) def->binary =3D virFileSanitizePath(binary); =20 @@ -23415,6 +23424,9 @@ virDomainFSDefFormat(virBuffer *buf, if (def->thread_pool_size >=3D 0) virBufferAsprintf(&binaryBuf, "\n", = def->thread_pool_size); =20 + if (def->rlimit_nofile > 0) + virBufferAsprintf(&binaryBuf, "\= n", def->rlimit_nofile); + } =20 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/domaincom= mon.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.ar= gs 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=3DC \ +PATH=3D/bin \ +HOME=3D/var/lib/libvirt/qemu/domain--1-guest \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/var/lib/libvirt/qemu/domain--1-guest/.local/share \ +XDG_CACHE_HOME=3D/var/lib/libvirt/qemu/domain--1-guest/.cache \ +XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-guest/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3Dguest,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/va= r/lib/libvirt/qemu/domain--1-guest/master-key.aes"}' \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,acpi=3Doff \ +-accel kvm \ +-cpu qemu64 \ +-m size=3D14680064k \ +-overcommit mem-lock=3Doff \ +-smp 2,sockets=3D2,cores=3D1,threads=3D1 \ +-object '{"qom-type":"memory-backend-file","id":"ram-node0","mem-path":"/v= ar/lib/libvirt/qemu/ram/-1-guest/ram-node0","share":true,"size":15032385536= }' \ +-numa node,nodeid=3D0,cpus=3D0-1,memdev=3Dram-node0 \ +-uuid 126f2720-6f8e-45ab-a886-ec9277079a67 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot strict=3Don \ +-chardev socket,id=3Dchr-vu-fs0,path=3D/var/lib/libvirt/qemu/domain--1-gue= st/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=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxmlconfdata/vhost-user-fs-fd-rlimit.x86_64-latest.xm= l b/tests/qemuxmlconfdata/vhost-user-fs-fd-rlimit.x86_64-latest.xml new file mode 100644 index 0000000000..2983d3f275 --- /dev/null +++ b/tests/qemuxmlconfdata/vhost-user-fs-fd-rlimit.x86_64-latest.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 + + + + + + + + + + + + + + + + +
+ + + +