[PATCH v2 05/13] conf: display all iothread ids in the XML if one of them is not generated

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/conf/domain_conf.c                             | 23 ++++++++++++++--------
 .../qemuxml2xmlout-iothreads-ids-partial.xml       |  2 ++
 2 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7612185df1..cef6be48c4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -23696,6 +23696,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.
@@ -23889,17 +23903,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);
             }
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-iothreads-ids-partial.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-iothreads-ids-partial.xml
index d6deced96a..57f3be96fc 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-iothreads-ids-partial.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-iothreads-ids-partial.xml
@@ -6,6 +6,8 @@
   <vcpu placement='static'>2</vcpu>
   <iothreads>4</iothreads>
   <iothreadids>
+    <iothread id='1'/>
+    <iothread id='2'/>
     <iothread id='5'/>
     <iothread id='6'/>
   </iothreadids>
-- 
2.11.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux