render / rpms / libvirt

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