]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: bitmap: Tolerate NULL bitmaps in virBitmapEqual
authorPeter Krempa <pkrempa@redhat.com>
Tue, 20 Jan 2015 18:41:08 +0000 (19:41 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 29 Jan 2015 07:22:41 +0000 (08:22 +0100)
After virBitmapEqual is able to compare NULL bitmaps few bits of code
can be cleaned up.

src/conf/domain_conf.c
src/conf/numatune_conf.c
src/util/virbitmap.c
src/util/virbitmap.h

index 3c6b77dc6f42cb76fb70e56b8074c73c0500394b..d562e1a405488b7cecc2598ffd8bf1f6682740d0 100644 (file)
@@ -15637,18 +15637,10 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
             goto error;
         }
 
-        if (src_huge->nodemask && dst_huge->nodemask) {
-            if (!virBitmapEqual(src_huge->nodemask, dst_huge->nodemask)) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("Target huge page nodemask does not match source"));
-                goto error;
-            }
-        } else {
-            if (src_huge->nodemask || dst_huge->nodemask) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("Target huge page nodemask does not match source"));
-                goto error;
-            }
+        if (!virBitmapEqual(src_huge->nodemask, dst_huge->nodemask)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("Target huge page nodemask does not match source"));
+            goto error;
         }
     }
 
@@ -19138,20 +19130,12 @@ virDomainIsAllVcpupinInherited(virDomainDefPtr def)
 {
     size_t i;
 
-    if (!def->cpumask) {
-        if (def->cputune.nvcpupin)
+    for (i = 0; i < def->cputune.nvcpupin; i++) {
+        if (!virBitmapEqual(def->cputune.vcpupin[i]->cpumask, def->cpumask))
             return false;
-        else
-            return true;
-    } else {
-        for (i = 0; i < def->cputune.nvcpupin; i++) {
-            if (!virBitmapEqual(def->cputune.vcpupin[i]->cpumask,
-                                def->cpumask))
-                return false;
-        }
+    }
 
-        return true;
-   }
+    return true;
 }
 
 
@@ -19489,9 +19473,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
     for (i = 0; i < def->cputune.nvcpupin; i++) {
         char *cpumask;
         /* Ignore the vcpupin which inherit from "cpuset of "<vcpu>." */
-        if (def->cpumask &&
-            virBitmapEqual(def->cpumask,
-                           def->cputune.vcpupin[i]->cpumask))
+        if (virBitmapEqual(def->cpumask, def->cputune.vcpupin[i]->cpumask))
             continue;
 
         virBufferAsprintf(buf, "<vcpupin vcpu='%u' ",
@@ -19518,9 +19500,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
     for (i = 0; i < def->cputune.niothreadspin; i++) {
         char *cpumask;
         /* Ignore the iothreadpin which inherit from "cpuset of "<vcpu>." */
-        if (def->cpumask &&
-            virBitmapEqual(def->cpumask,
-                           def->cputune.iothreadspin[i]->cpumask))
+        if (virBitmapEqual(def->cpumask, def->cputune.iothreadspin[i]->cpumask))
             continue;
 
         virBufferAsprintf(buf, "<iothreadpin iothread='%u' ",
index ad928e0ded889318cf6bc6c0e9fc88a5f1c243e0..323cd59d19cac8ee366a9eb05bd59eceff64d45b 100644 (file)
@@ -542,9 +542,6 @@ virDomainNumatuneNodesEqual(virDomainNumatunePtr n1,
         if (!nd1->nodeset && !nd2->nodeset)
             continue;
 
-        if (!nd1->nodeset || !nd2->nodeset)
-            return false;
-
         if (nd1->mode != nd2->mode)
             return false;
 
index 05c50e4e8e6f97063b36eb0b239448c9629830a9..d5b0035f504173f963aa1b553e2bee0f44cfe12b 100644 (file)
@@ -504,6 +504,12 @@ bool virBitmapEqual(virBitmapPtr b1, virBitmapPtr b2)
     virBitmapPtr tmp;
     size_t i;
 
+    if (!b1 && !b2)
+        return true;
+
+    if (!b1 || !b2)
+        return false;
+
     if (b1->max_bit > b2->max_bit) {
         tmp = b1;
         b1 = b2;
index 565264cc4c4283cde7e2904066e33b42d6961976..a347f0afdc8d432adc8bcbe48a68a15e77724e68 100644 (file)
@@ -84,8 +84,7 @@ virBitmapPtr virBitmapNewData(void *data, int len) ATTRIBUTE_NONNULL(1);
 int virBitmapToData(virBitmapPtr bitmap, unsigned char **data, int *dataLen)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
 
-bool virBitmapEqual(virBitmapPtr b1, virBitmapPtr b2)
-    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+bool virBitmapEqual(virBitmapPtr b1, virBitmapPtr b2);
 
 size_t virBitmapSize(virBitmapPtr bitmap)
     ATTRIBUTE_NONNULL(1);