提交 66079339 编写于 作者: J Ján Tomko

conf: add virtiofs-related elements and attributes

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: NJán Tomko <jtomko@redhat.com>
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
Reviewed-by: NMasayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Reviewed-by: NPeter Krempa <pkrempa@redhat.com>
Tested-by: NAndrea Bolognani <abologna@redhat.com>
上级 ecc6ad6b
......@@ -3946,7 +3946,11 @@
&lt;readonly/&gt;
&lt;/filesystem&gt;
&lt;filesystem type='mount' accessmode='passthrough'&gt;
&lt;driver type='virtiofs'/&gt;
&lt;driver type='virtiofs queue='1024'/&gt;
&lt;binary path='/usr/libexec/virtiofsd' xattr='on'&gt;
&lt;cache mode='always'/&gt;
&lt;lock posix='on' flock='on'/&gt;
&lt;/binary&gt;
&lt;source dir='/path'/&gt;
&lt;target dir='mount_tag'/&gt;
&lt;/filesystem&gt;
......@@ -4073,9 +4077,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
......
......@@ -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">
......
......@@ -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, "<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:
......
......@@ -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);
......
......@@ -395,6 +395,7 @@ virDomainDiskSourceFormat;
virDomainDiskTranslateSourcePool;
virDomainFeatureTypeFromString;
virDomainFeatureTypeToString;
virDomainFSCacheModeTypeToString;
virDomainFSDefFree;
virDomainFSDefNew;
virDomainFSDriverTypeToString;
......
......@@ -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'/>
......
......@@ -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'/>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册