
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1196199118 28800 # Node ID 651039e9392c60f96b6cbaa63f0a239df5357550 # Parent 140613919317633ad4b325b6321809849ecfbd41 Fix an issue where EnabledLogicalElementCapabilities ein/ei returns an error. Enumerating this class currently returns: "Missing key: Name". The problem is that get_ele_cap() expects the ref to have a Name property, which isn't the case on an ein/ei call. This fix makes the get_ele_cap() call more generic by accepting a char * to use in building the InstanceID. Also, the return_ele_cap() function wasn't properly returning an instance for each domain on the system. This fix grabs the domain list and returns an instance accordingly. NOTE: I don't like how I handled the virDomainFree() - not sure how else to do this except for changing goto end to goto out and then looping through the list to free. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 140613919317 -r 651039e9392c src/Virt_EnabledLogicalElementCapabilities.c --- a/src/Virt_EnabledLogicalElementCapabilities.c Wed Nov 21 08:23:33 2007 -0800 +++ b/src/Virt_EnabledLogicalElementCapabilities.c Tue Nov 27 13:31:58 2007 -0800 @@ -31,6 +31,7 @@ #include "misc_util.h" #include "device_parsing.h" +#include "cs_util.h" #include "Virt_EnabledLogicalElementCapabilities.h" @@ -103,20 +104,12 @@ static CMPIStatus set_inst_properties(co CMPIStatus get_ele_cap(const CMPIBroker *broker, const CMPIObjectPath *ref, + const char *sys_name, CMPIInstance **inst) { CMPIStatus s; CMPIObjectPath *op; char *classname = NULL; - char *sys_name = NULL; - - sys_name = cu_get_str_path(ref, "Name"); - if (sys_name == NULL) { - CMSetStatusWithChars(broker, &s, - CMPI_RC_ERR_FAILED, - "Missing key: Name"); - goto out; - } classname = get_typed_class(CLASSNAME(ref), "EnabledLogicalElementCapabilities"); @@ -147,7 +140,6 @@ CMPIStatus get_ele_cap(const CMPIBroker out: free(classname); - free(sys_name); return s; } @@ -158,16 +150,50 @@ static CMPIStatus return_ele_cap(const C { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; - - s = get_ele_cap(_BROKER, ref, &inst); - if (s.rc != CMPI_RC_OK) - goto out; - - if (names_only) - cu_return_instance_name(results, inst); - else - CMReturnInstance(results, inst); + virConnectPtr conn = NULL; + virDomainPtr *list = NULL; + int count; + int i; + const char *name; + + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); + if (conn == NULL) + goto out; + + count = get_domain_list(conn, &list); + if (count <= 0) + goto out; + + for (i = 0; i < count; i++) { + name = virDomainGetName(list[i]); + if (name == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to get domain names"); + goto end; + } + + s = get_ele_cap(_BROKER, ref, name, &inst); + if (s.rc != CMPI_RC_OK) + goto end; + + if (names_only) + cu_return_instance_name(results, inst); + else + CMReturnInstance(results, inst); + + end: + virDomainFree(list[i]); + + if (s.rc != CMPI_RC_OK) + goto out; + } + out: + free(list); + + virConnectClose(conn); + return s; } diff -r 140613919317 -r 651039e9392c src/Virt_EnabledLogicalElementCapabilities.h --- a/src/Virt_EnabledLogicalElementCapabilities.h Wed Nov 21 08:23:33 2007 -0800 +++ b/src/Virt_EnabledLogicalElementCapabilities.h Tue Nov 27 13:31:58 2007 -0800 @@ -20,6 +20,7 @@ */ CMPIStatus get_ele_cap(const CMPIBroker *broker, const CMPIObjectPath *ref, + const char *sys_name, CMPIInstance **inst); /* * Local Variables: