Add support for the iothread poll-weight XML attribute.

Store the value in the internal iothread definition, parse it from
the <poll/> element, and format it back into domain XML. Also extend
the schema to accept the new attribute and validate the accepted
range of [0, 63].

Signed-off-by: Jaehoon Kim <[email protected]>
---
 src/conf/domain_conf.c                     | 14 +++++++++++++-
 src/conf/domain_conf.h                     |  2 ++
 src/conf/schemas/domaincommon.rng          |  7 +++++++
 tests/genericxml2xmlindata/iothreadids.xml |  2 +-
 4 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 17c4a57cd8..f69317c36f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -16984,7 +16984,9 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt,
  *
  *     <iothreads>4</iothreads>
  *     <iothreadids>
- *       <iothread id='1' thread_pool_min="0" thread_pool_max="60"/>
+ *       <iothread id='1' thread_pool_min="0" thread_pool_max="60">
+ *         <poll max='32000' grow='2' shrink='2' weight='3'/>
+ *       </iothread>
  *       <iothread id='3'/>
  *       <iothread id='5'/>
  *       <iothread id='7'/>
@@ -17032,6 +17034,12 @@ virDomainIOThreadIDDefParseXML(xmlNodePtr node)
             return NULL;
 
         iothrid->set_poll_shrink = rc == 1;
+
+        if ((rc = virXMLPropUInt(pollNode, "weight", 10, VIR_XML_PROP_NONE,
+                                 &iothrid->poll_weight)) < 0)
+            return NULL;
+
+        iothrid->set_poll_weight = rc == 1;
     }
 
     return g_steal_pointer(&iothrid);
@@ -29011,6 +29019,7 @@ virDomainDefIothreadShouldFormat(const virDomainDef 
*def)
             def->iothreadids[i]->set_poll_max_ns ||
             def->iothreadids[i]->set_poll_grow ||
             def->iothreadids[i]->set_poll_shrink ||
+            def->iothreadids[i]->set_poll_weight ||
             def->iothreadids[i]->thread_pool_min >= 0 ||
             def->iothreadids[i]->thread_pool_max >= 0)
             return true;
@@ -29084,6 +29093,9 @@ virDomainDefIOThreadsFormat(virBuffer *buf,
             if (iothread->set_poll_shrink)
                 virBufferAsprintf(&pollAttrBuf, " shrink='%llu'", 
iothread->poll_shrink);
 
+            if (iothread->set_poll_weight)
+                virBufferAsprintf(&pollAttrBuf, " weight='%u'", 
iothread->poll_weight);
+
             virXMLFormatElement(&iothreadChildBuf, "poll", &pollAttrBuf, NULL);
 
             virXMLFormatElement(&childrenBuf, "iothread", &attrBuf, 
&iothreadChildBuf);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 0c6c79c413..eebe55a093 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2902,6 +2902,8 @@ struct _virDomainIOThreadIDDef {
     bool set_poll_grow;
     unsigned long long poll_shrink;
     bool set_poll_shrink;
+    unsigned int poll_weight;
+    bool set_poll_weight;
 
     int thread_pool_min;
     int thread_pool_max;
diff --git a/src/conf/schemas/domaincommon.rng 
b/src/conf/schemas/domaincommon.rng
index 121e4e06a6..36743f81e4 100644
--- a/src/conf/schemas/domaincommon.rng
+++ b/src/conf/schemas/domaincommon.rng
@@ -990,6 +990,13 @@
                       <ref name="unsignedLong"/>
                     </attribute>
                   </optional>
+                  <optional>
+                    <attribute name="weight">
+                      <data type="unsignedInt">
+                        <param name="maxInclusive">63</param>
+                      </data>
+                    </attribute>
+                  </optional>
                 </element>
               </optional>
             </element>
diff --git a/tests/genericxml2xmlindata/iothreadids.xml 
b/tests/genericxml2xmlindata/iothreadids.xml
index 671a467295..e9814854eb 100644
--- a/tests/genericxml2xmlindata/iothreadids.xml
+++ b/tests/genericxml2xmlindata/iothreadids.xml
@@ -7,7 +7,7 @@
   <iothreads>1</iothreads>
   <iothreadids>
     <iothread id='8' thread_pool_min='2147483647' thread_pool_max='2147483647'>
-      <poll max='9223372036854775807' grow='456' shrink='789'/>
+      <poll max='9223372036854775807' grow='456' shrink='789' weight='3'/>
     </iothread>
   </iothreadids>
   <os>
-- 
2.54.0

Reply via email to