We need to clear these out without freeing the object completely. --- src/conf/domain_conf.c | 14 +++++++++++++- src/conf/domain_conf.h | 1 + src/libvirt_private.syms | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c5b4815..899b6af 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1737,7 +1737,8 @@ virDomainActualNetDefFree(virDomainActualNetDefPtr def) VIR_FREE(def); } -void virDomainNetDefFree(virDomainNetDefPtr def) +void +virDomainNetDefClear(virDomainNetDefPtr def) { size_t i; @@ -1753,6 +1754,7 @@ void virDomainNetDefFree(virDomainNetDefPtr def) case VIR_DOMAIN_NET_TYPE_VHOSTUSER: virDomainChrSourceDefFree(def->data.vhostuser); + def->data.vhostuser = NULL; break; case VIR_DOMAIN_NET_TYPE_SERVER: @@ -1767,6 +1769,7 @@ void virDomainNetDefFree(virDomainNetDefPtr def) VIR_FREE(def->data.network.name); VIR_FREE(def->data.network.portgroup); virDomainActualNetDefFree(def->data.network.actual); + def->data.network.actual = NULL; break; case VIR_DOMAIN_NET_TYPE_BRIDGE: @@ -1811,10 +1814,19 @@ void virDomainNetDefFree(virDomainNetDefPtr def) VIR_FREE(def->filter); virNWFilterHashTableFree(def->filterparams); + def->filterparams = NULL; virNetDevBandwidthFree(def->bandwidth); + def->bandwidth = NULL; virNetDevVlanClear(&def->vlan); +} +void +virDomainNetDefFree(virDomainNetDefPtr def) +{ + if (!def) + return; + virDomainNetDefClear(def); VIR_FREE(def); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 8529a78..b9dc174 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2492,6 +2492,7 @@ virDomainControllerDefPtr virDomainControllerDefNew(virDomainControllerType type); void virDomainFSDefFree(virDomainFSDefPtr def); void virDomainActualNetDefFree(virDomainActualNetDefPtr def); +void virDomainNetDefClear(virDomainNetDefPtr def); void virDomainNetDefFree(virDomainNetDefPtr def); void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def); void virDomainChrDefFree(virDomainChrDefPtr def); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 36e3901..807ffce 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -372,6 +372,7 @@ virDomainMemoryFindInactiveByDef; virDomainMemoryInsert; virDomainMemoryRemove; virDomainNetAppendIPAddress; +virDomainNetDefClear; virDomainNetDefFormat; virDomainNetDefFree; virDomainNetFind; -- 2.5.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list