[PATCH 0 of 2] #2 Fix (again) VSMCaps and ElementCaps

There was a lot of cruft in both VSMCaps and ElementCaps around generating a dynamic InstanceID with the HostSystem.Name in it that is really not necessary. This set just changes to a static InstanceID for VSMCaps and removes all the supporting code that it obviates. Changes: - Just a rebase on tip

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196465209 28800 # Node ID 41b88691861933c0fa5b0ead6f27bd1b9730985d # Parent 075b7c91e9729f9705af3a2f4726e6883be29b59 Make VirtualSystemManagementCapabilities not use a devid-style InstanceID This changes to a static InstanceID (since this is a singleton) and remove all the sys_name plumbing. Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 075b7c91e972 -r 41b886918619 src/Virt_VirtualSystemManagementCapabilities.c --- a/src/Virt_VirtualSystemManagementCapabilities.c Fri Nov 30 14:16:17 2007 -0800 +++ b/src/Virt_VirtualSystemManagementCapabilities.c Fri Nov 30 15:26:49 2007 -0800 @@ -30,7 +30,6 @@ #include "std_instance.h" #include "misc_util.h" -#include "device_parsing.h" #include "Virt_VirtualSystemManagementCapabilities.h" #include "Virt_HostSystem.h" @@ -48,25 +47,17 @@ enum {ADD_RESOURCES = 1, static CMPIStatus set_inst_properties(const CMPIBroker *broker, CMPIInstance *inst, - const char *classname, - const char *sys_name) + const char *classname) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIArray *array; uint16_t element; - char *devid; - + CMSetProperty(inst, "CreationClassName", (CMPIValue *)classname, CMPI_chars); - devid = get_fq_devid((char *)sys_name, "0"); - if (devid == NULL) { - cu_statusf(broker, &s, - CMPI_RC_ERR_FAILED, - "Could not get full ID"); - goto out; - } - CMSetProperty(inst, "InstanceID", (CMPIValue *)devid, CMPI_chars); + CMSetProperty(inst, "InstanceID", + (CMPIValue *)"ManagementCapabilities", CMPI_chars); array = CMNewArray(broker, 4, CMPI_uint16, &s); if ((s.rc != CMPI_RC_OK) || CMIsNullObject(array)) @@ -92,7 +83,6 @@ static CMPIStatus set_inst_properties(co CMPIStatus get_vsm_cap(const CMPIBroker *broker, const CMPIObjectPath *ref, - const char* sys_name, CMPIInstance **inst) { CMPIStatus s; @@ -124,7 +114,7 @@ CMPIStatus get_vsm_cap(const CMPIBroker goto out; } - s = set_inst_properties(broker, *inst, classname, sys_name); + s = set_inst_properties(broker, *inst, classname); out: free(classname); @@ -138,16 +128,8 @@ static CMPIStatus return_vsm_cap(const C { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; - const char *hostname = NULL; - s = get_host_cs(_BROKER, ref, &inst); - if (s.rc != CMPI_RC_OK) - goto out; - - if (cu_get_str_prop(inst, "Name", &hostname) != CMPI_RC_OK) - goto out; - - s = get_vsm_cap(_BROKER, ref, hostname, &inst); + s = get_vsm_cap(_BROKER, ref, &inst); if (s.rc != CMPI_RC_OK) goto out; diff -r 075b7c91e972 -r 41b886918619 src/Virt_VirtualSystemManagementCapabilities.h --- a/src/Virt_VirtualSystemManagementCapabilities.h Fri Nov 30 14:16:17 2007 -0800 +++ b/src/Virt_VirtualSystemManagementCapabilities.h Fri Nov 30 15:26:49 2007 -0800 @@ -20,7 +20,6 @@ */ CMPIStatus get_vsm_cap(const CMPIBroker *broker, const CMPIObjectPath *ref, - const char* sys_name, CMPIInstance **inst); /* * Local Variables:

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196465546 28800 # Node ID e6be7823c8e90c1f4b722ce1b33d6d15db123029 # Parent 41b88691861933c0fa5b0ead6f27bd1b9730985d Make ElementCapabilities not assume a devid-style InstanceID For the cap_to_sys case, grab the host_cs and use cu_compare_ref() instead of inspecting the InstanceID directly. Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 41b886918619 -r e6be7823c8e9 src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Fri Nov 30 15:26:49 2007 -0800 +++ b/src/Virt_ElementCapabilities.c Fri Nov 30 15:32:26 2007 -0800 @@ -52,34 +52,22 @@ static CMPIStatus sys_to_cap(const CMPIO struct inst_list *list) { CMPIInstance *inst; - CMPIrc host_rc; - const char *host_name = NULL; - const char *sys_name = NULL; - CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIStatus s = {CMPI_RC_OK, NULL}; + const char *prop; s = get_host_cs(_BROKER, ref, &inst); if (s.rc != CMPI_RC_OK) goto out; - host_rc = cu_get_str_prop(inst, "Name", &host_name); - if (host_rc != CMPI_RC_OK) - goto out; - - if (cu_get_str_path(ref, "Name", &sys_name) != CMPI_RC_OK) { + prop = cu_compare_ref(ref, inst); + if (prop != NULL) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, - "Missing `Name' property"); - goto out; - } - - if (!STREQ(sys_name, host_name)) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "System '%s' is not a host system", sys_name); - goto out; - } - - s = get_vsm_cap(_BROKER, ref, sys_name, &inst); + "No such HostSystem (%s)", prop); + goto out; + } + + s = get_vsm_cap(_BROKER, ref, &inst); if (s.rc == CMPI_RC_OK) inst_list_add(list, inst); out: @@ -90,44 +78,16 @@ static CMPIStatus cap_to_sys(const CMPIO struct std_assoc_info *info, struct inst_list *list) { - const char *inst_id; - char *host; - char *device; - const char *host_name; - CMPIrc host_rc; - CMPIInstance *inst; - CMPIStatus s = {CMPI_RC_OK, NULL}; - - if (cu_get_str_path(ref, "InstanceID", &inst_id) != CMPI_RC_OK) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Could not get InstanceID"); - goto out; - } - - if (!parse_fq_devid(inst_id, &host, &device)) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Could not get system name"); - goto out; - } + CMPIInstance *inst; + CMPIStatus s = {CMPI_RC_OK, NULL}; s = get_host_cs(_BROKER, ref, &inst); if (s.rc != CMPI_RC_OK) goto out; - host_rc = cu_get_str_prop(inst, "Name", &host_name); - if (host_rc != CMPI_RC_OK) - goto out; - - if (!STREQ(host_name, host)) - goto out; - inst_list_add(list, inst); out: - free(host); - free(device); return s; }

Dan Smith wrote:
There was a lot of cruft in both VSMCaps and ElementCaps around generating a dynamic InstanceID with the HostSystem.Name in it that is really not necessary.
This set just changes to a static InstanceID for VSMCaps and removes all the supporting code that it obviates.
Changes: - Just a rebase on tip
Excellent - this one applied for me. +1 -- Kaitlin Rupert IBM Linux Technology Center karupert@us.ibm.com

Kaitlin Rupert wrote:
Dan Smith wrote:
There was a lot of cruft in both VSMCaps and ElementCaps around generating a dynamic InstanceID with the HostSystem.Name in it that is really not necessary.
This set just changes to a static InstanceID for VSMCaps and removes all the supporting code that it obviates.
Changes: - Just a rebase on tip
Excellent - this one applied for me. +1
works for me too. +1 -- Regards Heidi Eckhart Software Engineer Linux Technology Center - Open Hypervisor heidieck@linux.vnet.ibm.com ************************************************** IBM Deutschland Entwicklung GmbH Vorsitzender des Aufsichtsrats: Martin Jetter Geschaeftsfuehrung: Herbert Kircher Sitz der Gesellschaft: Boeblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
participants (3)
-
Dan Smith
-
Heidi Eckhart
-
Kaitlin Rupert