[PATCH] Fix enum_domains() to generate a correct ObjectPath for returned Instances

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1194024510 25200 # Node ID d48584b1c90c499dea3940c1718ef0e97ae5ef9e # Parent 854d848bae0b56420e483ac7522775b6b3080aaa Fix enum_domains() to generate a correct ObjectPath for returned Instances This fixes the fact that HostedDependency is returning ComputerSystem instances with the wrong class name. - Modified enum_domains() to take a namespace instead of an object path and actually create the correct OP for the instances - Removed an unnecessary parameter from instance_from_dom() Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 854d848bae0b -r d48584b1c90c src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Fri Nov 02 07:03:04 2007 -0700 +++ b/src/Virt_ComputerSystem.c Fri Nov 02 10:28:30 2007 -0700 @@ -239,8 +239,7 @@ static int set_creation_class(CMPIInstan /* Populate an instance with information from a domain */ static int instance_from_dom(const CMPIBroker *broker, virDomainPtr dom, - CMPIInstance *instance, - const CMPIObjectPath *reference) + CMPIInstance *instance) { if (!set_name_from_dom(dom, instance)) { /* Print trace error */ @@ -291,7 +290,7 @@ CMPIInstance *instance_from_name(const C if (instance == NULL) goto out; - if (!instance_from_dom(broker, dom, instance, op)) + if (!instance_from_dom(broker, dom, instance)) instance = NULL; out: @@ -303,7 +302,7 @@ CMPIInstance *instance_from_name(const C /* Enumerate domains on the given connection, return results */ int enum_domains(const CMPIBroker *broker, virConnectPtr conn, - const CMPIObjectPath *op, + const char *ns, struct inst_list *instlist) { virDomainPtr *list = NULL; @@ -315,14 +314,13 @@ int enum_domains(const CMPIBroker *broke goto out; for (i = 0; i < count; i++) { - CMPIStatus s; CMPIInstance *inst; - inst = CMNewInstance(broker, op, &s); - if ((s.rc != CMPI_RC_OK) || (CMIsNullObject(inst))) + inst = get_typed_instance(broker, "ComputerSystem", ns); + if (inst == NULL) goto end; - if (instance_from_dom(broker, list[i], inst, op)) + if (instance_from_dom(broker, list[i], inst)) inst_list_add(instlist, inst); end: @@ -351,7 +349,7 @@ static CMPIStatus return_enum_domains(co return s; inst_list_init(&list); - ret = enum_domains(_BROKER, conn, reference, &list); + ret = enum_domains(_BROKER, conn, NAMESPACE(reference), &list); if (!ret) { CMSetStatus(&s, CMPI_RC_ERR_FAILED); goto out; diff -r 854d848bae0b -r d48584b1c90c src/Virt_ComputerSystem.h --- a/src/Virt_ComputerSystem.h Fri Nov 02 07:03:04 2007 -0700 +++ b/src/Virt_ComputerSystem.h Fri Nov 02 10:28:30 2007 -0700 @@ -49,7 +49,7 @@ CMPIInstance *instance_from_name(const C */ int enum_domains(const CMPIBroker *broker, virConnectPtr conn, - const CMPIObjectPath *op, + const char *ns, struct inst_list *instlist); diff -r 854d848bae0b -r d48584b1c90c src/Virt_HostedDependency.c --- a/src/Virt_HostedDependency.c Fri Nov 02 07:03:04 2007 -0700 +++ b/src/Virt_HostedDependency.c Fri Nov 02 10:28:30 2007 -0700 @@ -62,7 +62,7 @@ static CMPIStatus host_to_vs(const CMPIO if (conn == NULL) return s; - ret = enum_domains(_BROKER, conn, ref, list); + ret = enum_domains(_BROKER, conn, NAMESPACE(ref), list); if (ret) { CMSetStatus(&s, CMPI_RC_OK); } else {

Dan Smith wrote:
# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1194024510 25200 # Node ID d48584b1c90c499dea3940c1718ef0e97ae5ef9e # Parent 854d848bae0b56420e483ac7522775b6b3080aaa Fix enum_domains() to generate a correct ObjectPath for returned Instances
This fixes the fact that HostedDependency is returning ComputerSystem instances with the wrong class name.
- Modified enum_domains() to take a namespace instead of an object path and actually create the correct OP for the instances - Removed an unnecessary parameter from instance_from_dom()
Nice fix - HostedDependency now returns a correctly formatted Xen_ComputerSystem instance on my system. And good catch on the extra param for instance_from_dom(). +1 -- Kaitlin Rupert IBM Linux Technology Center karupert@us.ibm.com
participants (2)
-
Dan Smith
-
Kaitlin Rupert