[libvirt] [PATCH 1/2] conf: Expose iothreadids when delete non sequential iothreadids

John Ferlan jferlan at redhat.com
Wed May 6 14:50:45 UTC 2015


Since 'autofill'd iothreadid entries are not written during XML format
processing, it is possible that if an iothreadid in the middle of an
autofilled list would then change it's id on a subsequent restart.

Thus during the iothreadid deletion, if we determine the delete is not
the "last" thread, then clear the autofill bit for all iothreadid's
following the one being deleted (either the first or one in the middle).
This way, iothreadid's will be printed/saved.

Signed-off-by: John Ferlan <jferlan at redhat.com>
---
 src/conf/domain_conf.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4cd36a1..b75291b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -17485,12 +17485,21 @@ void
 virDomainIOThreadIDDel(virDomainDefPtr def,
                        unsigned int iothread_id)
 {
-    int n;
+    size_t i, j;
+
+    for (i = 0; i < def->niothreadids; i++) {
+        if (def->iothreadids[i]->iothread_id == iothread_id) {
+            /* If we were sequential and removed a threadid in the
+             * beginning or middle of the list, then unconditionally
+             * clear the autofill flag so we don't lose these
+             * definitions for XML formatting.
+             */
+            for (j = i + 1; j < def->niothreadids; j++)
+                def->iothreadids[j]->autofill = false;
+
+            virDomainIOThreadIDDefFree(def->iothreadids[i]);
+            VIR_DELETE_ELEMENT(def->iothreadids, i, def->niothreadids);
 
-    for (n = 0; n < def->niothreadids; n++) {
-        if (def->iothreadids[n]->iothread_id == iothread_id) {
-            virDomainIOThreadIDDefFree(def->iothreadids[n]);
-            VIR_DELETE_ELEMENT(def->iothreadids, n, def->niothreadids);
             return;
         }
     }
-- 
2.1.0




More information about the libvir-list mailing list