]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
bitmap: new member variable and function renaming
authorHu Tao <hutao@cn.fujitsu.com>
Fri, 14 Sep 2012 07:46:56 +0000 (15:46 +0800)
committerLaine Stump <laine@laine.org>
Mon, 17 Sep 2012 18:59:36 +0000 (14:59 -0400)
Add a new member variable map_len to store map len of bitmap.
and rename size to max_bit accordingly.

rename virBitmapAlloc to virBitmapNew.

src/conf/domain_conf.c
src/conf/snapshot_conf.c
src/libvirt_private.syms
src/libxl/libxl_driver.c
src/qemu/qemu_capabilities.c
src/qemu/qemu_driver.c
src/util/bitmap.c
src/util/bitmap.h
tools/virsh-domain.c

index 75756c4e85a1d32152f151035c5906e59ed34033..b43195ff5bd4363a4a0f2abd0f0b1d6b79592530 100644 (file)
@@ -9110,7 +9110,7 @@ static virDomainDefPtr virDomainDefParseXML(virCapsPtr caps,
     if (STREQ(def->os.type, "hvm")) {
         if (virDomainDefParseBootXML(ctxt, def, &bootMapSize) < 0)
             goto error;
-        if (bootMapSize && !(bootMap = virBitmapAlloc(bootMapSize)))
+        if (bootMapSize && !(bootMap = virBitmapNew(bootMapSize)))
             goto no_memory;
     }
 
index e13cdd6dd09be4d9aabf51c5f393a76dd5c0b108..ba5b1887c41ebaac9ab102ad3de90575e62bb13f 100644 (file)
@@ -357,7 +357,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def,
         goto cleanup;
     }
 
-    if (!(map = virBitmapAlloc(def->dom->ndisks))) {
+    if (!(map = virBitmapNew(def->dom->ndisks))) {
         virReportOOMError();
         goto cleanup;
     }
index db08c09534d966a653f05e85ee828ce5c928a44f..9c0e40bf0f163fddf7662ebdc68027a622adedae 100644 (file)
@@ -6,11 +6,11 @@
 #
 
 # bitmap.h
-virBitmapAlloc;
 virBitmapClearBit;
 virBitmapCopy;
 virBitmapFree;
 virBitmapGetBit;
+virBitmapNew;
 virBitmapSetBit;
 virBitmapString;
 
index 1638314c03fe22c1770b9e1797727b93c73e237b..eccae295f90a8200a015201326b95db4c545208d 100644 (file)
@@ -869,7 +869,7 @@ libxlStartup(int privileged) {
 
     /* Allocate bitmap for vnc port reservation */
     if ((libxl_driver->reservedVNCPorts =
-         virBitmapAlloc(LIBXL_VNC_PORT_MAX - LIBXL_VNC_PORT_MIN)) == NULL)
+         virBitmapNew(LIBXL_VNC_PORT_MAX - LIBXL_VNC_PORT_MIN)) == NULL)
         goto out_of_memory;
 
     if (virDomainObjListInit(&libxl_driver->domains) < 0)
index 43645bf9c31d236b6ea81bf8ae2331ebf21f4ade..7742db50f6cc41e2eb989781682435e7de62e885 100644 (file)
@@ -1718,7 +1718,7 @@ qemuCapsNew(void)
     if (!(caps = virObjectNew(qemuCapsClass)))
         return NULL;
 
-    if (!(caps->flags = virBitmapAlloc(QEMU_CAPS_LAST)))
+    if (!(caps->flags = virBitmapNew(QEMU_CAPS_LAST)))
         goto no_memory;
 
     return caps;
index 981e6d46caf2d7fb45fbed755836e824c6993948..0f7ae10c77ce7fbb8d8500dc86b4d2c3e20a413d 100644 (file)
@@ -696,7 +696,7 @@ qemudStartup(int privileged) {
      * do this before the config is loaded properly, since the port
      * numbers are configurable now */
     if ((qemu_driver->reservedRemotePorts =
-         virBitmapAlloc(qemu_driver->remotePortMax - qemu_driver->remotePortMin)) == NULL)
+         virBitmapNew(qemu_driver->remotePortMax - qemu_driver->remotePortMin)) == NULL)
         goto out_of_memory;
 
     /* We should always at least have the 'nop' manager, so
index cd52802facc290e2bdd908e9d2314b057e375690..dc9c28ad29724db961674462de721db2a6556fdd 100644 (file)
@@ -36,7 +36,8 @@
 
 
 struct _virBitmap {
-    size_t size;
+    size_t max_bit;
+    size_t map_len;
     unsigned long *map;
 };
 
@@ -48,7 +49,7 @@ struct _virBitmap {
 
 
 /**
- * virBitmapAlloc:
+ * virBitmapNew:
  * @size: number of bits
  *
  * Allocate a bitmap capable of containing @size bits.
@@ -56,7 +57,7 @@ struct _virBitmap {
  * Returns a pointer to the allocated bitmap or NULL if
  * memory cannot be allocated.
  */
-virBitmapPtr virBitmapAlloc(size_t size)
+virBitmapPtr virBitmapNew(size_t size)
 {
     virBitmapPtr bitmap;
     size_t sz;
@@ -75,7 +76,8 @@ virBitmapPtr virBitmapAlloc(size_t size)
         return NULL;
     }
 
-    bitmap->size = size;
+    bitmap->max_bit = size;
+    bitmap->map_len = sz;
     return bitmap;
 }
 
@@ -83,7 +85,7 @@ virBitmapPtr virBitmapAlloc(size_t size)
  * virBitmapFree:
  * @bitmap: previously allocated bitmap
  *
- * Free @bitmap previously allocated by virBitmapAlloc.
+ * Free @bitmap previously allocated by virBitmapNew.
  */
 void virBitmapFree(virBitmapPtr bitmap)
 {
@@ -96,17 +98,12 @@ void virBitmapFree(virBitmapPtr bitmap)
 
 int virBitmapCopy(virBitmapPtr dst, virBitmapPtr src)
 {
-    size_t sz;
-
-    if (dst->size != src->size) {
+    if (dst->max_bit != src->max_bit) {
         errno = EINVAL;
         return -1;
     }
 
-    sz = (src->size + VIR_BITMAP_BITS_PER_UNIT - 1) /
-        VIR_BITMAP_BITS_PER_UNIT;
-
-    memcpy(dst->map, src->map, sz * sizeof(src->map[0]));
+    memcpy(dst->map, src->map, src->map_len * sizeof(src->map[0]));
 
     return 0;
 }
@@ -123,7 +120,7 @@ int virBitmapCopy(virBitmapPtr dst, virBitmapPtr src)
  */
 int virBitmapSetBit(virBitmapPtr bitmap, size_t b)
 {
-    if (bitmap->size <= b)
+    if (bitmap->max_bit <= b)
         return -1;
 
     bitmap->map[VIR_BITMAP_UNIT_OFFSET(b)] |= VIR_BITMAP_BIT(b);
@@ -141,7 +138,7 @@ int virBitmapSetBit(virBitmapPtr bitmap, size_t b)
  */
 int virBitmapClearBit(virBitmapPtr bitmap, size_t b)
 {
-    if (bitmap->size <= b)
+    if (bitmap->max_bit <= b)
         return -1;
 
     bitmap->map[VIR_BITMAP_UNIT_OFFSET(b)] &= ~VIR_BITMAP_BIT(b);
@@ -161,7 +158,7 @@ int virBitmapClearBit(virBitmapPtr bitmap, size_t b)
  */
 int virBitmapGetBit(virBitmapPtr bitmap, size_t b, bool *result)
 {
-    if (bitmap->size <= b)
+    if (bitmap->max_bit <= b)
         return -1;
 
     *result = !!(bitmap->map[VIR_BITMAP_UNIT_OFFSET(b)] & VIR_BITMAP_BIT(b));
@@ -183,8 +180,7 @@ char *virBitmapString(virBitmapPtr bitmap)
 
     virBufferAddLit(&buf, "0x");
 
-    sz = (bitmap->size + VIR_BITMAP_BITS_PER_UNIT - 1) /
-          VIR_BITMAP_BITS_PER_UNIT;
+    sz = bitmap->map_len;
 
     while (sz--) {
         virBufferAsprintf(&buf, "%0*lx",
index 1d8750e8b094bd468bc552670c9f940254e8b681..2609509e8ad725c68eef776178b78868d35ec70d 100644 (file)
@@ -34,7 +34,7 @@ typedef virBitmap *virBitmapPtr;
 /*
  * Allocate a bitmap capable of containing @size bits.
  */
-virBitmapPtr virBitmapAlloc(size_t size) ATTRIBUTE_RETURN_CHECK;
+virBitmapPtr virBitmapNew(size_t size) ATTRIBUTE_RETURN_CHECK;
 
 /*
  * Free previously allocated bitmap
index 887a1560d672d8b093a0ffad0aebb92a7d5ebd17..b6de9a81bbe625292903f695d1295193a6d8102a 100644 (file)
@@ -7178,7 +7178,7 @@ vshNodeIsSuperset(xmlNodePtr n1, xmlNodePtr n2)
     if (n1_child_size == 0 && n2_child_size == 0)
         return true;
 
-    if (!(bitmap = virBitmapAlloc(n1_child_size))) {
+    if (!(bitmap = virBitmapNew(n1_child_size))) {
         virReportOOMError();
         return false;
     }