[PATCH 1/3] conf: Refactor helpers to retrieve actual storage type

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

 



Now that the storage source definition is uniform convert the helpers to
retrieve the actual storage type to a single one.
---
 src/conf/domain_conf.c       | 10 ----------
 src/conf/domain_conf.h       |  1 -
 src/conf/snapshot_conf.c     |  7 -------
 src/conf/snapshot_conf.h     |  2 --
 src/libvirt_private.syms     |  3 +--
 src/qemu/qemu_command.c      |  6 +++---
 src/qemu/qemu_driver.c       | 12 ++++++------
 src/storage/storage_driver.c |  4 ++--
 src/util/virstoragefile.c    | 10 ++++++++++
 src/util/virstoragefile.h    |  1 +
 10 files changed, 23 insertions(+), 33 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 52bbf87..56a7f70 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1215,16 +1215,6 @@ virDomainDiskSetType(virDomainDiskDefPtr def, int type)
 }


-int
-virDomainDiskGetActualType(virDomainDiskDefPtr def)
-{
-    if (def->src.type == VIR_STORAGE_TYPE_VOLUME && def->src.srcpool)
-        return def->src.srcpool->actualtype;
-
-    return def->src.type;
-}
-
-
 const char *
 virDomainDiskGetSource(virDomainDiskDefPtr def)
 {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index addf654..2ff0bc4 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2132,7 +2132,6 @@ void virDomainDiskDefFree(virDomainDiskDefPtr def);
 void virDomainLeaseDefFree(virDomainLeaseDefPtr def);
 int virDomainDiskGetType(virDomainDiskDefPtr def);
 void virDomainDiskSetType(virDomainDiskDefPtr def, int type);
-int virDomainDiskGetActualType(virDomainDiskDefPtr def);
 const char *virDomainDiskGetSource(virDomainDiskDefPtr def);
 int virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
     ATTRIBUTE_RETURN_CHECK;
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
index 852a286..070e50d 100644
--- a/src/conf/snapshot_conf.c
+++ b/src/conf/snapshot_conf.c
@@ -1290,10 +1290,3 @@ virDomainSnapshotRedefinePrep(virDomainPtr domain,
  cleanup:
     return ret;
 }
-
-
-int
-virDomainSnapshotDiskGetActualType(virDomainSnapshotDiskDefPtr def)
-{
-    return def->src.type;
-}
diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h
index 1444d77..5f74b62 100644
--- a/src/conf/snapshot_conf.h
+++ b/src/conf/snapshot_conf.h
@@ -183,8 +183,6 @@ int virDomainSnapshotRedefinePrep(virDomainPtr domain,
                                   bool *update_current,
                                   unsigned int flags);

-int virDomainSnapshotDiskGetActualType(virDomainSnapshotDiskDefPtr def);
-
 VIR_ENUM_DECL(virDomainSnapshotLocation)
 VIR_ENUM_DECL(virDomainSnapshotState)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 55aa586..9c189dc 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -197,7 +197,6 @@ virDomainDiskErrorPolicyTypeToString;
 virDomainDiskFindByBusAndDst;
 virDomainDiskGeometryTransTypeFromString;
 virDomainDiskGeometryTransTypeToString;
-virDomainDiskGetActualType;
 virDomainDiskGetDriver;
 virDomainDiskGetFormat;
 virDomainDiskGetSource;
@@ -663,7 +662,6 @@ virDomainSnapshotDefFormat;
 virDomainSnapshotDefFree;
 virDomainSnapshotDefIsExternal;
 virDomainSnapshotDefParseString;
-virDomainSnapshotDiskGetActualType;
 virDomainSnapshotDropParent;
 virDomainSnapshotFindByName;
 virDomainSnapshotForEach;
@@ -1843,6 +1841,7 @@ virStorageNetHostTransportTypeToString;
 virStorageNetProtocolTypeToString;
 virStorageSourceAuthClear;
 virStorageSourceClear;
+virStorageSourceGetActualType;
 virStorageSourcePoolDefFree;
 virStorageSourcePoolModeTypeFromString;
 virStorageSourcePoolModeTypeToString;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 379c094..8b58d5e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3863,7 +3863,7 @@ qemuDomainDiskGetSourceString(virConnectPtr conn,
                               virDomainDiskDefPtr disk,
                               char **source)
 {
-    int actualType = virDomainDiskGetActualType(disk);
+    int actualType = virStorageSourceGetActualType(&disk->src);
     char *secret = NULL;
     int ret = -1;

@@ -3893,7 +3893,7 @@ qemuDomainDiskGetSourceString(virConnectPtr conn,
             goto cleanup;
     }

-    ret = qemuGetDriveSourceString(virDomainDiskGetActualType(disk),
+    ret = qemuGetDriveSourceString(actualType,
                                    disk->src.path,
                                    disk->src.protocol,
                                    disk->src.nhosts,
@@ -3921,7 +3921,7 @@ qemuBuildDriveStr(virConnectPtr conn,
     int idx = virDiskNameToIndex(disk->dst);
     int busid = -1, unitid = -1;
     char *source = NULL;
-    int actualType = virDomainDiskGetActualType(disk);
+    int actualType = virStorageSourceGetActualType(&disk->src);

     if (idx < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 4bb4819..5b0e484 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12005,7 +12005,7 @@ qemuDomainSnapshotDiskGetSourceString(virDomainSnapshotDiskDefPtr disk,
 {
     *source = NULL;

-    return qemuGetDriveSourceString(virDomainSnapshotDiskGetActualType(disk),
+    return qemuGetDriveSourceString(virStorageSourceGetActualType(&disk->src),
                                     disk->src.path,
                                     disk->src.protocol,
                                     disk->src.nhosts,
@@ -12326,7 +12326,7 @@ qemuDomainSnapshotCreateActiveInternal(virConnectPtr conn,
 static int
 qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
 {
-    int actualType = virDomainDiskGetActualType(disk);
+    int actualType = virStorageSourceGetActualType(&disk->src);

     switch ((enum virStorageType) actualType) {
     case VIR_STORAGE_TYPE_BLOCK:
@@ -12371,7 +12371,7 @@ qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
 static int
 qemuDomainSnapshotPrepareDiskExternalBackingActive(virDomainDiskDefPtr disk)
 {
-    int actualType = virDomainDiskGetActualType(disk);
+    int actualType = virStorageSourceGetActualType(&disk->src);

     if (actualType == VIR_STORAGE_TYPE_BLOCK &&
         disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) {
@@ -12388,7 +12388,7 @@ qemuDomainSnapshotPrepareDiskExternalBackingActive(virDomainDiskDefPtr disk)
 static int
 qemuDomainSnapshotPrepareDiskExternalOverlayActive(virDomainSnapshotDiskDefPtr disk)
 {
-    int actualType = virDomainSnapshotDiskGetActualType(disk);
+    int actualType = virStorageSourceGetActualType(&disk->src);

     switch ((enum virStorageType) actualType) {
     case VIR_STORAGE_TYPE_BLOCK:
@@ -12436,7 +12436,7 @@ qemuDomainSnapshotPrepareDiskExternalOverlayActive(virDomainSnapshotDiskDefPtr d
 static int
 qemuDomainSnapshotPrepareDiskExternalOverlayInactive(virDomainSnapshotDiskDefPtr disk)
 {
-    int actualType = virDomainSnapshotDiskGetActualType(disk);
+    int actualType = virStorageSourceGetActualType(&disk->src);

     switch ((enum virStorageType) actualType) {
     case VIR_STORAGE_TYPE_BLOCK:
@@ -12534,7 +12534,7 @@ qemuDomainSnapshotPrepareDiskInternal(virConnectPtr conn,
     if (qemuTranslateDiskSourcePool(conn, disk) < 0)
         return -1;

-    actualType = virDomainDiskGetActualType(disk);
+    actualType = virStorageSourceGetActualType(&disk->src);

     switch ((enum virStorageType) actualType) {
     case VIR_STORAGE_TYPE_BLOCK:
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 2f98f78..629525a 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -2790,7 +2790,7 @@ virStorageFileInitInternal(int type,
 virStorageFilePtr
 virStorageFileInitFromDiskDef(virDomainDiskDefPtr disk)
 {
-    return virStorageFileInitInternal(virDomainDiskGetActualType(disk),
+    return virStorageFileInitInternal(virStorageSourceGetActualType(&disk->src),
                                       disk->src.path,
                                       disk->src.protocol,
                                       disk->src.nhosts,
@@ -2801,7 +2801,7 @@ virStorageFileInitFromDiskDef(virDomainDiskDefPtr disk)
 virStorageFilePtr
 virStorageFileInitFromSnapshotDef(virDomainSnapshotDiskDefPtr disk)
 {
-    return virStorageFileInitInternal(virDomainSnapshotDiskGetActualType(disk),
+    return virStorageFileInitInternal(virStorageSourceGetActualType(&disk->src),
                                       disk->src.path,
                                       disk->src.protocol,
                                       disk->src.nhosts,
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 3cdc89c..2bf3a53 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1561,6 +1561,16 @@ virStorageSourceAuthClear(virStorageSourcePtr def)
 }


+int
+virStorageSourceGetActualType(virStorageSourcePtr def)
+{
+    if (def->type == VIR_STORAGE_TYPE_VOLUME && def->srcpool)
+        return def->srcpool->actualtype;
+
+    return def->type;
+}
+
+
 void
 virStorageSourceClear(virStorageSourcePtr def)
 {
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 83ec2bd..22198a8 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -298,5 +298,6 @@ virStorageNetHostDefPtr virStorageNetHostDefCopy(size_t nhosts,
 void virStorageSourceAuthClear(virStorageSourcePtr def);
 void virStorageSourcePoolDefFree(virStorageSourcePoolDefPtr def);
 void virStorageSourceClear(virStorageSourcePtr def);
+int virStorageSourceGetActualType(virStorageSourcePtr def);

 #endif /* __VIR_STORAGE_FILE_H__ */
-- 
1.9.1

--
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]