[PATCH 0 of 3] Clean up leaks, ensure libvirt pointers are properly freed

These fixes resolve an occasional hang and and recv error messages seen when running with upstream libvirt. The recv error message is the same one seen in the test run from March 25th on KVM on Fedora rawhide: "libvir: Remote error : cannot recv data: Connection reset by peer"

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1239243141 14400 # Node ID 58ebddb9670798102bf8fcd4d47a6137b0779571 # Parent cdf4fa212c15f1b22b0b4b1d1535e1716e1e52d2 Free virStorageVolPtr in disk_template() in SDC Need to free the pointer each time through the loop. diff -r cdf4fa212c15 -r 58ebddb96707 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Thu Apr 09 10:07:27 2009 -0700 +++ b/src/Virt_SettingsDefineCapabilities.c Wed Apr 08 22:12:21 2009 -0400 @@ -1014,6 +1014,9 @@ } s = volume_template(ref, template_type, volptr, list); + + virStorageVolFree(volptr); + if (s.rc != CMPI_RC_OK) goto out; } @@ -1024,7 +1027,6 @@ free(pfx); free(volnames); free(host); - virStorageVolFree(volptr); virStoragePoolFree(poolptr); virConnectClose(conn);

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1238622609 25200 # Node ID 2e7cebb8a166483d9997becd030666166631c301 # Parent 58ebddb9670798102bf8fcd4d47a6137b0779571 Fix spots where virConnectPtr isn't being closed properly Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 58ebddb96707 -r 2e7cebb8a166 src/Virt_KVMRedirectionSAP.c --- a/src/Virt_KVMRedirectionSAP.c Wed Apr 08 22:12:21 2009 -0400 +++ b/src/Virt_KVMRedirectionSAP.c Wed Apr 01 14:50:09 2009 -0700 @@ -269,7 +269,7 @@ struct inst_list *list) { CMPIStatus s = {CMPI_RC_OK, NULL}; - virConnectPtr conn; + virConnectPtr conn = NULL; virDomainPtr *domain_list; struct domain *dominfo = NULL; struct vnc_ports port_list; @@ -364,6 +364,7 @@ } free(port_list.list); + virConnectClose(conn); return s; } diff -r 58ebddb96707 -r 2e7cebb8a166 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Wed Apr 08 22:12:21 2009 -0400 +++ b/src/Virt_SettingsDefineCapabilities.c Wed Apr 01 14:50:09 2009 -0700 @@ -374,6 +374,7 @@ ret = true; out: + virConnectClose(conn); return ret; } @@ -702,7 +703,7 @@ bool ret = false; const char *inst_id; CMPIrc prop_ret; - virConnectPtr conn; + virConnectPtr conn = NULL; CMPIInstance *pool_inst; if (cu_get_str_path(ref, "InstanceID", &inst_id) != CMPI_RC_OK) { @@ -738,6 +739,7 @@ ret = true; out: + virConnectClose(conn); return ret; } diff -r 58ebddb96707 -r 2e7cebb8a166 src/Virt_VSSD.c --- a/src/Virt_VSSD.c Wed Apr 08 22:12:21 2009 -0400 +++ b/src/Virt_VSSD.c Wed Apr 01 14:50:09 2009 -0700 @@ -238,6 +238,7 @@ out: free(list); + virConnectClose(conn); return s; } diff -r 58ebddb96707 -r 2e7cebb8a166 src/Virt_VirtualSystemManagementService.c --- a/src/Virt_VirtualSystemManagementService.c Wed Apr 08 22:12:21 2009 -0400 +++ b/src/Virt_VirtualSystemManagementService.c Wed Apr 01 14:50:09 2009 -0700 @@ -969,7 +969,7 @@ CMPI_RC_ERR_FAILED, conn, "Failed to define domain"); - return NULL; + goto out; } name = virDomainGetName(dom); @@ -982,6 +982,7 @@ "Failed to lookup resulting system"); } + out: virDomainFree(dom); virConnectClose(conn);

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1239243762 14400 # Node ID 8d0ce3b79aaacde9a7b25d8e2fe2eb79878229ee # Parent 2e7cebb8a166483d9997becd030666166631c301 Fix places where virDomainPtr aren't properly freed. diff -r 2e7cebb8a166 -r 8d0ce3b79aaa src/Virt_KVMRedirectionSAP.c --- a/src/Virt_KVMRedirectionSAP.c Wed Apr 01 14:50:09 2009 -0700 +++ b/src/Virt_KVMRedirectionSAP.c Wed Apr 08 22:22:42 2009 -0400 @@ -374,7 +374,7 @@ CMPIInstance **_inst) { virConnectPtr conn; - virDomainPtr dom; + virDomainPtr dom = NULL; CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; struct domain *dominfo = NULL; @@ -445,14 +445,13 @@ inst = get_console_sap(broker, ref, conn, port, &s); - virDomainFree(dom); - if (s.rc != CMPI_RC_OK) goto out; *_inst = inst; out: + virDomainFree(dom); virConnectClose(conn); if (port != NULL) free(port->name); diff -r 2e7cebb8a166 -r 8d0ce3b79aaa src/Virt_RASD.c --- a/src/Virt_RASD.c Wed Apr 01 14:50:09 2009 -0700 +++ b/src/Virt_RASD.c Wed Apr 08 22:22:42 2009 -0400 @@ -63,12 +63,17 @@ struct virt_device **list) { virDomainPtr dom; + int count = 0; dom = virDomainLookupByName(conn, host); if (dom == NULL) return 0; - return get_devices(dom, list, type); + count = get_devices(dom, list, type); + + virDomainFree(dom); + + return count; } static struct virt_device *find_dev(virConnectPtr conn, @@ -703,6 +708,7 @@ out: virConnectClose(conn); + free(domains); return s; }

+1 Kaitlin Rupert wrote:
These fixes resolve an occasional hang and and recv error messages seen when running with upstream libvirt.
The recv error message is the same one seen in the test run from March 25th on KVM on Fedora rawhide:
"libvir: Remote error : cannot recv data: Connection reset by peer"
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
-- Richard Maciel, MSc IBM Linux Technology Center rmaciel@linux.vnet.ibm.com
participants (2)
-
Kaitlin Rupert
-
Richard Maciel