]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: display all iothread ids in the XML if one of them is not generated
authorPavel Hrdina <phrdina@redhat.com>
Mon, 20 Feb 2017 17:03:08 +0000 (18:03 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Mon, 20 Feb 2017 17:40:54 +0000 (18:40 +0100)
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
src/conf/domain_conf.c
tests/qemuxml2xmloutdata/qemuxml2xmlout-iothreads-ids-partial.xml

index d437fbf020e913d51b6fd8501a1855b2f1245aea..f39e9ec465ba2496e2c535e8c2f274b7f7f03b3f 100644 (file)
@@ -23658,6 +23658,20 @@ virDomainCpuDefFormat(virBufferPtr buf,
 }
 
 
+static bool
+virDomainDefIothreadShouldFormat(virDomainDefPtr def)
+{
+    size_t i;
+
+    for (i = 0; i < def->niothreadids; i++) {
+        if (!def->iothreadids[i]->autofill)
+            return true;
+    }
+
+    return false;
+}
+
+
 /* This internal version appends to an existing buffer
  * (possibly with auto-indent), rather than flattening
  * to string.
@@ -23851,17 +23865,10 @@ virDomainDefFormatInternal(virDomainDefPtr def,
     if (def->niothreadids > 0) {
         virBufferAsprintf(buf, "<iothreads>%lu</iothreads>\n",
                           def->niothreadids);
-        /* Only print out iothreadids if we read at least one */
-        for (i = 0; i < def->niothreadids; i++) {
-            if (!def->iothreadids[i]->autofill)
-                break;
-        }
-        if (i < def->niothreadids) {
+        if (virDomainDefIothreadShouldFormat(def)) {
             virBufferAddLit(buf, "<iothreadids>\n");
             virBufferAdjustIndent(buf, 2);
             for (i = 0; i < def->niothreadids; i++) {
-                if (def->iothreadids[i]->autofill)
-                    continue;
                 virBufferAsprintf(buf, "<iothread id='%u'/>\n",
                                   def->iothreadids[i]->iothread_id);
             }
index d6deced96a1aff2791f7630baef83bb7b0e82adf..276b6a61a2df5aafd04a422055dc7f6851efcb02 100644 (file)
@@ -8,6 +8,8 @@
   <iothreadids>
     <iothread id='5'/>
     <iothread id='6'/>
+    <iothread id='1'/>
+    <iothread id='2'/>
   </iothreadids>
   <os>
     <type arch='i686' machine='pc'>hvm</type>