]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
domain_conf: Format <defaultiothread/> more often
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 7 Jul 2022 14:29:18 +0000 (16:29 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 13 Jul 2022 09:55:06 +0000 (11:55 +0200)
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>
src/conf/domain_conf.c

index b6390223961a70aa97c29e82f2beaf6cc0af58dd..24f17a8b91a2725312559da1800d87a467648b44 100644 (file)
@@ -26349,40 +26349,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);
 }