I'm also squashing in this (addition of virDomainHostdevDefClear()) into PATCH 1/6, per the discussion in: https://www.redhat.com/archives/libvir-list/2012-February/msg00895.html --- src/conf/domain_conf.c | 17 ++++++++++++++++- src/conf/domain_conf.h | 1 + src/libvirt_private.syms | 1 + 3 files changed, 18 insertions(+), 1 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c950391..3719097 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1313,12 +1313,27 @@ virDomainHostdevDefPtr virDomainHostdevDefAlloc(void) return def; } -void virDomainHostdevDefFree(virDomainHostdevDefPtr def) +void virDomainHostdevDefClear(virDomainHostdevDefPtr def) { if (!def) return; + /* At this point, any resources in the hostdevdef *except + * def->info* should be freed. Currently there are no such + * resources. + */ + virDomainDeviceInfoFree(def->info); +} + +void virDomainHostdevDefFree(virDomainHostdevDefPtr def) +{ + if (!def) + return; + + /* free all subordinate objects */ + virDomainHostdevDefClear(def); + VIR_FREE(def); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 1f7f25a..43cc08f 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1741,6 +1741,7 @@ void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def); void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def); void virDomainVideoDefFree(virDomainVideoDefPtr def); virDomainHostdevDefPtr virDomainHostdevDefAlloc(void); +void virDomainHostdevDefClear(virDomainHostdevDefPtr def); void virDomainHostdevDefFree(virDomainHostdevDefPtr def); void virDomainHubDefFree(virDomainHubDefPtr def); void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index dc55f7b..0869ee6 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -351,6 +351,7 @@ virDomainGraphicsSpiceZlibCompressionTypeToString; virDomainGraphicsTypeFromString; virDomainGraphicsTypeToString; virDomainHostdevDefAlloc; +virDomainHostdevDefClear; virDomainHostdevDefFree; virDomainHostdevModeTypeToString; virDomainHostdevSubsysTypeToString; -- 1.7.7.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list