[PATCH 02/13] conf: remove redundant iothreads variable

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

 



Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/conf/domain_conf.c  | 32 +++++++++++++++++---------------
 src/conf/domain_conf.h  |  1 -
 src/qemu/qemu_driver.c  |  6 ------
 src/qemu/qemu_process.c |  1 -
 4 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a179c1e278..71cd572a30 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2558,7 +2558,8 @@ virDomainIOThreadIDDefArrayFree(virDomainIOThreadIDDefPtr *def,
 
 
 static int
-virDomainIOThreadIDDefArrayInit(virDomainDefPtr def)
+virDomainIOThreadIDDefArrayInit(virDomainDefPtr def,
+                                unsigned int iothreads)
 {
     int retval = -1;
     size_t i;
@@ -2569,11 +2570,11 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def)
     /* Same value (either 0 or some number), then we have none to fill in or
      * the iothreadid array was filled from the XML
      */
-    if (def->iothreads == def->niothreadids)
+    if (iothreads == def->niothreadids)
         return 0;
 
     /* iothread's are numbered starting at 1, account for that */
-    if (!(thrmap = virBitmapNew(def->iothreads + 1)))
+    if (!(thrmap = virBitmapNew(iothreads + 1)))
         goto error;
     virBitmapSetAll(thrmap);
 
@@ -2585,11 +2586,11 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def)
                                        def->iothreadids[i]->iothread_id));
 
     /* resize array */
-    if (VIR_REALLOC_N(def->iothreadids, def->iothreads) < 0)
+    if (VIR_REALLOC_N(def->iothreadids, iothreads) < 0)
         goto error;
 
     /* Populate iothreadids[] using the set bit number from thrmap */
-    while (def->niothreadids < def->iothreads) {
+    while (def->niothreadids < iothreads) {
         if ((nxt = virBitmapNextSetBit(thrmap, nxt)) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("failed to populate iothreadids"));
@@ -16755,8 +16756,9 @@ virDomainDefParseXML(xmlDocPtr xml,
         goto error;
 
     /* Optional - iothreads */
+    unsigned int iothreads;
     tmp = virXPathString("string(./iothreads[1])", ctxt);
-    if (tmp && virStrToLong_uip(tmp, NULL, 10, &def->iothreads) < 0) {
+    if (tmp && virStrToLong_uip(tmp, NULL, 10, &iothreads) < 0) {
         virReportError(VIR_ERR_XML_ERROR,
                        _("invalid iothreads count '%s'"), tmp);
         goto error;
@@ -16767,8 +16769,8 @@ virDomainDefParseXML(xmlDocPtr xml,
     if ((n = virXPathNodeSet("./iothreadids/iothread", ctxt, &nodes)) < 0)
         goto error;
 
-    if (n > def->iothreads)
-        def->iothreads = n;
+    if (n > iothreads)
+        iothreads = n;
 
     if (n && VIR_ALLOC_N(def->iothreadids, n) < 0)
         goto error;
@@ -16789,7 +16791,7 @@ virDomainDefParseXML(xmlDocPtr xml,
     }
     VIR_FREE(nodes);
 
-    if (virDomainIOThreadIDDefArrayInit(def) < 0)
+    if (virDomainIOThreadIDDefArrayInit(def, iothreads) < 0)
         goto error;
 
     /* Extract cpu tunables. */
@@ -19487,11 +19489,11 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPtr src,
     if (!virDomainDefVcpuCheckAbiStability(src, dst))
         goto error;
 
-    if (src->iothreads != dst->iothreads) {
+    if (src->niothreadids != dst->niothreadids) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("Target domain iothreads count %u does not "
-                         "match source %u"),
-                       dst->iothreads, src->iothreads);
+                       _("Target domain iothreads count %lu does not "
+                         "match source %lu"),
+                       dst->niothreadids, src->niothreadids);
         goto error;
     }
 
@@ -23812,8 +23814,8 @@ virDomainDefFormatInternal(virDomainDefPtr def,
         goto error;
 
     if (def->niothreadids > 0) {
-        virBufferAsprintf(buf, "<iothreads>%u</iothreads>\n",
-                          def->iothreads);
+        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)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index dd79206f69..8ff2de8c25 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2210,7 +2210,6 @@ struct _virDomainDef {
     int placement_mode;
     virBitmapPtr cpumask;
 
-    unsigned int iothreads;
     size_t niothreadids;
     virDomainIOThreadIDDefPtr *iothreadids;
 
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index afbcded93f..661f6f5d34 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5617,10 +5617,8 @@ qemuDomainHotplugAddIOThread(virQEMUDriverPtr driver,
                        _("got wrong number of IOThread ids from QEMU monitor. "
                          "got %d, wanted %d"),
                        new_niothreads, exp_niothreads);
-        vm->def->iothreads = new_niothreads;
         goto cleanup;
     }
-    vm->def->iothreads = exp_niothreads;
 
     /*
      * If we've successfully added an IOThread, find out where we added it
@@ -5716,10 +5714,8 @@ qemuDomainHotplugDelIOThread(virQEMUDriverPtr driver,
                        _("got wrong number of IOThread ids from QEMU monitor. "
                          "got %d, wanted %d"),
                        new_niothreads, exp_niothreads);
-        vm->def->iothreads = new_niothreads;
         goto cleanup;
     }
-    vm->def->iothreads = exp_niothreads;
 
     virDomainIOThreadIDDel(vm->def, iothread_id);
 
@@ -5798,7 +5794,6 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver,
             if (!virDomainIOThreadIDAdd(persistentDef, iothread_id))
                 goto endjob;
 
-            persistentDef->iothreads++;
         } else {
             virDomainIOThreadIDDefPtr iothrid;
             if (!(iothrid = virDomainIOThreadIDFind(persistentDef,
@@ -5811,7 +5806,6 @@ qemuDomainChgIOThread(virQEMUDriverPtr driver,
             }
 
             virDomainIOThreadIDDel(persistentDef, iothread_id);
-            persistentDef->iothreads--;
         }
 
         if (virDomainSaveConfig(cfg->configDir, driver->caps,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 76f132bc8f..62f0b9b630 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2123,7 +2123,6 @@ qemuProcessDetectIOThreadPIDs(virQEMUDriverPtr driver,
             /* Remove any trace */
             VIR_FREE(vm->def->iothreadids);
             vm->def->niothreadids = 0;
-            vm->def->iothreads = 0;
         }
         return 0;
     }
-- 
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