[PATCH] Enumeration on VirtualSystemManagementService class is returning dups

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1195735052 -3600 # Node ID fb84303afda80d4d180e9951b114f2769a5d6baa # Parent 710a381591c1a67e5a79ad3b04aaa8bc7adbb108 Enumeration on VirtualSystemManagementService class is returning dups On systems where only one hypervisor is existing, the provider returned instance for all known subclasses (Xen, KVM). Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 710a381591c1 -r fb84303afda8 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Thu Nov 22 13:13:00 2007 +0100 +++ b/src/Virt_VirtualSystemManagementService.c Thu Nov 22 13:37:32 2007 +0100 @@ -1048,26 +1048,32 @@ CMPIStatus get_vsms(const CMPIObjectPath CMPIStatus get_vsms(const CMPIObjectPath *reference, CMPIInstance **_inst, const CMPIBroker *broker) -{ - CMPIStatus s; - CMPIInstance *inst; - CMPIInstance *host; +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *inst = NULL; + CMPIInstance *host = NULL; char *val = NULL; + virConnectPtr conn = NULL; + + conn = connect_by_classname(broker, CLASSNAME(reference), &s); + if (conn == NULL) + goto out; s = get_host_cs(broker, reference, &host); if (s.rc != CMPI_RC_OK) - goto out; + goto err; inst = get_typed_instance(broker, - CLASSNAME(reference), + pfx_from_conn(conn), "VirtualSystemManagementService", NAMESPACE(reference)); + if (inst == NULL) { CU_DEBUG("Failed to get typed instance"); cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, "Failed to create instance"); - goto out; + goto err; } CMSetProperty(inst, "Name", @@ -1076,8 +1082,8 @@ CMPIStatus get_vsms(const CMPIObjectPath if (cu_get_str_prop(host, "Name", &val) != CMPI_RC_OK) { cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, - "Unable to get name of System"); - goto out; + "Unable to get name of HostSystem"); + goto err; } CMSetProperty(inst, "SystemName", @@ -1087,8 +1093,8 @@ CMPIStatus get_vsms(const CMPIObjectPath if (cu_get_str_prop(host, "CreationClassName", &val) != CMPI_RC_OK) { cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, - "Unable to get creation class of system"); - goto out; + "Unable to get creation class of HostSystem"); + goto err; } CMSetProperty(inst, "SystemCreationClassName", @@ -1097,8 +1103,11 @@ CMPIStatus get_vsms(const CMPIObjectPath CMSetStatus(&s, CMPI_RC_OK); + err: + virConnectClose(conn); + + out: *_inst = inst; - out: return s; } @@ -1106,19 +1115,17 @@ static CMPIStatus return_vsms(const CMPI const CMPIResult *results, int name_only) { + CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst; - CMPIStatus s; s = get_vsms(reference, &inst, _BROKER); - if (s.rc != CMPI_RC_OK) + if (s.rc != CMPI_RC_OK || inst == NULL) goto out; if (name_only) cu_return_instance_name(results, inst); else CMReturnInstance(results, inst); - - CMSetStatus(&s, CMPI_RC_OK); out: return s; }

Heidi Eckhart wrote:
# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1195735052 -3600 # Node ID fb84303afda80d4d180e9951b114f2769a5d6baa # Parent 710a381591c1a67e5a79ad3b04aaa8bc7adbb108 Enumeration on VirtualSystemManagementService class is returning dups
On systems where only one hypervisor is existing, the provider returned instance for all known subclasses (Xen, KVM). Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com>
This looks good, although the same little issue with virConnectClose() applies here as well. +1 -- -Jay

Jay Gagnon wrote:
Heidi Eckhart wrote:
# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1195735052 -3600 # Node ID fb84303afda80d4d180e9951b114f2769a5d6baa # Parent 710a381591c1a67e5a79ad3b04aaa8bc7adbb108 Enumeration on VirtualSystemManagementService class is returning dups
On systems where only one hypervisor is existing, the provider returned instance for all known subclasses (Xen, KVM). Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com>
This looks good, although the same little issue with virConnectClose() applies here as well. +1
Sorry, reading that back I don't think it came out right. The idea was supposed to be that I'm fine with what the new changes do, and assuming the virConnectClose() bit gets cleaned up, I'm +1 on it. That cleanup will hardly be a total rework of the patch, so I think it's safe to say we can apply the cleaned up one once it hits the list. -- -Jay

HE> # HG changeset patch HE> # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> HE> # Date 1195735052 -3600 HE> # Node ID fb84303afda80d4d180e9951b114f2769a5d6baa HE> # Parent 710a381591c1a67e5a79ad3b04aaa8bc7adbb108 HE> Enumeration on VirtualSystemManagementService class is returning dups Ah, I see now. Connecting first causes us to bail if the hypervisor isn't present. Both of these patches look fine to me now, but I'd still like to see the "err:" removed. Thanks Heidi! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com
participants (3)
-
Dan Smith
-
Heidi Eckhart
-
Jay Gagnon