]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: Store the iothread 'poll' settings in the XML
authorPeter Krempa <pkrempa@redhat.com>
Thu, 23 Feb 2023 12:48:35 +0000 (13:48 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 2 May 2023 12:32:47 +0000 (14:32 +0200)
Currently we allow configuring the 'poll-max-ns', 'poll-grow', and
'poll-shrink' parameters of qemu iothreads only during runtime and they
are not persisted. Add XML machinery to persist them.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
docs/formatdomain.rst
src/conf/domain_conf.c
src/conf/domain_conf.h
src/conf/schemas/domaincommon.rng
tests/qemuxml2argvdata/iothreads-ids-pool-sizes.xml

index 3b9251547e840c5195215d1194d0f2e32bf08561..99e0a4241c4cd1040970bf9f735ab1376d478d69 100644 (file)
@@ -740,7 +740,9 @@ host/guest with many LUNs. :since:`Since 1.2.8 (QEMU only)`
        <iothread id="2"/>
        <iothread id="4"/>
        <iothread id="6"/>
-       <iothread id="8" thread_pool_min="2" thread_pool_max="32"/>
+       <iothread id="8" thread_pool_min="2" thread_pool_max="32">
+         <poll max='123' grow='456' shrink='789'/>
+       </iothread>
      </iothreadids>
      <defaultiothread thread_pool_min="8" thread_pool_max="16"/>
      ...
@@ -766,6 +768,13 @@ host/guest with many LUNs. :since:`Since 1.2.8 (QEMU only)`
    ``thread_pool_max`` which allow setting lower and upper boundary for number
    of worker threads for given IOThread. While the former can be value of zero,
    the latter can't. :since:`Since 8.5.0`
+   :since:`Since 9.4.0` an optional sub-element ``poll`` with can be used to
+   override the hypervisor-default interval of polling for the iothread before
+   it switches back to events. The optional attribute ``max`` sets the maximum
+   time polling should be used in nanoseconds. Setting ``max`` to ``0`` disables
+   polling. Attributes ``grow`` and ``shrink`` override (or disable when set to
+   ``0`` the default steps for increasing/decreasing the polling interval if
+   the set interval is deemed insufficient or extensive.
 ``defaultiothread``
    This element represents the default event loop within hypervisor, where I/O
    requests from devices not assigned to a specific IOThread are processed.
index 222dd989f54f41d4c8c8913c79d6f1116d6b30d3..ac7165bad481e1ce7dbc8423ef4625dcc96eea7c 100644 (file)
@@ -15721,6 +15721,7 @@ static virDomainIOThreadIDDef *
 virDomainIOThreadIDDefParseXML(xmlNodePtr node)
 {
     g_autoptr(virDomainIOThreadIDDef) iothrid = virDomainIOThreadIDDefNew();
+    xmlNodePtr pollNode;
 
     if (virXMLPropUInt(node, "id", 10,
                        VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO,
@@ -15737,6 +15738,28 @@ virDomainIOThreadIDDefParseXML(xmlNodePtr node)
                       &iothrid->thread_pool_max, -1) < 0)
         return NULL;
 
+    if ((pollNode = virXMLNodeGetSubelement(node, "poll"))) {
+        int rc;
+
+        if ((rc = virXMLPropULongLong(pollNode, "max", 10, VIR_XML_PROP_NONE,
+                                      &iothrid->poll_max_ns)) < 0)
+            return NULL;
+
+        iothrid->set_poll_max_ns = rc == 1;
+
+        if ((rc = virXMLPropULongLong(pollNode, "grow", 10, VIR_XML_PROP_NONE,
+                                      &iothrid->poll_grow)) < 0)
+            return NULL;
+
+        iothrid->set_poll_grow = rc == 1;
+
+        if ((rc = virXMLPropULongLong(pollNode, "shrink", 10, VIR_XML_PROP_NONE,
+                                      &iothrid->poll_shrink)) < 0)
+            return NULL;
+
+        iothrid->set_poll_shrink = rc == 1;
+    }
+
     return g_steal_pointer(&iothrid);
 }
 
@@ -26630,6 +26653,9 @@ virDomainDefIothreadShouldFormat(const virDomainDef *def)
 
     for (i = 0; i < def->niothreadids; i++) {
         if (!def->iothreadids[i]->autofill ||
+            def->iothreadids[i]->set_poll_max_ns ||
+            def->iothreadids[i]->set_poll_grow ||
+            def->iothreadids[i]->set_poll_shrink ||
             def->iothreadids[i]->thread_pool_min >= 0 ||
             def->iothreadids[i]->thread_pool_max >= 0)
             return true;
@@ -26678,6 +26704,8 @@ virDomainDefIOThreadsFormat(virBuffer *buf,
         for (i = 0; i < def->niothreadids; i++) {
             virDomainIOThreadIDDef *iothread = def->iothreadids[i];
             g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
+            g_auto(virBuffer) iothreadChildBuf = VIR_BUFFER_INIT_CHILD(&childrenBuf);
+            g_auto(virBuffer) pollAttrBuf = VIR_BUFFER_INITIALIZER;
 
             virBufferAsprintf(&attrBuf, " id='%u'",
                               iothread->iothread_id);
@@ -26692,7 +26720,18 @@ virDomainDefIOThreadsFormat(virBuffer *buf,
                                   iothread->thread_pool_max);
             }
 
-            virXMLFormatElement(&childrenBuf, "iothread", &attrBuf, NULL);
+            if (iothread->set_poll_max_ns)
+                virBufferAsprintf(&pollAttrBuf, " max='%llu'", iothread->poll_max_ns);
+
+            if (iothread->set_poll_grow)
+                virBufferAsprintf(&pollAttrBuf, " grow='%llu'", iothread->poll_grow);
+
+            if (iothread->set_poll_shrink)
+                virBufferAsprintf(&pollAttrBuf, " shrink='%llu'", iothread->poll_shrink);
+
+            virXMLFormatElement(&iothreadChildBuf, "poll", &pollAttrBuf, NULL);
+
+            virXMLFormatElement(&childrenBuf, "iothread", &attrBuf, &iothreadChildBuf);
         }
 
         virXMLFormatElement(buf, "iothreadids", NULL, &childrenBuf);
index 2a8fc6f90d4fa23019d97db79d700ee8762f6c3e..88aef2991231e1bc70e5ce2fcd836de6c8853650 100644 (file)
@@ -2715,6 +2715,13 @@ struct _virDomainIOThreadIDDef {
 
     virDomainThreadSchedParam sched;
 
+    unsigned long long poll_max_ns;
+    bool set_poll_max_ns;
+    unsigned long long poll_grow;
+    bool set_poll_grow;
+    unsigned long long poll_shrink;
+    bool set_poll_shrink;
+
     int thread_pool_min;
     int thread_pool_max;
 };
index 6158ed79ac1096211c516dc42bfc415fec0164bd..57fb4a5e33adf7f0f30c0cf3d2ffb235e34a6072 100644 (file)
                   <ref name="unsignedInt"/>
                 </attribute>
               </optional>
+              <optional>
+                <element name="poll">
+                  <optional>
+                    <attribute name="max">
+                      <ref name="unsignedInt"/>
+                    </attribute>
+                  </optional>
+                  <optional>
+                    <attribute name="grow">
+                      <ref name="unsignedInt"/>
+                    </attribute>
+                  </optional>
+                  <optional>
+                    <attribute name="shrink">
+                      <ref name="unsignedInt"/>
+                    </attribute>
+                  </optional>
+                </element>
+              </optional>
             </element>
           </zeroOrMore>
         </element>
index df4b291a7af16613e6cb6519b4117ee4bf43b92a..63fb4a52f6bde7f0fb49681f0e0f642c24867ae0 100644 (file)
@@ -7,9 +7,15 @@
   <iothreads>5</iothreads>
   <iothreadids>
     <iothread id='2' thread_pool_min='0' thread_pool_max='60'/>
-    <iothread id='4' thread_pool_min='1' thread_pool_max='1'/>
-    <iothread id='1'/>
-    <iothread id='3'/>
+    <iothread id='4' thread_pool_min='1' thread_pool_max='1'>
+      <poll max='123'/>
+    </iothread>
+    <iothread id='1'>
+      <poll grow='456' shrink='789'/>
+    </iothread>
+    <iothread id='3'>
+      <poll max='123000' grow='456' shrink='789'/>
+    </iothread>
     <iothread id='5'/>
   </iothreadids>
   <defaultiothread thread_pool_min='8' thread_pool_max='16'/>