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

[libvirt] [PATCHv6 1/8] conf: Move qemuDiskGetActualType to virDomainDiskGetActualType



All the data for getting the actual type is present in the domain
config. There is no need to have this function private to the qemu
driver and it will be re-used later in other parts of libvirt
---

Notes:
    Version 6:
    - new in series

 src/conf/domain_conf.c   | 10 ++++++++++
 src/conf/domain_conf.h   |  1 +
 src/libvirt_private.syms |  1 +
 src/qemu/qemu_command.c  |  6 +++---
 src/qemu/qemu_conf.c     | 10 ----------
 src/qemu/qemu_conf.h     |  2 --
 src/qemu/qemu_driver.c   |  6 +++---
 7 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f6065ed..fc9615f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1345,6 +1345,16 @@ error:
 }


+int
+virDomainDiskGetActualType(virDomainDiskDefPtr def)
+{
+    if (def->type == VIR_DOMAIN_DISK_TYPE_VOLUME && def->srcpool)
+        return def->srcpool->actualtype;
+
+    return def->type;
+}
+
+
 void virDomainControllerDefFree(virDomainControllerDefPtr def)
 {
     if (!def)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 4895e81..24cbec3 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2252,6 +2252,7 @@ void virDomainDiskHostDefClear(virDomainDiskHostDefPtr def);
 void virDomainDiskHostDefFree(size_t nhosts, virDomainDiskHostDefPtr hosts);
 virDomainDiskHostDefPtr virDomainDiskHostDefCopy(size_t nhosts,
                                                  virDomainDiskHostDefPtr hosts);
+int virDomainDiskGetActualType(virDomainDiskDefPtr def);
 int virDomainDeviceFindControllerModel(virDomainDefPtr def,
                                        virDomainDeviceInfoPtr info,
                                        int controllerType);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 0b28bac..aae6a3b 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -198,6 +198,7 @@ virDomainDiskErrorPolicyTypeToString;
 virDomainDiskFindByBusAndDst;
 virDomainDiskGeometryTransTypeFromString;
 virDomainDiskGeometryTransTypeToString;
+virDomainDiskGetActualType;
 virDomainDiskHostDefClear;
 virDomainDiskHostDefCopy;
 virDomainDiskHostDefFree;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index e499d54..e9908f9 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3869,7 +3869,7 @@ qemuDomainDiskGetSourceString(virConnectPtr conn,
                               virDomainDiskDefPtr disk,
                               char **source)
 {
-    int actualType = qemuDiskGetActualType(disk);
+    int actualType = virDomainDiskGetActualType(disk);
     char *secret = NULL;
     int ret = -1;

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

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

     if (idx < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index ecaaf81..dc4ded3 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1304,16 +1304,6 @@ cleanup:


 int
-qemuDiskGetActualType(virDomainDiskDefPtr def)
-{
-    if (def->type == VIR_DOMAIN_DISK_TYPE_VOLUME && def->srcpool)
-        return def->srcpool->actualtype;
-
-    return def->type;
-}
-
-
-int
 qemuTranslateDiskSourcePool(virConnectPtr conn,
                             virDomainDiskDefPtr def)
 {
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 1f44a76..842b740 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -305,8 +305,6 @@ int qemuSetUnprivSGIO(virDomainDeviceDefPtr dev);
 int qemuDriverAllocateID(virQEMUDriverPtr driver);
 virDomainXMLOptionPtr virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver);

-int qemuDiskGetActualType(virDomainDiskDefPtr def);
-
 int qemuTranslateDiskSourcePool(virConnectPtr conn,
                                 virDomainDiskDefPtr def);

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 59e018d..6ddbd21 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12260,7 +12260,7 @@ endjob:
 static int
 qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
 {
-    int actualType = qemuDiskGetActualType(disk);
+    int actualType = virDomainDiskGetActualType(disk);

     switch ((enum virDomainDiskType) actualType) {
     case VIR_DOMAIN_DISK_TYPE_BLOCK:
@@ -12304,7 +12304,7 @@ qemuDomainSnapshotPrepareDiskExternalBackingInactive(virDomainDiskDefPtr disk)
 static int
 qemuDomainSnapshotPrepareDiskExternalBackingActive(virDomainDiskDefPtr disk)
 {
-    int actualType = qemuDiskGetActualType(disk);
+    int actualType = virDomainDiskGetActualType(disk);

     if (actualType == VIR_DOMAIN_DISK_TYPE_BLOCK &&
         disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) {
@@ -12448,7 +12448,7 @@ qemuDomainSnapshotPrepareDiskInternal(virConnectPtr conn,
     if (qemuTranslateDiskSourcePool(conn, disk) < 0)
         return -1;

-    actualType = qemuDiskGetActualType(disk);
+    actualType = virDomainDiskGetActualType(disk);

     switch ((enum virDomainDiskType) actualType) {
     case VIR_DOMAIN_DISK_TYPE_BLOCK:
-- 
1.8.5.3


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