render / rpms / libvirt

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