[libvirt] [PATCH] conf: replace call to virNetworkFree() with virOjectUnref()

Martin Kletzander mkletzan at redhat.com
Sun Nov 30 20:37:29 UTC 2014

s/virOjectUnref/virObjectUnref/ in $SUBJ if you haven't pushed already.

On Tue, Nov 25, 2014 at 05:15:23AM -0500, Laine Stump wrote:
>The function virNetworkObjListExport() in network_conf.c had a call to
>the public API virNetworkFree() which was causing a link error:
>CCLD     libvirt_driver_vbox_network_impl.la
> ./.libs/libvirt_conf.a(libvirt_conf_la-network_conf.o): In function `virNetworkObjListExport':
>/home/laine/devel/libvirt/src/conf/network_conf.c:4496: undefined reference to `virNetworkFree'
>This would happen when I added
>  #include "network_conf.h"
>into domain_conf.c, then attempted to call a new function from that
>file (and enum converter, similar to virNetworkForwardTypeToString())
>In the end, virNetworkFree() ends up just calling virObjectUnref(obj)
>anyway (after clearing all pending errors, which we probably *don't*
>want to do in the cleanup of a utility function), so this is likely
>more correct than the original code as well.
>A quick look showed that there may be other places where we are
>calling public APIs such as virNetworkFree and virDomainFree when we
>really don't want to be clearning out the pending error - this would
>result in the good old "an error was encountered but the cause is
>unknown" type of log messages. It may warrant an audit...
> src/conf/network_conf.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
>index 067334e..a249e32 100644
>--- a/src/conf/network_conf.c
>+++ b/src/conf/network_conf.c
>@@ -4463,10 +4463,8 @@ virNetworkObjListExport(virConnectPtr conn,
>  cleanup:
>     if (tmp_nets) {
>-        for (i = 0; i < nnets; i++) {
>-            if (tmp_nets[i])
>-                virNetworkFree(tmp_nets[i]);
>-        }
>+        for (i = 0; i < nnets; i++)
>+            virObjectUnref(tmp_nets[i]);
>     }
>     VIR_FREE(tmp_nets);
>libvir-list mailing list
>libvir-list at redhat.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20141130/f4900189/attachment-0001.sig>

More information about the libvir-list mailing list