[PATCH 11/n] conf: move common disk source functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Move some functions out of domain_conf for use in the next
patch where snapshot starts to directly use structs in
virstoragefile.

* src/conf/domain_conf.c (virDomainDiskDefFree)
(virDomainDiskSourcePoolDefParse): Adjust callers.
(virDomainDiskSourceDefClear, virDomainDiskSourcePoolDefFree)
(virDomainDiskAuthClear): Move...
* src/util/virstoragefile.c (virStorageSourceClear)
(virStorageSourcePoolDefFree, virStorageSourceAuthClear): ...and
rename.
* src/conf/domain_conf.h (virDomainDiskAuthClear): Drop
declaration.
* src/qemu/qemu_conf.c (qemuTranslateDiskSourcePool): Adjust
caller.
* src/util/virstoragefile.h: Declare them.
* src/libvirt_private.syms (virstoragefile.h): Export them.

Signed-off-by: Eric Blake <eblake@xxxxxxxxxx>
---
 src/conf/domain_conf.c    | 52 ++---------------------------------------------
 src/conf/domain_conf.h    |  1 -
 src/libvirt_private.syms  |  4 +++-
 src/qemu/qemu_conf.c      |  2 +-
 src/util/virstoragefile.c | 49 ++++++++++++++++++++++++++++++++++++++++++++
 src/util/virstoragefile.h |  3 +++
 6 files changed, 58 insertions(+), 53 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b38021d..0af5be7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1179,42 +1179,6 @@ void virDomainLeaseDefFree(virDomainLeaseDefPtr def)
     VIR_FREE(def);
 }

-static void
-virDomainDiskSourcePoolDefFree(virStorageSourcePoolDefPtr def)
-{
-    if (!def)
-        return;
-
-    VIR_FREE(def->pool);
-    VIR_FREE(def->volume);
-
-    VIR_FREE(def);
-}
-
-
-static void
-virDomainDiskSourceDefClear(virStorageSourcePtr def)
-{
-    size_t i;
-
-    if (!def)
-        return;
-
-    VIR_FREE(def->path);
-    virDomainDiskSourcePoolDefFree(def->srcpool);
-    VIR_FREE(def->driverName);
-    virStorageEncryptionFree(def->encryption);
-
-    if (def->seclabels) {
-        for (i = 0; i < def->nseclabels; i++)
-            virSecurityDeviceLabelDefFree(def->seclabels[i]);
-        VIR_FREE(def->seclabels);
-    }
-
-    virStorageNetHostDefFree(def->nhosts, def->hosts);
-    virDomainDiskAuthClear(def);
-}
-

 void
 virDomainDiskDefFree(virDomainDiskDefPtr def)
@@ -1222,7 +1186,7 @@ virDomainDiskDefFree(virDomainDiskDefPtr def)
     if (!def)
         return;

-    virDomainDiskSourceDefClear(&def->src);
+    virStorageSourceClear(&def->src);
     VIR_FREE(def->serial);
     VIR_FREE(def->dst);
     virStorageFileFreeMetadata(def->backingChain);
@@ -1236,18 +1200,6 @@ virDomainDiskDefFree(virDomainDiskDefPtr def)
 }


-void
-virDomainDiskAuthClear(virStorageSourcePtr def)
-{
-    VIR_FREE(def->auth.username);
-
-    if (def->auth.secretType == VIR_STORAGE_SECRET_TYPE_USAGE)
-        VIR_FREE(def->auth.secret.usage);
-
-    def->auth.secretType = VIR_STORAGE_SECRET_TYPE_NONE;
-}
-
-
 int
 virDomainDiskGetType(virDomainDiskDefPtr def)
 {
@@ -4995,7 +4947,7 @@ virDomainDiskSourcePoolDefParse(xmlNodePtr node,
     ret = 0;

  cleanup:
-    virDomainDiskSourcePoolDefFree(source);
+    virStorageSourcePoolDefFree(source);
     VIR_FREE(mode);
     return ret;
 }
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index b011847..02ac5de 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2125,7 +2125,6 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def);
 void virDomainInputDefFree(virDomainInputDefPtr def);
 void virDomainDiskDefFree(virDomainDiskDefPtr def);
 void virDomainLeaseDefFree(virDomainLeaseDefPtr def);
-void virDomainDiskAuthClear(virStorageSourcePtr def);
 int virDomainDiskGetType(virDomainDiskDefPtr def);
 void virDomainDiskSetType(virDomainDiskDefPtr def, int type);
 int virDomainDiskGetActualType(virDomainDiskDefPtr def);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 07d4f36..2d12105 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -181,7 +181,6 @@ virDomainDeviceGetInfo;
 virDomainDeviceInfoCopy;
 virDomainDeviceInfoIterate;
 virDomainDeviceTypeToString;
-virDomainDiskAuthClear;
 virDomainDiskBusTypeToString;
 virDomainDiskCacheTypeFromString;
 virDomainDiskCacheTypeToString;
@@ -1840,6 +1839,9 @@ virStorageNetHostDefFree;
 virStorageNetHostTransportTypeFromString;
 virStorageNetHostTransportTypeToString;
 virStorageNetProtocolTypeToString;
+virStorageSourceAuthClear;
+virStorageSourceClear;
+virStorageSourcePoolDefFree;
 virStorageSourcePoolModeTypeFromString;
 virStorageSourcePoolModeTypeToString;
 virStorageTypeFromString;
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 3352936..209558d 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1310,7 +1310,7 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,

     VIR_FREE(def->src.path);
     virStorageNetHostDefFree(def->src.nhosts, def->src.hosts);
-    virDomainDiskAuthClear(&def->src);
+    virStorageSourceAuthClear(&def->src);

     switch ((enum virStoragePoolType) pooldef->type) {
     case VIR_STORAGE_POOL_DIR:
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index e201bc9..bbaa171 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1531,3 +1531,52 @@ virStorageNetHostDefCopy(size_t nhosts,
     virStorageNetHostDefFree(nhosts, ret);
     return NULL;
 }
+
+
+void
+virStorageSourcePoolDefFree(virStorageSourcePoolDefPtr def)
+{
+    if (!def)
+        return;
+
+    VIR_FREE(def->pool);
+    VIR_FREE(def->volume);
+
+    VIR_FREE(def);
+}
+
+
+void
+virStorageSourceAuthClear(virStorageSourcePtr def)
+{
+    VIR_FREE(def->auth.username);
+
+    if (def->auth.secretType == VIR_STORAGE_SECRET_TYPE_USAGE)
+        VIR_FREE(def->auth.secret.usage);
+
+    def->auth.secretType = VIR_STORAGE_SECRET_TYPE_NONE;
+}
+
+
+void
+virStorageSourceClear(virStorageSourcePtr def)
+{
+    size_t i;
+
+    if (!def)
+        return;
+
+    VIR_FREE(def->path);
+    virStorageSourcePoolDefFree(def->srcpool);
+    VIR_FREE(def->driverName);
+    virStorageEncryptionFree(def->encryption);
+
+    if (def->seclabels) {
+        for (i = 0; i < def->nseclabels; i++)
+            virSecurityDeviceLabelDefFree(def->seclabels[i]);
+        VIR_FREE(def->seclabels);
+    }
+
+    virStorageNetHostDefFree(def->nhosts, def->hosts);
+    virStorageSourceAuthClear(def);
+}
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 18db09e..4980960 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -262,5 +262,8 @@ void virStorageNetHostDefFree(size_t nhosts, virStorageNetHostDefPtr hosts);
 virStorageNetHostDefPtr virStorageNetHostDefCopy(size_t nhosts,
                                                  virStorageNetHostDefPtr hosts);

+void virStorageSourceAuthClear(virStorageSourcePtr def);
+void virStorageSourcePoolDefFree(virStorageSourcePoolDefPtr def);
+void virStorageSourceClear(virStorageSourcePtr def);

 #endif /* __VIR_STORAGE_FILE_H__ */
-- 
1.9.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]