Re: [libvirt] [PATCH] Strict check when listing domains

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

 




I am really sorry. I sent an older version of the patch, here is the correct one.


Eric Blake wrote:
On 03/24/2010 11:19 AM, Eduardo Otubo wrote:

     /* exit early if there are no domains */
-    if (nids == 0)
+    if (nids_numdomains == 0 || nids_listdomains == 0
+        || nids_numdomains != nids_listdomains)
         return 0;

Should we be reporting an error here...

- if (VIR_ALLOC_N(ids, nids) < 0) {
+    if (VIR_ALLOC_N(ids, nids_listdomains) < 0) {
         virReportOOMError();
         goto err;
     }
- if ((nids = phypListDomainsGeneric(conn, ids, nids, 1)) < 0)
-        goto err;
-
-    /* exit early if there are no domains */
-    /* FIXME: phypNumDomainsGeneric() returned > 0 but phypListDomainsGeneric()
-     *        returned 0. indicates this an error condition?
-     *        an even stricter check would be to treat
-     *
-     *          phypNumDomainsGeneric() != phypListDomainsGeneric()
-     *
-     *        as an error */

...given this comment?  You treated it as an early exit of 0, even if
both values were non-zero.



--
Eduardo Otubo
Software Engineer
Linux Technology Center
IBM Systems & Technology Group
Mobile: +55 19 8135 0885
eotubo@xxxxxxxxxxxxxxxxxx
diff --git a/.gnulib b/.gnulib
index 4f01268..10d66ae 160000
--- a/.gnulib
+++ b/.gnulib
@@ -1 +1 @@
-Subproject commit 4f01268d0c584c20704e42527f4fa125e7525aae
+Subproject commit 10d66aedfdd610f731c8c54152b9dfca3efbee12
diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 4f7efdb..eb6be32 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -1849,41 +1849,32 @@ phypUUIDTable_Init(virConnectPtr conn)
 {
     uuid_tablePtr uuid_table;
     phyp_driverPtr phyp_driver;
-    int nids = 0;
+    int nids_numdomains = 0;
+    int nids_listdomains = 0;
     int *ids = NULL;
     unsigned int i = 0;
 
-    if ((nids = phypNumDomainsGeneric(conn, 2)) < 0)
+    if ((nids_numdomains = phypNumDomainsGeneric(conn, 2)) < 0)
+        goto err;
+
+    if ((nids_listdomains =
+         phypListDomainsGeneric(conn, ids, nids_listdomains, 1)) < 0)
         goto err;
 
     /* exit early if there are no domains */
-    if (nids == 0)
+    if (nids_numdomains != nids_listdomains)
+        goto err;
+    else if (nids_numdomains == 0 && nids_listdomains == 0)
         return 0;
 
-    if (VIR_ALLOC_N(ids, nids) < 0) {
+    if (VIR_ALLOC_N(ids, nids_listdomains) < 0) {
         virReportOOMError();
         goto err;
     }
 
-    if ((nids = phypListDomainsGeneric(conn, ids, nids, 1)) < 0)
-        goto err;
-
-    /* exit early if there are no domains */
-    /* FIXME: phypNumDomainsGeneric() returned > 0 but phypListDomainsGeneric()
-     *        returned 0. indicates this an error condition?
-     *        an even stricter check would be to treat
-     *
-     *          phypNumDomainsGeneric() != phypListDomainsGeneric()
-     *
-     *        as an error */
-    if (nids == 0) {
-        VIR_FREE(ids);
-        return 0;
-    }
-
     phyp_driver = conn->privateData;
     uuid_table = phyp_driver->uuid_table;
-    uuid_table->nlpars = nids;
+    uuid_table->nlpars = nids_listdomains;
 
     /* try to get the table from server */
     if (phypUUIDTable_Pull(conn) == -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]