Add virDomainDiskAuthClear to help cleaning out the struct in other
places too.
---
src/conf/domain_conf.c | 17 ++++++++++++++---
src/conf/domain_conf.h | 1 +
src/libvirt_private.syms | 1 +
3 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e0d6903..454b21c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1201,12 +1201,9 @@ void virDomainDiskDefFree(virDomainDiskDefPtr def)
VIR_FREE(def->driverName);
virStorageFileFreeMetadata(def->backingChain);
VIR_FREE(def->mirror);
- VIR_FREE(def->auth.username);
VIR_FREE(def->wwn);
VIR_FREE(def->vendor);
VIR_FREE(def->product);
- if (def->auth.secretType == VIR_DOMAIN_DISK_SECRET_TYPE_USAGE)
- VIR_FREE(def->auth.secret.usage);
virStorageEncryptionFree(def->encryption);
virDomainDeviceInfoClear(&def->info);
@@ -1217,10 +1214,24 @@ void virDomainDiskDefFree(virDomainDiskDefPtr def)
}
virDomainDiskHostDefFree(def->nhosts, def->hosts);
+ virDomainDiskAuthClear(def);
VIR_FREE(def);
}
+
+void
+virDomainDiskAuthClear(virDomainDiskDefPtr def)
+{
+ VIR_FREE(def->auth.username);
+
+ if (def->auth.secretType == VIR_DOMAIN_DISK_SECRET_TYPE_USAGE)
+ VIR_FREE(def->auth.secret.usage);
+
+ def->auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_NONE;
+}
+
+
void virDomainDiskHostDefClear(virDomainDiskHostDefPtr def)
{
if (!def)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ee018f0..4934911 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2210,6 +2210,7 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
void virDomainInputDefFree(virDomainInputDefPtr def);
void virDomainDiskDefFree(virDomainDiskDefPtr def);
void virDomainLeaseDefFree(virDomainLeaseDefPtr def);
+void virDomainDiskAuthClear(virDomainDiskDefPtr def);
void virDomainDiskHostDefClear(virDomainDiskHostDefPtr def);
void virDomainDiskHostDefFree(size_t nhosts, virDomainDiskHostDefPtr hosts);
virDomainDiskHostDefPtr virDomainDiskHostDefCopy(size_t nhosts,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index f952a12..f8e774c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -180,6 +180,7 @@ virDomainDeviceFindControllerModel;
virDomainDeviceInfoCopy;
virDomainDeviceInfoIterate;
virDomainDeviceTypeToString;
+virDomainDiskAuthClear;
virDomainDiskBusTypeToString;
virDomainDiskCacheTypeFromString;
virDomainDiskCacheTypeToString;
--
1.8.4.3