libvirt/SOURCES/libvirt-domain_conf-Format-defaultiothread-more-often.patch
2022-11-15 07:37:10 +00:00

97 lines
3.7 KiB
Diff

From a39ce54007de67ce6909c1770a7759b09c41bfd6 Mon Sep 17 00:00:00 2001
Message-Id: <a39ce54007de67ce6909c1770a7759b09c41bfd6@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Thu, 7 Jul 2022 16:29:18 +0200
Subject: [PATCH] domain_conf: Format <defaultiothread/> more often
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The <defaultiothread/> element is formatted inside
virDomainDefaultIOThreadDefFormat() which is called only from
virDomainDefIOThreadsFormat() (so that IOThread related stuff is
formatted calling one function). However, when there are no
<iothreadids/> defined (or only autoallocated ones are present),
then the outer formatting function exits early never calling the
<defaultiothread/> formatter.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 24fa7004e47ce86b92bc23c1f2ef9c3d6152c3a8)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2059511
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
src/conf/domain_conf.c | 46 ++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 24 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 709ca53790..207a45d9ae 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -27763,40 +27763,38 @@ static void
virDomainDefIOThreadsFormat(virBuffer *buf,
const virDomainDef *def)
{
- g_auto(virBuffer) childrenBuf = VIR_BUFFER_INIT_CHILD(buf);
- size_t i;
-
- if (def->niothreadids == 0)
- return;
+ if (def->niothreadids > 0) {
+ virBufferAsprintf(buf, "<iothreads>%zu</iothreads>\n",
+ def->niothreadids);
+ }
- virBufferAsprintf(buf, "<iothreads>%zu</iothreads>\n",
- def->niothreadids);
+ if (virDomainDefIothreadShouldFormat(def)) {
+ g_auto(virBuffer) childrenBuf = VIR_BUFFER_INIT_CHILD(buf);
+ size_t i;
- if (!virDomainDefIothreadShouldFormat(def))
- return;
+ for (i = 0; i < def->niothreadids; i++) {
+ virDomainIOThreadIDDef *iothread = def->iothreadids[i];
+ g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
- for (i = 0; i < def->niothreadids; i++) {
- virDomainIOThreadIDDef *iothread = def->iothreadids[i];
- g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
+ virBufferAsprintf(&attrBuf, " id='%u'",
+ iothread->iothread_id);
- virBufferAsprintf(&attrBuf, " id='%u'",
- iothread->iothread_id);
+ if (iothread->thread_pool_min >= 0) {
+ virBufferAsprintf(&attrBuf, " thread_pool_min='%d'",
+ iothread->thread_pool_min);
+ }
- if (iothread->thread_pool_min >= 0) {
- virBufferAsprintf(&attrBuf, " thread_pool_min='%d'",
- iothread->thread_pool_min);
- }
+ if (iothread->thread_pool_max >= 0) {
+ virBufferAsprintf(&attrBuf, " thread_pool_max='%d'",
+ iothread->thread_pool_max);
+ }
- if (iothread->thread_pool_max >= 0) {
- virBufferAsprintf(&attrBuf, " thread_pool_max='%d'",
- iothread->thread_pool_max);
+ virXMLFormatElement(&childrenBuf, "iothread", &attrBuf, NULL);
}
- virXMLFormatElement(&childrenBuf, "iothread", &attrBuf, NULL);
+ virXMLFormatElement(buf, "iothreadids", NULL, &childrenBuf);
}
- virXMLFormatElement(buf, "iothreadids", NULL, &childrenBuf);
-
virDomainDefaultIOThreadDefFormat(buf, def);
}
--
2.35.1