VBOX_DRIVER_SOURCES = \
vbox/vbox_glue.c vbox/vbox_glue.h \
vbox/vbox_driver.c vbox/vbox_driver.h \
- vbox/vbox_snapshot_conf.c vbox/vbox_snapshot_conf.h \
+ vbox/vbox_snapshot_conf.c vbox/vbox_snapshot_conf.h \
vbox/vbox_V2_2.c vbox/vbox_CAPI_v2_2.h \
vbox/vbox_V3_0.c vbox/vbox_CAPI_v3_0.h \
vbox/vbox_V3_1.c vbox/vbox_CAPI_v3_1.h \
vbox/vbox_V4_0.c vbox/vbox_CAPI_v4_0.h \
vbox/vbox_V4_1.c vbox/vbox_CAPI_v4_1.h \
vbox/vbox_V4_2.c vbox/vbox_CAPI_v4_2.h \
- vbox/vbox_V4_2_20.c vbox/vbox_CAPI_v4_2_20.h \
+ vbox/vbox_V4_2_20.c vbox/vbox_CAPI_v4_2_20.h \
vbox/vbox_V4_3.c vbox/vbox_CAPI_v4_3.h \
vbox/vbox_V4_3_4.c vbox/vbox_CAPI_v4_3_4.h \
vbox/vbox_common.c vbox/vbox_common.h \
vbox/vbox_uniformed_api.h \
- vbox/vbox_install_api.h
+ vbox/vbox_get_driver.h
VBOX_DRIVER_EXTRA_DIST = \
vbox/vbox_tmpl.c vbox/README \
#include "vbox_common.h"
#include "vbox_uniformed_api.h"
-#include "vbox_install_api.h"
+#include "vbox_get_driver.h"
/* Common codes for vbox driver. With the definitions in vbox_common.h,
* it treats vbox structs as a void*. Though vboxUniformedAPI
/* global vbox API, used for all common codes. */
static vboxUniformedAPI gVBoxAPI;
-/* update the virDriver according to the vboxUniformedAPI */
-static void updateDriver(void);
-
-int vboxRegisterUniformedAPI(uint32_t uVersion)
-{
- /* Install gVBoxAPI according to the vbox API version.
- * Return -1 for unsupported version.
- */
- 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);
- } else {
- return -1;
- }
- updateDriver();
- return 0;
-}
-
static int openSessionForMachine(vboxGlobalData *data, const unsigned char *dom_uuid, vboxIIDUnion *iid,
IMachine **machine, bool checkflag)
{
else
vboxCommonDriver.domainScreenshot = NULL;
}
+
+virDriverPtr vboxGetDriver(uint32_t uVersion)
+{
+ /* Install gVBoxAPI according to the vbox API version.
+ * Return -1 for unsupported version.
+ */
+ 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);
+ } else {
+ return NULL;
+ }
+ updateDriver();
+ return &vboxCommonDriver;
+}
#include "domain_event.h"
#include "domain_conf.h"
-#include "vbox_install_api.h"
+#include "vbox_get_driver.h"
#define VIR_FROM_THIS VIR_FROM_VBOX
extern virNetworkDriver vbox43_4NetworkDriver;
extern virStorageDriver vbox43_4StorageDriver;
-extern virDriver vboxCommonDriver;
-
-static virDriver vboxDriverDummy;
-
#define VIR_FROM_THIS VIR_FROM_VBOX
+#if !defined(WITH_DRIVER_MODULES) || defined(VBOX_NETWORK_DRIVER) || defined(VBOX_STORAGE_DRIVER)
static void
vboxGetDrivers(virDriverPtr *driver_ret,
virNetworkDriverPtr *networkDriver_ret,
virStorageDriverPtr *storageDriver_ret)
{
- virDriverPtr driver;
virNetworkDriverPtr networkDriver;
virStorageDriverPtr storageDriver;
uint32_t uVersion;
* if the user requests a vbox:// URI which we know will
* never work
*/
- driver = &vboxDriverDummy;
networkDriver = &vbox22NetworkDriver;
storageDriver = &vbox22StorageDriver;
} 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
- * vboxDriverDummy in case of failure. */
- driver = &vboxCommonDriver;
} else {
VIR_DEBUG("VBoxCGlueInit failed, using dummy driver");
}
if (driver_ret)
- *driver_ret = driver;
+ *driver_ret = NULL;
if (networkDriver_ret)
*networkDriver_ret = networkDriver;
if (storageDriver_ret)
*storageDriver_ret = storageDriver;
}
-
+#endif
#if !defined(WITH_DRIVER_MODULES) || defined(VBOX_NETWORK_DRIVER)
int vboxNetworkRegister(void)
#endif
#if !defined(WITH_DRIVER_MODULES) || defined(VBOX_DRIVER)
-int vboxRegister(void)
-{
- virDriverPtr driver;
-
- vboxGetDrivers(&driver, NULL, NULL);
-
- if (virRegisterDriver(driver) < 0)
- return -1;
- return 0;
-}
-#endif
-
static virDrvOpenStatus dummyConnectOpen(virConnectPtr conn,
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
unsigned int flags)
"VBOX",
.connectOpen = dummyConnectOpen, /* 0.6.3 */
};
+
+int vboxRegister(void)
+{
+ virDriverPtr driver = NULL;
+ uint32_t uVersion;
+
+ if (VBoxCGlueInit(&uVersion) == 0)
+ driver = vboxGetDriver(uVersion);
+
+ if (!driver)
+ driver = &vboxDriverDummy;
+
+ if (virRegisterDriver(driver) < 0)
+ return -1;
+ return 0;
+}
+#endif
--- /dev/null
+/*
+ * Copyright 2014, Taowei Luo (uaedante@gmail.com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef VBOX_GET_DRIVER_H
+# define VBOX_GET_DRIVER_H
+
+# include "internal.h"
+
+virDriverPtr vboxGetDriver(uint32_t uVersion);
+
+#endif /* VBOX_GET_DRIVER_H */
+++ /dev/null
-/*
- * Copyright 2014, Taowei Luo (uaedante@gmail.com)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library. If not, see
- * <http://www.gnu.org/licenses/>.
- */
-
-#ifndef VBOX_INSTALL_API_H
-# define VBOX_INSTALL_API_H
-
-# include "internal.h"
-
-int vboxRegisterUniformedAPI(uint32_t uVersion);
-
-#endif /* VBOX_INSTALL_API_H */