mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-11-08 14:29:56 +00:00
vbox: Interfaces for register per parties
The patch dbb4cbf532
by Michal has splited the vbox driver into
three parties. This modification brings a more suitable interface
to the previous patch.
The new function vboxGetDriver is introduced to get the
corresponding vbox domain driver directly thought the vbox version.
Functions like vboxGetNetworkDriver and vboxGetStorageDriver
will be introduced after rewriting it's drivers.
This patch, by the way, fixed the align problem for vbox in
Makefile.am
This commit is contained in:
parent
e3a7b8740f
commit
fac5d061ed
@ -679,7 +679,7 @@ VBOX_DRIVER_SOURCES = \
|
|||||||
vbox/vbox_V4_3_4.c vbox/vbox_CAPI_v4_3_4.h \
|
vbox/vbox_V4_3_4.c vbox/vbox_CAPI_v4_3_4.h \
|
||||||
vbox/vbox_common.c vbox/vbox_common.h \
|
vbox/vbox_common.c vbox/vbox_common.h \
|
||||||
vbox/vbox_uniformed_api.h \
|
vbox/vbox_uniformed_api.h \
|
||||||
vbox/vbox_install_api.h
|
vbox/vbox_get_driver.h
|
||||||
|
|
||||||
VBOX_DRIVER_EXTRA_DIST = \
|
VBOX_DRIVER_EXTRA_DIST = \
|
||||||
vbox/vbox_tmpl.c vbox/README \
|
vbox/vbox_tmpl.c vbox/README \
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
#include "vbox_common.h"
|
#include "vbox_common.h"
|
||||||
#include "vbox_uniformed_api.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,
|
/* Common codes for vbox driver. With the definitions in vbox_common.h,
|
||||||
* it treats vbox structs as a void*. Though vboxUniformedAPI
|
* it treats vbox structs as a void*. Though vboxUniformedAPI
|
||||||
@ -121,41 +121,6 @@ if (!data->vboxObj) {\
|
|||||||
/* global vbox API, used for all common codes. */
|
/* global vbox API, used for all common codes. */
|
||||||
static vboxUniformedAPI gVBoxAPI;
|
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,
|
static int openSessionForMachine(vboxGlobalData *data, const unsigned char *dom_uuid, vboxIIDUnion *iid,
|
||||||
IMachine **machine, bool checkflag)
|
IMachine **machine, bool checkflag)
|
||||||
{
|
{
|
||||||
@ -7565,3 +7530,35 @@ static void updateDriver(void)
|
|||||||
else
|
else
|
||||||
vboxCommonDriver.domainScreenshot = NULL;
|
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;
|
||||||
|
}
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
#include "domain_event.h"
|
#include "domain_event.h"
|
||||||
#include "domain_conf.h"
|
#include "domain_conf.h"
|
||||||
|
|
||||||
#include "vbox_install_api.h"
|
#include "vbox_get_driver.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_VBOX
|
#define VIR_FROM_THIS VIR_FROM_VBOX
|
||||||
|
|
||||||
@ -69,18 +69,14 @@ extern virStorageDriver vbox43StorageDriver;
|
|||||||
extern virNetworkDriver vbox43_4NetworkDriver;
|
extern virNetworkDriver vbox43_4NetworkDriver;
|
||||||
extern virStorageDriver vbox43_4StorageDriver;
|
extern virStorageDriver vbox43_4StorageDriver;
|
||||||
|
|
||||||
extern virDriver vboxCommonDriver;
|
|
||||||
|
|
||||||
static virDriver vboxDriverDummy;
|
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_VBOX
|
#define VIR_FROM_THIS VIR_FROM_VBOX
|
||||||
|
|
||||||
|
#if !defined(WITH_DRIVER_MODULES) || defined(VBOX_NETWORK_DRIVER) || defined(VBOX_STORAGE_DRIVER)
|
||||||
static void
|
static void
|
||||||
vboxGetDrivers(virDriverPtr *driver_ret,
|
vboxGetDrivers(virDriverPtr *driver_ret,
|
||||||
virNetworkDriverPtr *networkDriver_ret,
|
virNetworkDriverPtr *networkDriver_ret,
|
||||||
virStorageDriverPtr *storageDriver_ret)
|
virStorageDriverPtr *storageDriver_ret)
|
||||||
{
|
{
|
||||||
virDriverPtr driver;
|
|
||||||
virNetworkDriverPtr networkDriver;
|
virNetworkDriverPtr networkDriver;
|
||||||
virStorageDriverPtr storageDriver;
|
virStorageDriverPtr storageDriver;
|
||||||
uint32_t uVersion;
|
uint32_t uVersion;
|
||||||
@ -91,7 +87,6 @@ vboxGetDrivers(virDriverPtr *driver_ret,
|
|||||||
* if the user requests a vbox:// URI which we know will
|
* if the user requests a vbox:// URI which we know will
|
||||||
* never work
|
* never work
|
||||||
*/
|
*/
|
||||||
driver = &vboxDriverDummy;
|
|
||||||
networkDriver = &vbox22NetworkDriver;
|
networkDriver = &vbox22NetworkDriver;
|
||||||
storageDriver = &vbox22StorageDriver;
|
storageDriver = &vbox22StorageDriver;
|
||||||
|
|
||||||
@ -150,24 +145,18 @@ vboxGetDrivers(virDriverPtr *driver_ret,
|
|||||||
} else {
|
} else {
|
||||||
VIR_DEBUG("Unsupported VirtualBox API version: %u", uVersion);
|
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 {
|
} else {
|
||||||
VIR_DEBUG("VBoxCGlueInit failed, using dummy driver");
|
VIR_DEBUG("VBoxCGlueInit failed, using dummy driver");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (driver_ret)
|
if (driver_ret)
|
||||||
*driver_ret = driver;
|
*driver_ret = NULL;
|
||||||
if (networkDriver_ret)
|
if (networkDriver_ret)
|
||||||
*networkDriver_ret = networkDriver;
|
*networkDriver_ret = networkDriver;
|
||||||
if (storageDriver_ret)
|
if (storageDriver_ret)
|
||||||
*storageDriver_ret = storageDriver;
|
*storageDriver_ret = storageDriver;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(WITH_DRIVER_MODULES) || defined(VBOX_NETWORK_DRIVER)
|
#if !defined(WITH_DRIVER_MODULES) || defined(VBOX_NETWORK_DRIVER)
|
||||||
int vboxNetworkRegister(void)
|
int vboxNetworkRegister(void)
|
||||||
@ -195,18 +184,6 @@ int vboxStorageRegister(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(WITH_DRIVER_MODULES) || defined(VBOX_DRIVER)
|
#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,
|
static virDrvOpenStatus dummyConnectOpen(virConnectPtr conn,
|
||||||
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
@ -252,3 +229,20 @@ static virDriver vboxDriverDummy = {
|
|||||||
"VBOX",
|
"VBOX",
|
||||||
.connectOpen = dummyConnectOpen, /* 0.6.3 */
|
.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
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
* <http://www.gnu.org/licenses/>.
|
* <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef VBOX_INSTALL_API_H
|
#ifndef VBOX_GET_DRIVER_H
|
||||||
# define VBOX_INSTALL_API_H
|
# define VBOX_GET_DRIVER_H
|
||||||
|
|
||||||
# include "internal.h"
|
# include "internal.h"
|
||||||
|
|
||||||
int vboxRegisterUniformedAPI(uint32_t uVersion);
|
virDriverPtr vboxGetDriver(uint32_t uVersion);
|
||||||
|
|
||||||
#endif /* VBOX_INSTALL_API_H */
|
#endif /* VBOX_GET_DRIVER_H */
|
Loading…
Reference in New Issue
Block a user