From nobody Sun Feb 8 18:39:13 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 15804040871477.303719265281188; Thu, 30 Jan 2020 09:08:07 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-347-bEcAYDViPMerAGwVS-FuFg-1; Thu, 30 Jan 2020 12:07:05 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C42CE1005514; Thu, 30 Jan 2020 17:06:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9F8AD5C548; Thu, 30 Jan 2020 17:06:48 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 637C087A93; Thu, 30 Jan 2020 17:06:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00UH6cwt002162 for ; Thu, 30 Jan 2020 12:06:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0801277928; Thu, 30 Jan 2020 17:06:38 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.43.2.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 826AB77948 for ; Thu, 30 Jan 2020 17:06:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580404086; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=kOLpsY2TFFlPl24y+e+yB7ihjOLmnPJJkPAGWagmnRA=; b=bOFzzxbmdedk+PriKj6xp76OlWBmZ1v8+11Ydw+y3IX182wa7J7/RWc6vfsnDM8j6LXUh4 umKdNHUColxdeF7ae2qj/D7BdUcxFLTlRVgmsEemhEVgBFYY8YPwoSgNOKrgTa+dbw69p2 ATRu1Z5s4xzWSFFG2/h9xMaZrgwSP3w= From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCHv3 06/12] conf: add virtiofs-related elements and attributes Date: Thu, 30 Jan 2020 18:06:22 +0100 Message-Id: <1b6b5613712328f1e5f7d2f96392fb20fa7d3c1e.1580403751.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: bEcAYDViPMerAGwVS-FuFg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Add more elements for tuning the virtiofsd daemon and the vhost-user-fs device: /usr/libexec/virtiofsd Signed-off-by: J=C3=A1n Tomko Reviewed-by: Daniel P. Berrang=C3=A9 --- docs/formatdomain.html.in | 25 +++- docs/schemas/domaincommon.rng | 48 ++++++++ src/conf/domain_conf.c | 107 +++++++++++++++++- 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, 200 insertions(+), 3 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index d5565361ab..58e06d21f5 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -3922,10 +3922,15 @@ <readonly/> </filesystem> <filesystem type=3D'mount' accessmode=3D'passthrough'> - <driver type=3D'virtiofs'/> + <driver type=3D'virtiofs queue=3D'1024'/> + <binary path=3D'/usr/libexec/virtiofsd' xattr=3D'on'> + <cache mode=3D'always'/> + <lock posix=3D'on' flock=3D'on'/> + </binary> <source dir=3D'/path'/> <target dir=3D'mount_tag'/> </filesystem> + ... </devices> ... @@ -4049,9 +4054,27 @@ Virtio-specific options can also= be set. (Since 3.5.0) +
  • + For virtiofs, the queue attribute ca= n be used + to specify the queue size (i.e. how many requests can the queu= e fit). + (Since 6.1.0) +
  • =20 +
    binary
    +
    + The optional binary element can tune the options for = virtiofsd. + The attribute path can be used to override the path t= o the daemon. + Attribute xattr enables the use of filesystem extende= d 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 bot= h accepting + values yes or no. + (Since 6.1.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 e30b82c57e..db475a43ca 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2480,6 +2480,9 @@ + + + @@ -2629,12 +2632,57 @@ virtiofs + + + + + + + + + + + + + + + + + + + + + + + none + always + + + + + + + + + + + + + + + + + + + + + =20 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index d1a6d125d7..5c26e0d06c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -501,6 +501,14 @@ VIR_ENUM_IMPL(virDomainFSModel, "virtio-non-transitional", ); =20 +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) VIR_FREE(def->dst); virDomainDeviceInfoClear(&def->info); VIR_FREE(def->virtio); + VIR_FREE(def->binary); =20 VIR_FREE(def); } @@ -11254,6 +11263,64 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlop= t, } } =20 + if (def->fsdriver =3D=3D VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS) { + 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 *xattr =3D virXPathString("string(./binary/@xattr)= ", ctxt); + g_autofree char *cache =3D virXPathString("string(./binary/cache/@= mode)", ctxt); + g_autofree char *posix_lock =3D virXPathString("string(./binary/lo= ck/@posix)", ctxt); + g_autofree char *flock =3D virXPathString("string(./binary/lock/@f= lock)", ctxt); + int val; + + + if (queue_size && virStrToLong_ull(queue_size, NULL, 10, &def->que= ue_size) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("cannot parse queue size '%s' for virtiofs"), + queue_size); + goto error; + } + + if (binary) + def->binary =3D virFileSanitizePath(binary); + + if (xattr) { + if ((val =3D virTristateSwitchTypeFromString(xattr)) <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown xattr value '%s'"), xattr); + goto error; + } + def->xattr =3D val; + } + + if (cache) { + if ((val =3D virDomainFSCacheModeTypeFromString(cache)) <=3D 0= ) { + virReportError(VIR_ERR_XML_ERROR, + _("cannot parse cache mode '%s' for virtiof= s"), + cache); + goto error; + } + def->cache =3D val; + } + + if (posix_lock) { + if ((val =3D virTristateSwitchTypeFromString(posix_lock)) <=3D= 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown posix lock value '%s'"), posix_l= ock); + goto error; + } + def->posix_lock =3D val; + } + + if (flock) { + if ((val =3D virTristateSwitchTypeFromString(flock)) <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown flock value '%s'"), flock); + goto error; + } + def->flock =3D val; + } + } + if (format) { if ((def->format =3D virStorageFileFormatTypeFromString(format)) <= =3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -25053,6 +25120,9 @@ virDomainFSDefFormat(virBufferPtr buf, const char *wrpolicy =3D virDomainFSWrpolicyTypeToString(def->wrpolicy= ); const char *src =3D def->src->path; g_auto(virBuffer) driverAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) driverBuf =3D VIR_BUFFER_INIT_CHILD(buf); + g_auto(virBuffer) binaryAttrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) binaryBuf =3D VIR_BUFFER_INIT_CHILD(buf); =20 if (!type) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -25076,6 +25146,8 @@ virDomainFSDefFormat(virBufferPtr buf, virBufferAddLit(buf, ">\n"); =20 virBufferAdjustIndent(buf, 2); + virBufferAdjustIndent(&driverBuf, 2); + virBufferAdjustIndent(&binaryBuf, 2); if (def->fsdriver) { virBufferAsprintf(&driverAttrBuf, " type=3D'%s'", fsdriver); =20 @@ -25087,11 +25159,44 @@ virDomainFSDefFormat(virBufferPtr buf, if (def->wrpolicy) virBufferAsprintf(&driverAttrBuf, " wrpolicy=3D'%s'", wrpolicy= ); =20 + if (def->queue_size) + virBufferAsprintf(&driverAttrBuf, " queue=3D'%llu'", def->queu= e_size); + + } + + if (def->fsdriver =3D=3D VIR_DOMAIN_FS_DRIVER_TYPE_VIRTIOFS) { + g_auto(virBuffer) lockAttrBuf =3D VIR_BUFFER_INITIALIZER; + virBufferEscapeString(&binaryAttrBuf, " path=3D'%s'", def->binary); + + if (def->xattr !=3D VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(&binaryAttrBuf, " xattr=3D'%s'", + virTristateSwitchTypeToString(def->xattr)); + } + + if (def->cache !=3D VIR_DOMAIN_FS_CACHE_MODE_DEFAULT) { + virBufferAsprintf(&binaryBuf, "\n", + virDomainFSCacheModeTypeToString(def->cache)= ); + } + + if (def->posix_lock !=3D VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(&lockAttrBuf, " posix=3D'%s'", + virTristateSwitchTypeToString(def->posix_loc= k)); + } + + if (def->flock !=3D VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(&lockAttrBuf, " flock=3D'%s'", + virTristateSwitchTypeToString(def->flock)); + } + + virXMLFormatElement(&binaryBuf, "lock", &lockAttrBuf, NULL); } =20 + virDomainVirtioOptionsFormat(&driverAttrBuf, def->virtio); =20 - virXMLFormatElement(buf, "driver", &driverAttrBuf, NULL); + virXMLFormatElement(buf, "driver", &driverAttrBuf, &driverBuf); + virXMLFormatElement(buf, "binary", &binaryAttrBuf, &binaryBuf); + virXMLFormatElement(buf, "driver", &driverAttrBuf, &driverBuf); =20 switch (def->type) { case VIR_DOMAIN_FS_TYPE_MOUNT: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index de2bd3be93..21a36c34ef 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -804,6 +804,14 @@ typedef enum { VIR_DOMAIN_FS_MODEL_LAST } virDomainFSModel; =20 +typedef enum { + VIR_DOMAIN_FS_CACHE_MODE_DEFAULT =3D 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 */ @@ -819,6 +827,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; }; @@ -3441,6 +3455,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 ebf830791e..30c3b12d79 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/qem= uxml2argvdata/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/qem= uxml2argvdata/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 @@ +
    --=20 2.21.0