]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: virtiofs: add thread_pool element
authorJán Tomko <jtomko@redhat.com>
Fri, 10 Jun 2022 13:10:29 +0000 (15:10 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 16 Jun 2022 12:58:25 +0000 (14:58 +0200)
Add an element to configure the thread pool size:

...
<binary>
  <thread_pool size='16'/>
</binary>
...

https://bugzilla.redhat.com/show_bug.cgi?id=2072905

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
docs/formatdomain.rst
src/conf/domain_conf.c
src/conf/domain_conf.h
src/conf/schemas/domaincommon.rng
tests/qemuxml2argvdata/vhost-user-fs-fd-memory.xml

index 19c4aa5e2ee469cf1387de6e3b103479edb8fb77..991d45672af55d3dd1addb242faf77627d4d978e 100644 (file)
@@ -3367,6 +3367,7 @@ A directory on the host that can be accessed directly from the guest.
             <cache mode='always'/>
             <sandbox mode='namespace'/>
             <lock posix='on' flock='on'/>
+            <thread_pool size='16'/>
          </binary>
          <source dir='/path'/>
          <target dir='mount_tag'/>
@@ -3500,6 +3501,11 @@ A directory on the host that can be accessed directly from the guest.
    ``chroot``, see the
    `virtiofsd documentation <https://qemu.readthedocs.io/en/latest/tools/virtiofsd.html>`__
    for more details. ( :since:`Since 7.2.0` )
+   Element ``thread_pool`` accepts one attribute ``size`` which defines the
+   maximum thread pool size. A value of "0" disables the pool.
+   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` )
 ``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
index 015ce0bce14a1ddc2c02fcc46821637f99b6a051..9fe930a5d820d4eb50feb7172e18114589ac236c 100644 (file)
@@ -2472,6 +2472,8 @@ virDomainFSDefNew(virDomainXMLOption *xmlopt)
 
     ret->src = virStorageSourceNew();
 
+    ret->thread_pool_size = -1;
+
     if (xmlopt &&
         xmlopt->privateData.fsNew &&
         !(ret->privateData = xmlopt->privateData.fsNew()))
@@ -9910,6 +9912,7 @@ virDomainFSDefParseXML(virDomainXMLOption *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 *thread_pool_size = virXPathString("string(./binary/thread_pool/@size)", ctxt);
         xmlNodePtr binary_node = virXPathNode("./binary", ctxt);
         xmlNodePtr binary_lock_node = virXPathNode("./binary/lock", ctxt);
         xmlNodePtr binary_cache_node = virXPathNode("./binary/cache", ctxt);
@@ -9922,6 +9925,14 @@ virDomainFSDefParseXML(virDomainXMLOption *xmlopt,
             goto error;
         }
 
+        if (thread_pool_size &&
+            virStrToLong_i(thread_pool_size, NULL, 10, &def->thread_pool_size) < 0) {
+            virReportError(VIR_ERR_XML_ERROR,
+                           _("cannot parse thread pool size '%s' for virtiofs"),
+                           queue_size);
+            goto error;
+        }
+
         if (binary)
             def->binary = virFileSanitizePath(binary);
 
@@ -24258,6 +24269,10 @@ virDomainFSDefFormat(virBuffer *buf,
         }
 
         virXMLFormatElement(&binaryBuf, "lock", &lockAttrBuf, NULL);
+
+        if (def->thread_pool_size >= 0)
+            virBufferAsprintf(&binaryBuf, "<thread_pool size='%d'/>\n", def->thread_pool_size);
+
     }
 
     virDomainVirtioOptionsFormat(&driverAttrBuf, def->virtio);
index 612ebc80b760703c631be62559ebeb40e779fdea..4c8c42b7eb6a72c2188654c99ce3913a2e553c47 100644 (file)
@@ -905,6 +905,7 @@ struct _virDomainFSDef {
     virTristateSwitch posix_lock;
     virTristateSwitch flock;
     virDomainFSSandboxMode sandbox;
+    int thread_pool_size;
     virDomainVirtioOptions *virtio;
     virObject *privateData;
 };
index 3ba4da46a4bba4dbd65d50a2da8888972751e328..e2246e6b633abd72774b49984aa20a3b5cbc6041 100644 (file)
             </optional>
           </element>
         </optional>
+        <optional>
+          <element name="thread_pool">
+            <optional>
+              <attribute name="size">
+                <data type="integer"/>
+              </attribute>
+            </optional>
+          </element>
+        </optional>
       </interleave>
     </element>
   </define>
index abddf0870b0cc1c8037ab769adc87c1b2e1b12ad..81de8c0dd7e98b228294fc9d94d2aea650abb8df 100644 (file)
@@ -32,6 +32,7 @@
         <cache mode='always'/>
         <sandbox mode='chroot'/>
         <lock posix='off' flock='off'/>
+        <thread_pool size='16'/>
       </binary>
       <source dir='/path'/>
       <target dir='mount_tag'/>