[PATCH] (#2) Add Enumeration support to RASD

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1203373962 28800 # Node ID c118dc77598088e3bd866df48787e5999aeb9d10 # Parent 7b5611c03994d1568ba69560f5afad284df06bd0 (#2) Add Enumeration support to RASD Supports enumerating a specific RASD type, as well as the parent classes KVM_RASD, Xen_RASD, as well as CIM_RASD. Changes: - Remove printf() in place of a CU_DEBUG() (before Kaitlin got a chance to complain, I'll have you know) Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 7b5611c03994 -r c118dc775980 src/Virt_RASD.c --- a/src/Virt_RASD.c Fri Feb 15 13:35:31 2008 -0800 +++ b/src/Virt_RASD.c Mon Feb 18 14:32:42 2008 -0800 @@ -34,6 +34,7 @@ #include "device_parsing.h" #include "misc_util.h" +#include "cs_util.h" #include "Virt_RASD.h" #include "svpc_types.h" @@ -442,6 +443,100 @@ CMPIrc rasd_classname_from_type(uint16_t return rc; } +static CMPIStatus _enum_rasds(const CMPIObjectPath *ref, + struct inst_list *list) +{ + virConnectPtr conn = NULL; + virDomainPtr *domains = NULL; + int count; + int i, j; + uint16_t type; + CMPIStatus s; + uint16_t types[] = {CIM_RASD_TYPE_PROC, + CIM_RASD_TYPE_DISK, + CIM_RASD_TYPE_NET, + CIM_RASD_TYPE_MEM, + 0}; + + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); + if (conn == NULL) + return s; + + count = get_domain_list(conn, &domains); + if (count <= 0) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to get domain list"); + goto out; + } + + if (rasd_type_from_classname(CLASSNAME(ref), &type) == CMPI_RC_OK) { + types[0] = type; + types[1] = 0; + } + + for (i = 0; i < count; i++) { + for (j = 0; types[j] != 0; j++) { + CU_DEBUG(("Doing RASD type %i for %s", + type, virDomainGetName(domains[i])); + rasds_for_domain(_BROKER, + virDomainGetName(domains[i]), + types[j], + ref, + list); + } + virDomainFree(domains[i]); + } + + s = (CMPIStatus){CMPI_RC_OK, NULL}; + + out: + virConnectClose(conn); + free(domains); + + return s; +} + +static CMPIStatus return_enum_rasds(const CMPIObjectPath *ref, + const CMPIResult *results, + const bool names_only) +{ + struct inst_list list; + CMPIStatus s; + + inst_list_init(&list); + + s = _enum_rasds(ref, &list); + if (s.rc == CMPI_RC_OK) { + if (names_only) + cu_return_instance_names(results, &list); + else + cu_return_instances(results, &list); + } + + inst_list_free(&list); + + return s; +} + +static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference) +{ + return return_enum_rasds(reference, results, true); +} + +static CMPIStatus EnumInstances(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *reference, + const char **properties) +{ + + return return_enum_rasds(reference, results, false); +} + static CMPIStatus GetInstance(CMPIInstanceMI *self, const CMPIContext *context, const CMPIResult *results, @@ -516,8 +611,6 @@ DEFAULT_CI(); DEFAULT_CI(); DEFAULT_MI(); DEFAULT_DI(); -DEFAULT_EI(); -DEFAULT_EIN(); DEFAULT_INST_CLEANUP(); DEFAULT_EQ();

Dan Smith wrote:
# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1203373962 28800 # Node ID c118dc77598088e3bd866df48787e5999aeb9d10 # Parent 7b5611c03994d1568ba69560f5afad284df06bd0 (#2) Add Enumeration support to RASD
Supports enumerating a specific RASD type, as well as the parent classes KVM_RASD, Xen_RASD, as well as CIM_RASD.
Changes: - Remove printf() in place of a CU_DEBUG() (before Kaitlin got a chance to complain, I'll have you know)
+ + if (rasd_type_from_classname(CLASSNAME(ref), &type) == CMPI_RC_OK) { + types[0] = type; + types[1] = 0; + } + + for (i = 0; i < count; i++) { + for (j = 0; types[j] != 0; j++) { + CU_DEBUG(("Doing RASD type %i for %s",
I had troubles compiling with this patch applied - you have an extra open paren here. Also, I was unable to query the CIM_ superclass: wbemcli ein http://localhost/root/virt:CIM_ResourceAllocationSettingData Since the classname is not specify, we're unable to get a domain list from the connection. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

KR> I had troubles compiling with this patch applied - you have an KR> extra open paren here. Ah, well, I was trying to beat you to the punch. Oh well :) KR> Also, I was unable to query the CIM_ superclass: KR> wbemcli ein http://localhost/root/virt:CIM_ResourceAllocationSettingData KR> Since the classname is not specify, we're unable to get a domain list KR> from the connection. Hmm, it worked just fine for me because Pegasus translates that into a call of each type. Was this on SFCB perhaps? -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Dan Smith wrote:
KR> I had troubles compiling with this patch applied - you have an KR> extra open paren here.
Ah, well, I was trying to beat you to the punch. Oh well :)
KR> Also, I was unable to query the CIM_ superclass:
KR> wbemcli ein http://localhost/root/virt:CIM_ResourceAllocationSettingData
KR> Since the classname is not specify, we're unable to get a domain list KR> from the connection.
Hmm, it worked just fine for me because Pegasus translates that into a call of each type. Was this on SFCB perhaps?
Hmm.. interesting. No, this was with Pegasus. Here's error - I don't see anything strange in the CU_DEBUG output. [kaitlin@elm3b41 libvirt-cim]$ wbemcli ein http://localhost/root/virt:CIM_ResourceAllocationSettingData * * wbemcli: Cim: (1) CIM_ERR_FAILED: A general error occurred that is not covered by a more specific error code: "Unable to get domain list" I see the following with ei: [kaitlin@elm3b41 libvirt-cim]$ wbemcli ei http://localhost/root/virt:CIM_ResourceAllocationSettingData * * wbemcli: Cim: (2) CIM_ERR_ACCESS_DENIED: Access to a CIM resource was not available to the client: "Recursive Use of CIMOMHandle Attempted" -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Kaitlin Rupert wrote:
Dan Smith wrote:
KR> I had troubles compiling with this patch applied - you have an KR> extra open paren here.
Ah, well, I was trying to beat you to the punch. Oh well :)
KR> Also, I was unable to query the CIM_ superclass:
KR> wbemcli ein http://localhost/root/virt:CIM_ResourceAllocationSettingData
KR> Since the classname is not specify, we're unable to get a domain list KR> from the connection.
Hmm, it worked just fine for me because Pegasus translates that into a call of each type. Was this on SFCB perhaps? For class providers sfcb is acting like Pegasus. It translates the CIM_RASD call into a separate provider request for each subclass.
Hmm.. interesting. No, this was with Pegasus. Here's error - I don't see anything strange in the CU_DEBUG output.
[kaitlin@elm3b41 libvirt-cim]$ wbemcli ein http://localhost/root/virt:CIM_ResourceAllocationSettingData * * wbemcli: Cim: (1) CIM_ERR_FAILED: A general error occurred that is not covered by a more specific error code: "Unable to get domain list"
I see the following with ei:
[kaitlin@elm3b41 libvirt-cim]$ wbemcli ei http://localhost/root/virt:CIM_ResourceAllocationSettingData * * wbemcli: Cim: (2) CIM_ERR_ACCESS_DENIED: Access to a CIM resource was not available to the client: "Recursive Use of CIMOMHandle Attempted"
Besides that tiny compilation issue I had no trouble with the provider - neither with sfcb nor with Pegasus. And by reviewing the code I have no idea, where this behavior could come from. For me everything looks fine. What is really strange is, that for nearly the same call two different functions are returning errors: - for the first one (ein) the provider is returning the error - for the second one (ei) the CIMOM is returning the error ... and that error looks like Pegasus is having trouble with calling the same provider for different subclasses Please can you reinstall, restart Pegasus and try again ? What happens ? -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor
participants (3)
-
Dan Smith
-
Heidi Eckhart
-
Kaitlin Rupert