[Libvirt-cim] [PATCH] bug fix: KVM_MemResourceAllocationSettingData does not conform to profile

Wayne Xia xiawenc at linux.vnet.ibm.com
Thu Jul 21 07:32:52 UTC 2011


# HG changeset patch
# User Wayne Xia <xiawenc at linux.vnet.ibm.com>
# Date 1311231387 -28800
# Node ID 677867c3d2a16a97591bde2828808f9f39b859a7
# Parent  3c90a88a5199a4ed931a4a76097cff8f55deae41
changed a bit to make it conform to CIM profile

According to the discuss and profile, the reserved property means the
memory actually allocated to support the VM running, and the unit
should be byte*2^10. This patch added some code to retrieve VM's state,
and the report the memory status according to that.
https://bugzilla.linux.ibm.com/show_bug.cgi?id=72759

Signed-off-by: Wayne Xia <xiawenc at linux.vnet.ibm.com>

diff -r 3c90a88a5199 -r 677867c3d2a1 libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c	Mon Jul 18 11:13:40 2011 -0300
+++ b/libxkutil/device_parsing.c	Thu Jul 21 14:56:27 2011 +0800
@@ -792,6 +792,7 @@
          } else if (dev->type == CIM_RES_TYPE_MEM) {
                  dev->dev.mem.size = _dev->dev.mem.size;
                  dev->dev.mem.maxsize = _dev->dev.mem.maxsize;
+                dev->dev.mem.reserved = _dev->dev.mem.reserved;
          } else if (dev->type == CIM_RES_TYPE_PROC) {
                  dev->dev.vcpu.quantity = _dev->dev.vcpu.quantity;
          } else if (dev->type == CIM_RES_TYPE_EMU) {
@@ -885,8 +886,22 @@
          if (xml == NULL)
                  return 0;

-        if (type == CIM_RES_TYPE_MEM)
+        if (type == CIM_RES_TYPE_MEM) {
                  ret = _get_mem_device(xml, list);
+                if (*list != NULL) {
+                    virDomainInfo dom_info;
+                    if (virDomainGetInfo(dom, &dom_info) == 0) {
+                        (*list)->dev.mem.reserved = dom_info.memory;
+                        if (dom_info.state == 5) { /* VM not active */
+                            (*list)->dev.mem.reserved = 0;
+                        }
+                    }
+                    else {
+                        CU_DEBUG("failed to get dom state for mem");
+                        ret = -1;
+                    }
+                }
+        }
          else if (type == CIM_RES_TYPE_PROC)
                  ret = _get_proc_device(xml, list);
          else
diff -r 3c90a88a5199 -r 677867c3d2a1 libxkutil/device_parsing.h
--- a/libxkutil/device_parsing.h	Mon Jul 18 11:13:40 2011 -0300
+++ b/libxkutil/device_parsing.h	Thu Jul 21 14:56:27 2011 +0800
@@ -71,6 +71,7 @@
  struct mem_device {
          uint64_t size;
          uint64_t maxsize;
+        uint64_t reserved;
  };

  struct vcpu_device {
diff -r 3c90a88a5199 -r 677867c3d2a1 src/Virt_RASD.c
--- a/src/Virt_RASD.c	Mon Jul 18 11:13:40 2011 -0300
+++ b/src/Virt_RASD.c	Thu Jul 21 14:56:27 2011 +0800
@@ -576,14 +576,14 @@
                                                      inst);

          } else if (dev->type == CIM_RES_TYPE_MEM) {
-                const char *units = "KiloBytes";
+                const char *units = "byte*2^10";

                  CMSetProperty(inst, "AllocationUnits",
                                (CMPIValue *)units, CMPI_chars);
                  CMSetProperty(inst, "VirtualQuantity",
                                (CMPIValue *)&dev->dev.mem.size, 
CMPI_uint64);
                  CMSetProperty(inst, "Reservation",
-                              (CMPIValue *)&dev->dev.mem.size, 
CMPI_uint64);
+                              (CMPIValue *)&dev->dev.mem.reserved, 
CMPI_uint64);
                  CMSetProperty(inst, "Limit",
                                (CMPIValue *)&dev->dev.mem.maxsize, 
CMPI_uint64);
          } else if (dev->type == CIM_RES_TYPE_PROC) {




More information about the Libvirt-cim mailing list