Blob Blame History Raw
From 61cbc22311d3241a32fd49dab600d9ba759fbc80 Mon Sep 17 00:00:00 2001
Message-Id: <61cbc22311d3241a32fd49dab600d9ba759fbc80@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Wed, 26 Feb 2014 14:54:51 +0100
Subject: [PATCH] conf: Add helper do clear disk source authentication struct

https://bugzilla.redhat.com/show_bug.cgi?id=1032370

Add virDomainDiskAuthClear to help cleaning out the struct in other
places too.

(cherry picked from commit 0018477fb24962955a49d9591e7779bfb9b06b85)

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 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 4e182f1..6e833c8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1196,12 +1196,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);
 
@@ -1212,10 +1209,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 3d8666a..ff44a5d 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2209,6 +2209,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 827b1ec..0650a61 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -178,6 +178,7 @@ virDomainDeviceFindControllerModel;
 virDomainDeviceInfoCopy;
 virDomainDeviceInfoIterate;
 virDomainDeviceTypeToString;
+virDomainDiskAuthClear;
 virDomainDiskBusTypeToString;
 virDomainDiskCacheTypeFromString;
 virDomainDiskCacheTypeToString;
-- 
1.9.0