[PATCHv5 4/4] Install vboxUniformedAPI

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

 



Install vboxUniformedAPI in the new way.
With the prototype:

void vboxRegisterUniformedAPI(uint32_t uVersion);

And leave the install job to the vbox_common.c
---
 src/vbox/vbox_common.c        |   30 ++++++++++++++++++++++++++++++
 src/vbox/vbox_driver.c        |   22 ++++++++++++++++++----
 src/vbox/vbox_uniformed_api.h |    2 ++
 3 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 3f95abb..12b3e33 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -75,6 +75,36 @@ static int openSessionForMachine(vboxGlobalData *data, vboxIIDUnion *iid, const
     return 0;
 }
 
+void vboxRegisterUniformedAPI(uint32_t uVersion)
+{
+    /* Install gVBoxAPI according to the vbox API version.
+     * This function don't check the validation of the
+     * uVersion, it assumes the vboxRegister will do this
+     * job.
+     */
+    if (uVersion >= 2001052 && uVersion < 2002051) {
+        vbox22InstallUniformedAPI(&gVBoxAPI);
+    } else if (uVersion >= 2002051 && uVersion < 3000051) {
+        vbox30InstallUniformedAPI(&gVBoxAPI);
+    } else if (uVersion >= 3000051 && uVersion < 3001051) {
+        vbox31InstallUniformedAPI(&gVBoxAPI);
+    } else if (uVersion >= 3001051 && uVersion < 3002051) {
+        vbox32InstallUniformedAPI(&gVBoxAPI);
+    } else if (uVersion >= 3002051 && uVersion < 4000051) {
+        vbox40InstallUniformedAPI(&gVBoxAPI);
+    } else if (uVersion >= 4000051 && uVersion < 4001051) {
+        vbox41InstallUniformedAPI(&gVBoxAPI);
+    } else if (uVersion >= 4001051 && uVersion < 4002020) {
+        vbox42InstallUniformedAPI(&gVBoxAPI);
+    } else if (uVersion >= 4002020 && uVersion < 4002051) {
+        vbox42_20InstallUniformedAPI(&gVBoxAPI);
+    } else if (uVersion >= 4002051 && uVersion < 4003004) {
+        vbox43InstallUniformedAPI(&gVBoxAPI);
+    } else if (uVersion >= 4003004 && uVersion < 4003051) {
+        vbox43_4InstallUniformedAPI(&gVBoxAPI);
+    }
+}
+
 int vboxInitialize(vboxGlobalData *data)
 {
     if (gVBoxAPI.pfnInitialize(data) != 0)
diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c
index 7d004b2..0b71a5a 100644
--- a/src/vbox/vbox_driver.c
+++ b/src/vbox/vbox_driver.c
@@ -39,6 +39,9 @@
 #include "vbox_glue.h"
 #include "virerror.h"
 #include "virutil.h"
+#include "domain_event.h"
+#include "domain_conf.h"
+#include "vbox_uniformed_api.h"
 
 #define VIR_FROM_THIS VIR_FROM_VBOX
 
@@ -144,10 +147,10 @@ int vboxRegister(void)
             networkDriver = &vbox42NetworkDriver;
             storageDriver = &vbox42StorageDriver;
         } else if (uVersion >= 4002020 && uVersion < 4002051) {
-           VIR_DEBUG("VirtualBox API version: 4.2.20 or higher");
-           driver         = &vbox42_20Driver;
-           networkDriver  = &vbox42_20NetworkDriver;
-           storageDriver  = &vbox42_20StorageDriver;
+            VIR_DEBUG("VirtualBox API version: 4.2.20 or higher");
+            driver         = &vbox42_20Driver;
+            networkDriver  = &vbox42_20NetworkDriver;
+            storageDriver  = &vbox42_20StorageDriver;
         } else if (uVersion >= 4002051 && uVersion < 4003004) {
             VIR_DEBUG("VirtualBox API version: 4.3");
             driver        = &vbox43Driver;
@@ -161,6 +164,17 @@ int vboxRegister(void)
         } else {
             VIR_DEBUG("Unsupported VirtualBox API version: %u", uVersion);
         }
+        /* Register vboxUniformedAPI. The dummy driver will not
+         * use vboxAPI, so the register step is only for validate
+         * vbox API versions.
+         * When the vbox driver is fully redesigned, and there is no
+         * vbox**Driver or vbox**NetworkDriver or vbox**StorageDriver any
+         * more, the registerAPI function will handle all jobs in this
+         * vboxRegister (eg. API version check, return a dummy driver
+         * for unsupported version).
+         * But the current design is a solution for compatibility.
+         */
+        vboxRegisterUniformedAPI(uVersion);
     } else {
         VIR_DEBUG("VBoxCGlueInit failed, using dummy driver");
     }
diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h
index a052a0f..8aede4c 100644
--- a/src/vbox/vbox_uniformed_api.h
+++ b/src/vbox/vbox_uniformed_api.h
@@ -206,4 +206,6 @@ void vbox42_20InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
 void vbox43InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
 void vbox43_4InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
 
+void vboxRegisterUniformedAPI(uint32_t uVersion);
+
 #endif /* VBOX_UNIFORMED_API_H */
-- 
1.7.9.5

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