
+1. Code looks good. No leaks after 2 cimtest runs. pushed On 05/18/2011 12:38 PM, Sharad Mishra wrote:
# HG changeset patch # User Sharad Mishra<snmishra@us.ibm.com> # Date 1305736505 25200 # Node ID 846303186ec24f6d514a76224dd3ba921232ba52 # Parent 8b428df21c360d1eaedba7157b0dfd429d2db121 (#3) Fix connection leaks.
libvirt-cim had few connection leaks which were causing it to crash.
Signed-off-by: Sharad Mishra<snmishra@us.ibm.com>
#2 - cimtest showed another leak, which was fixed in this version. #3 - Review comments to move and rename dom2 - virDomainPtr to _dom. Move virConnectClose during migration to migrate_do.
diff -r 8b428df21c36 -r 846303186ec2 libxkutil/pool_parsing.c --- a/libxkutil/pool_parsing.c Wed Apr 13 12:27:33 2011 -0700 +++ b/libxkutil/pool_parsing.c Wed May 18 09:35:05 2011 -0700 @@ -453,6 +453,7 @@ CU_DEBUG("Unable to refresh storage " "pool"); } + virStoragePoolFree(pool_ptr); ret = 1; }
diff -r 8b428df21c36 -r 846303186ec2 src/Virt_AllocationCapabilities.c --- a/src/Virt_AllocationCapabilities.c Wed Apr 13 12:27:33 2011 -0700 +++ b/src/Virt_AllocationCapabilities.c Wed May 18 09:35:05 2011 -0700 @@ -79,7 +79,6 @@ const char *id, struct inst_list *list) { - virConnectPtr conn = NULL; CMPIInstance *alloc_cap_inst; struct inst_list device_pool_list; CMPIStatus s = {CMPI_RC_OK, NULL}; @@ -91,15 +90,6 @@ if (!provider_is_responsible(broker, ref,&s)) goto out;
- conn = connect_by_classname(broker, CLASSNAME(ref),&s); - if (conn == NULL) { - if (id) - cu_statusf(broker,&s, - CMPI_RC_ERR_NOT_FOUND, - "Instance not found."); - goto out; - } - s = enum_pools(broker, ref, CIM_RES_TYPE_ALL,&device_pool_list); if (s.rc != CMPI_RC_OK) { cu_statusf(broker,&s, @@ -141,7 +131,6 @@ }
out: - virConnectClose(conn); inst_list_free(&device_pool_list);
return s; diff -r 8b428df21c36 -r 846303186ec2 src/Virt_ComputerSystem.c --- a/src/Virt_ComputerSystem.c Wed Apr 13 12:27:33 2011 -0700 +++ b/src/Virt_ComputerSystem.c Wed May 18 09:35:05 2011 -0700 @@ -907,6 +907,7 @@ { int ret; virConnectPtr conn = NULL; + virDomainPtr _dom = NULL; char *xml = NULL; CMPIStatus s = {CMPI_RC_OK, NULL};
@@ -938,12 +939,12 @@ goto out; }
- dom = virDomainLookupByName(conn, + _dom = virDomainLookupByName(conn, virDomainGetName(dom));
- if (dom == NULL) { - dom = virDomainDefineXML(conn, xml); - if (dom == NULL) { + if (_dom == NULL) { + _dom = virDomainDefineXML(conn, xml); + if (_dom == NULL) { CU_DEBUG("Failed to define domain from XML"); virt_set_status(_BROKER,&s, CMPI_RC_ERR_FAILED, @@ -953,10 +954,10 @@ } }
- if (!domain_online(dom)) + if (!domain_online(_dom)) CU_DEBUG("Guest is now offline");
- ret = virDomainCreate(dom); + ret = virDomainCreate(_dom); if (ret != 0) virt_set_status(_BROKER,&s, CMPI_RC_ERR_FAILED, @@ -965,6 +966,7 @@
out: free(xml); + virDomainFree(_dom);
return s; } diff -r 8b428df21c36 -r 846303186ec2 src/Virt_ComputerSystemIndication.c --- a/src/Virt_ComputerSystemIndication.c Wed Apr 13 12:27:33 2011 -0700 +++ b/src/Virt_ComputerSystemIndication.c Wed May 18 09:35:05 2011 -0700 @@ -422,7 +422,6 @@ }
static bool async_ind(CMPIContext *context, - virConnectPtr conn, int ind_type, struct dom_xml prev_dom, char *prefix, @@ -557,7 +556,7 @@ for (i = 0; i< cur_count; i++) { res = dom_in_list(cur_xml[i].uuid, prev_count, prev_xml); if (!res) - async_ind(context, conn, CS_CREATED, + async_ind(context, CS_CREATED, cur_xml[i], prefix, args);
} @@ -565,14 +564,14 @@ for (i = 0; i< prev_count; i++) { res = dom_in_list(prev_xml[i].uuid, cur_count, cur_xml); if (!res) - async_ind(context, conn, CS_DELETED, + async_ind(context, CS_DELETED, prev_xml[i], prefix, args); }
for (i = 0; i< prev_count; i++) { res = dom_changed(prev_xml[i], cur_xml, cur_count); if (res) { - async_ind(context, conn, CS_MODIFIED, + async_ind(context, CS_MODIFIED, prev_xml[i], prefix, args);
} diff -r 8b428df21c36 -r 846303186ec2 src/Virt_DevicePool.c --- a/src/Virt_DevicePool.c Wed Apr 13 12:27:33 2011 -0700 +++ b/src/Virt_DevicePool.c Wed May 18 09:35:05 2011 -0700 @@ -451,8 +451,8 @@
free(host); free(dev); + virDomainFree(dom); virConnectClose(conn); - virDomainFree(dom);
return pool; } diff -r 8b428df21c36 -r 846303186ec2 src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Wed Apr 13 12:27:33 2011 -0700 +++ b/src/Virt_VSMigrationService.c Wed May 18 09:35:05 2011 -0700 @@ -1294,7 +1294,6 @@ "Completed");
raise_deleted_ind(job); - virConnectClose(job->conn); free(job->domain); free(job->ref_cn); free(job->ref_ns); @@ -1511,6 +1510,7 @@
out: CMReturnData(results, (CMPIValue *)&retcode, CMPI_uint32); + virConnectClose(job->conn);
return s; }
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Chip Vincent Open Virtualization IBM Linux Technology Center cvincent@linux.vnet.ibm.com