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 <jhkim@linux.ibm.com>
---
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
On Wed, Jul 22, 2026 at 13:52:10 -0500, Jaehoon Kim wrote: > 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 <jhkim@linux.ibm.com> > --- > 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/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> Defining the range in the XML schema is not sufficient as validation is not mandatory. You'll need to add an explicit validation check in the code (e.g. in virDomainDefValidateIOThreads) to actually enforce this. And at that point I'd maybe suggest removing the XML check, the RNG validator from libxml2 tends to have rather poor error messages.
On 7/29/2026 8:52 AM, Peter Krempa wrote: > On Wed, Jul 22, 2026 at 13:52:10 -0500, Jaehoon Kim wrote: >> 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 <jhkim@linux.ibm.com> >> --- >> 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/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> > Defining the range in the XML schema is not sufficient as validation is > not mandatory. > > You'll need to add an explicit validation check in the code (e.g. in > virDomainDefValidateIOThreads) to actually enforce this. > > And at that point I'd maybe suggest removing the XML check, the RNG > validator from libxml2 tends to have rather poor error messages. Thanks for the feedback. I'll make the following changes in v2. 1.Add an explicit range check for poll-weight in virDomainDefValidateIOThreads in src/conf/domain_validate.c. 2.Simplify the RNG schema by replacing the maxInclusive constraint, since the range will be enforced during validation. Thanks, Jaehoon
© 2016 - 2026 Red Hat, Inc.