[Libvirt-cim] Patch(es) for Virt_SettingsDefineCapabilities: incorrect Default ValueRole, strstr() misuse

Gareth S Bestor bestor at us.ibm.com
Mon Jul 18 18:39:44 UTC 2011


Please find below a patch to Virt_SettingsDefineCapabilities.c to fix a 
couple issues I found:

- The CIM_AllocationCapabilities for 'Default' RASDs have the incorrect 
ValueRole. per DSP1043 "Allocation Capabilities Profile", Section 10.5 
"CIM_SettingsDefineCapabilities – Default" the ValueRole should be 0 
("Default")

- Fixed mistake with usage of strstr() swapping the arguments; should be:
        char *strstr(const char *haystack, const char *needle);
 This may not have mattered before when both strings were always exactly 
same or didnt match, but now for new 'Point' instances the instanceid has 
a prefix. [Thnx Sharad for catching this]

Please excuse the fact the patch is not in the correct format - I am still 
setting up my mercurial to correctly format and post patches, thnx.


# User Dr. Gareth S. Bestor <bestor at us.ibm.com>
#
diff -r 395f2d684c10 src/Virt_SettingsDefineCapabilities.c
--- a/src/Virt_SettingsDefineCapabilities.c     Tue Jul 05 15:52:31 2011 
-0300
+++ b/src/Virt_SettingsDefineCapabilities.c     Mon Jul 18 04:11:35 2011 
-0700
@@ -2054,20 +2188,21 @@
                 goto out;
         }

-        if (strstr("Default", iid) != NULL)
+        if (strstr(iid, "Default") != NULL) {
                 valuerange = SDC_RANGE_POINT;
-        else if (strstr("Increment", iid) != NULL)
+                valuerole = SDC_ROLE_DEFAULT;
+        }
+        else if (strstr(iid, "Point") != NULL)
+                valuerange = SDC_RANGE_POINT;
+        else if (strstr(iid, "Increment") != NULL)
                 valuerange = SDC_RANGE_INC;
-        else if (strstr("Maximum", iid) != NULL)
+        else if (strstr(iid, "Maximum") != NULL)
                 valuerange = SDC_RANGE_MAX;
-        else if (strstr("Minimum", iid) != NULL)
+        else if (strstr(iid, "Minimum") != NULL)
                 valuerange = SDC_RANGE_MIN;
         else
                 CU_DEBUG("Unknown default RASD type: `%s'", iid);

-        if (valuerange == SDC_RANGE_POINT)
-                valuerole = SDC_ROLE_DEFAULT;
-
         CMSetProperty(ref_inst, "ValueRole",
                       (CMPIValue *)&valuerole, CMPI_uint16);
         CMSetProperty(ref_inst, "ValueRange",



Dr. Gareth S. Bestor
IBM Senior Software Engineer
Systems & Technology Group - Systems Management Standards
971-285-6375 (mobile)
bestor at us.ibm.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvirt-cim/attachments/20110718/586805c2/attachment.htm>


More information about the Libvirt-cim mailing list