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

[libvirt] [PATCH 19/20] vbox: Introducing vboxCommonStorageDriver



---
 src/vbox/vbox_common.c        |   63 +++++++++++++++++++++++++++++------------
 src/vbox/vbox_driver.c        |   52 ++--------------------------------
 src/vbox/vbox_tmpl.c          |   24 ----------------
 src/vbox/vbox_uniformed_api.h |   17 -----------
 4 files changed, 47 insertions(+), 109 deletions(-)

diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index e32bee5..b1136c7 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -8293,9 +8293,10 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr network, unsigned int flags)
  * The Storage Functions here on
  */
 
-virDrvOpenStatus vboxStorageOpen(virConnectPtr conn,
-                                 virConnectAuthPtr auth ATTRIBUTE_UNUSED,
-                                 unsigned int flags)
+static virDrvOpenStatus
+vboxStorageOpen(virConnectPtr conn,
+                virConnectAuthPtr auth ATTRIBUTE_UNUSED,
+                unsigned int flags)
 {
     vboxGlobalData *data = conn->privateData;
 
@@ -8314,14 +8315,14 @@ virDrvOpenStatus vboxStorageOpen(virConnectPtr conn,
     return VIR_DRV_OPEN_SUCCESS;
 }
 
-int vboxStorageClose(virConnectPtr conn)
+static int vboxStorageClose(virConnectPtr conn)
 {
     VIR_DEBUG("vbox storage uninitialized");
     conn->storagePrivateData = NULL;
     return 0;
 }
 
-int vboxConnectNumOfStoragePools(virConnectPtr conn ATTRIBUTE_UNUSED)
+static int vboxConnectNumOfStoragePools(virConnectPtr conn ATTRIBUTE_UNUSED)
 {
 
     /** Currently only one pool supported, the default one
@@ -8331,8 +8332,8 @@ int vboxConnectNumOfStoragePools(virConnectPtr conn ATTRIBUTE_UNUSED)
     return 1;
 }
 
-int vboxConnectListStoragePools(virConnectPtr conn ATTRIBUTE_UNUSED,
-                                char **const names, int nnames)
+static int vboxConnectListStoragePools(virConnectPtr conn ATTRIBUTE_UNUSED,
+                                       char **const names, int nnames)
 {
     int numActive = 0;
 
@@ -8342,7 +8343,8 @@ int vboxConnectListStoragePools(virConnectPtr conn ATTRIBUTE_UNUSED,
     return numActive;
 }
 
-virStoragePoolPtr vboxStoragePoolLookupByName(virConnectPtr conn, const char *name)
+static virStoragePoolPtr
+vboxStoragePoolLookupByName(virConnectPtr conn, const char *name)
 {
     virStoragePoolPtr ret = NULL;
 
@@ -8362,7 +8364,7 @@ virStoragePoolPtr vboxStoragePoolLookupByName(virConnectPtr conn, const char *na
     return ret;
 }
 
-int vboxStoragePoolNumOfVolumes(virStoragePoolPtr pool)
+static int vboxStoragePoolNumOfVolumes(virStoragePoolPtr pool)
 {
     VBOX_OBJECT_CHECK(pool->conn, int, -1);
     vboxArray hardDisks = VBOX_ARRAY_INITIALIZER;
@@ -8398,7 +8400,8 @@ int vboxStoragePoolNumOfVolumes(virStoragePoolPtr pool)
     return ret;
 }
 
-int vboxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, int nnames)
+static int vboxStoragePoolListVolumes(virStoragePoolPtr pool,
+                                      char **const names, int nnames)
 {
     VBOX_OBJECT_CHECK(pool->conn, int, -1);
     vboxArray hardDisks = VBOX_ARRAY_INITIALIZER;
@@ -8449,7 +8452,8 @@ int vboxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, int n
     return ret;
 }
 
-virStorageVolPtr vboxStorageVolLookupByName(virStoragePoolPtr pool, const char *name)
+static virStorageVolPtr vboxStorageVolLookupByName(virStoragePoolPtr pool,
+                                                   const char *name)
 {
     VBOX_OBJECT_CHECK(pool->conn, virStorageVolPtr, NULL);
     vboxArray hardDisks = VBOX_ARRAY_INITIALIZER;
@@ -8517,7 +8521,8 @@ virStorageVolPtr vboxStorageVolLookupByName(virStoragePoolPtr pool, const char *
     return ret;
 }
 
-virStorageVolPtr vboxStorageVolLookupByKey(virConnectPtr conn, const char *key)
+static virStorageVolPtr
+vboxStorageVolLookupByKey(virConnectPtr conn, const char *key)
 {
     VBOX_OBJECT_CHECK(conn, virStorageVolPtr, NULL);
     vboxIIDUnion hddIID;
@@ -8579,7 +8584,8 @@ virStorageVolPtr vboxStorageVolLookupByKey(virConnectPtr conn, const char *key)
     return ret;
 }
 
-virStorageVolPtr vboxStorageVolLookupByPath(virConnectPtr conn, const char *path)
+static virStorageVolPtr
+vboxStorageVolLookupByPath(virConnectPtr conn, const char *path)
 {
     VBOX_OBJECT_CHECK(conn, virStorageVolPtr, NULL);
     PRUnichar *hddPathUtf16 = NULL;
@@ -8651,7 +8657,7 @@ virStorageVolPtr vboxStorageVolLookupByPath(virConnectPtr conn, const char *path
     return ret;
 }
 
-virStorageVolPtr vboxStorageVolCreateXML(virStoragePoolPtr pool,
+static virStorageVolPtr vboxStorageVolCreateXML(virStoragePoolPtr pool,
                                         const char *xml, unsigned int flags)
 {
     VBOX_OBJECT_CHECK(pool->conn, virStorageVolPtr, NULL);
@@ -8755,7 +8761,7 @@ virStorageVolPtr vboxStorageVolCreateXML(virStoragePoolPtr pool,
     return ret;
 }
 
-int vboxStorageVolDelete(virStorageVolPtr vol, unsigned int flags)
+static int vboxStorageVolDelete(virStorageVolPtr vol, unsigned int flags)
 {
     VBOX_OBJECT_CHECK(vol->conn, int, -1);
     unsigned char uuid[VIR_UUID_BUFLEN];
@@ -8910,7 +8916,8 @@ int vboxStorageVolDelete(virStorageVolPtr vol, unsigned int flags)
     return ret;
 }
 
-int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info)
+static int
+vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info)
 {
     VBOX_OBJECT_CHECK(vol->conn, int, -1);
     IHardDisk *hardDisk  = NULL;
@@ -8961,7 +8968,7 @@ int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info)
     return ret;
 }
 
-char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags)
+static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags)
 {
     VBOX_OBJECT_CHECK(vol->conn, char *, NULL);
     IHardDisk *hardDisk  = NULL;
@@ -9049,7 +9056,7 @@ char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags)
     return ret;
 }
 
-char *vboxStorageVolGetPath(virStorageVolPtr vol)
+static char *vboxStorageVolGetPath(virStorageVolPtr vol)
 {
     VBOX_OBJECT_CHECK(vol->conn, char *, NULL);
     IHardDisk *hardDisk  = NULL;
@@ -9190,6 +9197,26 @@ virNetworkDriver vboxCommonNetworkDriver = {
     .networkGetXMLDesc = vboxNetworkGetXMLDesc, /* 0.6.4 */
 };
 
+virStorageDriver vboxCommonStorageDriver = {
+    .name               = "VBOX",
+    .storageOpen = vboxStorageOpen, /* 0.7.1 */
+    .storageClose = vboxStorageClose, /* 0.7.1 */
+    .connectNumOfStoragePools = vboxConnectNumOfStoragePools, /* 0.7.1 */
+    .connectListStoragePools = vboxConnectListStoragePools, /* 0.7.1 */
+    .storagePoolLookupByName = vboxStoragePoolLookupByName, /* 0.7.1 */
+    .storagePoolNumOfVolumes = vboxStoragePoolNumOfVolumes, /* 0.7.1 */
+    .storagePoolListVolumes = vboxStoragePoolListVolumes, /* 0.7.1 */
+
+    .storageVolLookupByName = vboxStorageVolLookupByName, /* 0.7.1 */
+    .storageVolLookupByKey = vboxStorageVolLookupByKey, /* 0.7.1 */
+    .storageVolLookupByPath = vboxStorageVolLookupByPath, /* 0.7.1 */
+    .storageVolCreateXML = vboxStorageVolCreateXML, /* 0.7.1 */
+    .storageVolDelete = vboxStorageVolDelete, /* 0.7.1 */
+    .storageVolGetInfo = vboxStorageVolGetInfo, /* 0.7.1 */
+    .storageVolGetXMLDesc = vboxStorageVolGetXMLDesc, /* 0.7.1 */
+    .storageVolGetPath = vboxStorageVolGetPath /* 0.7.1 */
+};
+
 static void updateDriver(void)
 {
     /* Update the vboxDriver according to the vboxUniformedAPI.
diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c
index 6c86973..7874e35 100644
--- a/src/vbox/vbox_driver.c
+++ b/src/vbox/vbox_driver.c
@@ -48,19 +48,9 @@
 
 VIR_LOG_INIT("vbox.vbox_driver");
 
-extern virStorageDriver vbox22StorageDriver;
-extern virStorageDriver vbox30StorageDriver;
-extern virStorageDriver vbox31StorageDriver;
-extern virStorageDriver vbox32StorageDriver;
-extern virStorageDriver vbox40StorageDriver;
-extern virStorageDriver vbox41StorageDriver;
-extern virStorageDriver vbox42StorageDriver;
-extern virStorageDriver vbox42_20StorageDriver;
-extern virStorageDriver vbox43StorageDriver;
-extern virStorageDriver vbox43_4StorageDriver;
-
 extern virDriver vboxCommonDriver;
 extern virNetworkDriver vboxCommonNetworkDriver;
+extern virStorageDriver vboxCommonStorageDriver;
 
 static virDriver vboxDriverDummy;
 
@@ -81,7 +71,7 @@ int vboxRegister(void)
      */
     driver        = &vboxDriverDummy;
     networkDriver = &vboxCommonNetworkDriver;
-    storageDriver = &vbox22StorageDriver;
+    storageDriver = &vboxCommonStorageDriver;
 
     /* Init the glue and get the API version. */
     if (VBoxCGlueInit(&uVersion) == 0) {
@@ -91,44 +81,6 @@ int vboxRegister(void)
               uVersion % 1000,
               uVersion);
 
-        /* Select driver implementation based on version.
-         * Note that the VirtualBox development usually happens at build
-         * number 51, thus the version ranges in the if statements below.
-         */
-        if (uVersion >= 2001052 && uVersion < 2002051) {
-            VIR_DEBUG("VirtualBox API version: 2.2");
-            storageDriver = &vbox22StorageDriver;
-        } else if (uVersion >= 2002051 && uVersion < 3000051) {
-            VIR_DEBUG("VirtualBox API version: 3.0");
-            storageDriver = &vbox30StorageDriver;
-        } else if (uVersion >= 3000051 && uVersion < 3001051) {
-            VIR_DEBUG("VirtualBox API version: 3.1");
-            storageDriver = &vbox31StorageDriver;
-        } else if (uVersion >= 3001051 && uVersion < 3002051) {
-            VIR_DEBUG("VirtualBox API version: 3.2");
-            storageDriver = &vbox32StorageDriver;
-        } else if (uVersion >= 3002051 && uVersion < 4000051) {
-            VIR_DEBUG("VirtualBox API version: 4.0");
-            storageDriver = &vbox40StorageDriver;
-        } else if (uVersion >= 4000051 && uVersion < 4001051) {
-            VIR_DEBUG("VirtualBox API version: 4.1");
-            storageDriver = &vbox41StorageDriver;
-        } else if (uVersion >= 4001051 && uVersion < 4002020) {
-            VIR_DEBUG("VirtualBox API version: 4.2");
-            storageDriver = &vbox42StorageDriver;
-        } else if (uVersion >= 4002020 && uVersion < 4002051) {
-           VIR_DEBUG("VirtualBox API version: 4.2.20 or higher");
-           storageDriver  = &vbox42_20StorageDriver;
-        } else if (uVersion >= 4002051 && uVersion < 4003004) {
-            VIR_DEBUG("VirtualBox API version: 4.3");
-            storageDriver = &vbox43StorageDriver;
-        } else if (uVersion >= 4003004 && uVersion < 4003051) {
-            VIR_DEBUG("VirtualBox API version: 4.3.4 or higher");
-            storageDriver = &vbox43_4StorageDriver;
-        } else {
-            VIR_DEBUG("Unsupported VirtualBox API version: %u", uVersion);
-        }
-        /* Register vboxUniformedAPI. */
         if (vboxRegisterUniformedAPI(uVersion) == 0)
             /* Only if successfully register the uniformed api,
              * can we use the vboxCommonDriver. Or use the
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 73a72c7..0bce8c4 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -5116,27 +5116,3 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI)
     pVBoxAPI->networkRemoveInterface = 1;
 #endif /* VBOX_API_VERSION > 2002000 */
 }
-
-/**
- * Function Tables
- */
-
-virStorageDriver NAME(StorageDriver) = {
-    .name               = "VBOX",
-    .storageOpen = vboxStorageOpen, /* 0.7.1 */
-    .storageClose = vboxStorageClose, /* 0.7.1 */
-    .connectNumOfStoragePools = vboxConnectNumOfStoragePools, /* 0.7.1 */
-    .connectListStoragePools = vboxConnectListStoragePools, /* 0.7.1 */
-    .storagePoolLookupByName = vboxStoragePoolLookupByName, /* 0.7.1 */
-    .storagePoolNumOfVolumes = vboxStoragePoolNumOfVolumes, /* 0.7.1 */
-    .storagePoolListVolumes = vboxStoragePoolListVolumes, /* 0.7.1 */
-
-    .storageVolLookupByName = vboxStorageVolLookupByName, /* 0.7.1 */
-    .storageVolLookupByKey = vboxStorageVolLookupByKey, /* 0.7.1 */
-    .storageVolLookupByPath = vboxStorageVolLookupByPath, /* 0.7.1 */
-    .storageVolCreateXML = vboxStorageVolCreateXML, /* 0.7.1 */
-    .storageVolDelete = vboxStorageVolDelete, /* 0.7.1 */
-    .storageVolGetInfo = vboxStorageVolGetInfo, /* 0.7.1 */
-    .storageVolGetXMLDesc = vboxStorageVolGetXMLDesc, /* 0.7.1 */
-    .storageVolGetPath = vboxStorageVolGetPath /* 0.7.1 */
-};
diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h
index 5ec0dee..a638d5c 100644
--- a/src/vbox/vbox_uniformed_api.h
+++ b/src/vbox/vbox_uniformed_api.h
@@ -608,23 +608,6 @@ typedef struct {
 
 virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn,
                                     const unsigned char *uuid);
-virDrvOpenStatus vboxStorageOpen(virConnectPtr conn, virConnectAuthPtr auth,
-                                 unsigned int flags);
-int vboxStorageClose(virConnectPtr conn);
-int vboxConnectNumOfStoragePools(virConnectPtr conn);
-int vboxConnectListStoragePools(virConnectPtr conn, char **const names, int nnames);
-virStoragePoolPtr vboxStoragePoolLookupByName(virConnectPtr conn, const char *name);
-int vboxStoragePoolNumOfVolumes(virStoragePoolPtr pool);
-int vboxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, int nnames);
-virStorageVolPtr vboxStorageVolLookupByName(virStoragePoolPtr pool, const char *name);
-virStorageVolPtr vboxStorageVolLookupByKey(virConnectPtr conn, const char *key);
-virStorageVolPtr vboxStorageVolLookupByPath(virConnectPtr conn, const char *path);
-virStorageVolPtr vboxStorageVolCreateXML(virStoragePoolPtr pool,
-                                         const char *xml, unsigned int flags);
-int vboxStorageVolDelete(virStorageVolPtr vol, unsigned int flags);
-int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info);
-char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags);
-char *vboxStorageVolGetPath(virStorageVolPtr vol);
 
 /* Version specified functions for installing uniformed API */
 void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
-- 
1.7.9.5


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