[PATCH] Fix units adherence in MemoryRASD processing in DefineSystem()

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1216828041 25200 # Node ID f542e90d4c672efa40a907b8c7040d6df714bd38 # Parent 8d236493f5d67a952bfab94a3fc19a34b3fdf394 Fix units adherence in MemoryRASD processing in DefineSystem() Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 8d236493f5d6 -r f542e90d4c67 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Wed Jul 23 08:15:14 2008 -0700 +++ b/src/Virt_VirtualSystemManagementService.c Wed Jul 23 08:47:21 2008 -0700 @@ -469,12 +469,37 @@ static const char *mem_rasd_to_vdev(CMPIInstance *inst, struct virt_device *dev) { + const char *units; + int shift; + cu_get_u64_prop(inst, "VirtualQuantity", &dev->dev.mem.size); cu_get_u64_prop(inst, "Reservation", &dev->dev.mem.size); dev->dev.mem.maxsize = dev->dev.mem.size; cu_get_u64_prop(inst, "Limit", &dev->dev.mem.maxsize); - dev->dev.mem.size <<= 10; - dev->dev.mem.maxsize <<= 10; + + if (cu_get_str_prop(inst, "AllocationUnits", &units) != CMPI_RC_OK) { + CU_DEBUG("Memory RASD has no units, assuming bytes"); + units = "Bytes"; + } + + if (STREQC(units, "Bytes")) + shift = -10; + else if (STREQC(units, "KiloBytes")) + shift = 0; + else if (STREQC(units, "MegaBytes")) + shift = 10; + else if (STREQC(units, "GigaBytes")) + shift = 20; + else + return "Unknown AllocationUnits in Memory RASD"; + + if (shift < 0) { + dev->dev.mem.size >>= -shift; + dev->dev.mem.maxsize >>= -shift; + } else { + dev->dev.mem.size <<= shift; + dev->dev.mem.maxsize <<= shift; + } return NULL; }

Dan Smith wrote:
# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1216828041 25200 # Node ID f542e90d4c672efa40a907b8c7040d6df714bd38 # Parent 8d236493f5d67a952bfab94a3fc19a34b3fdf394 Fix units adherence in MemoryRASD processing in DefineSystem()
Signed-off-by: Dan Smith <danms@us.ibm.com>
diff -r 8d236493f5d6 -r f542e90d4c67 src/Virt_VirtualSystemManagementService.c
+1 -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (2)
-
Dan Smith
-
Kaitlin Rupert