提交 cdba7c90 编写于 作者: T Taowei 提交者: Michal Privoznik

vbox: Introducing vboxCommonDriver

After this patch, we will have only one common domain driver.
So, the rewritten on domain driver is finished in this patch.
上级 37cf7594
...@@ -37,7 +37,12 @@ The file which has version dependent changes and includes the template ...@@ -37,7 +37,12 @@ The file which has version dependent changes and includes the template
file for given below for all of its functionality. file for given below for all of its functionality.
vbox_tmpl.c vbox_tmpl.c
The file where all the real driver implementation code exists. The file contains all version specified codes. It implements the
vboxUniformedAPI for each vbox version.
vbox_common.c
The file implement the common driver, with the uniformed api which
defined in vbox_uniformed_api.h and implemented in vbox_tmpl.c
Now there would be a vbox_V*.c file (for eg: vbox_V2_2.c for V2.2) for Now there would be a vbox_V*.c file (for eg: vbox_V2_2.c for V2.2) for
each major virtualbox version which would do some preprocessor magic each major virtualbox version which would do some preprocessor magic
......
此差异已折叠。
...@@ -48,37 +48,29 @@ ...@@ -48,37 +48,29 @@
VIR_LOG_INIT("vbox.vbox_driver"); VIR_LOG_INIT("vbox.vbox_driver");
extern virDriver vbox22Driver;
extern virNetworkDriver vbox22NetworkDriver; extern virNetworkDriver vbox22NetworkDriver;
extern virStorageDriver vbox22StorageDriver; extern virStorageDriver vbox22StorageDriver;
extern virDriver vbox30Driver;
extern virNetworkDriver vbox30NetworkDriver; extern virNetworkDriver vbox30NetworkDriver;
extern virStorageDriver vbox30StorageDriver; extern virStorageDriver vbox30StorageDriver;
extern virDriver vbox31Driver;
extern virNetworkDriver vbox31NetworkDriver; extern virNetworkDriver vbox31NetworkDriver;
extern virStorageDriver vbox31StorageDriver; extern virStorageDriver vbox31StorageDriver;
extern virDriver vbox32Driver;
extern virNetworkDriver vbox32NetworkDriver; extern virNetworkDriver vbox32NetworkDriver;
extern virStorageDriver vbox32StorageDriver; extern virStorageDriver vbox32StorageDriver;
extern virDriver vbox40Driver;
extern virNetworkDriver vbox40NetworkDriver; extern virNetworkDriver vbox40NetworkDriver;
extern virStorageDriver vbox40StorageDriver; extern virStorageDriver vbox40StorageDriver;
extern virDriver vbox41Driver;
extern virNetworkDriver vbox41NetworkDriver; extern virNetworkDriver vbox41NetworkDriver;
extern virStorageDriver vbox41StorageDriver; extern virStorageDriver vbox41StorageDriver;
extern virDriver vbox42Driver;
extern virNetworkDriver vbox42NetworkDriver; extern virNetworkDriver vbox42NetworkDriver;
extern virStorageDriver vbox42StorageDriver; extern virStorageDriver vbox42StorageDriver;
extern virDriver vbox42_20Driver;
extern virNetworkDriver vbox42_20NetworkDriver; extern virNetworkDriver vbox42_20NetworkDriver;
extern virStorageDriver vbox42_20StorageDriver; extern virStorageDriver vbox42_20StorageDriver;
extern virDriver vbox43Driver;
extern virNetworkDriver vbox43NetworkDriver; extern virNetworkDriver vbox43NetworkDriver;
extern virStorageDriver vbox43StorageDriver; extern virStorageDriver vbox43StorageDriver;
extern virDriver vbox43_4Driver;
extern virNetworkDriver vbox43_4NetworkDriver; extern virNetworkDriver vbox43_4NetworkDriver;
extern virStorageDriver vbox43_4StorageDriver; extern virStorageDriver vbox43_4StorageDriver;
extern virDriver vboxCommonDriver;
static virDriver vboxDriverDummy; static virDriver vboxDriverDummy;
#define VIR_FROM_THIS VIR_FROM_VBOX #define VIR_FROM_THIS VIR_FROM_VBOX
...@@ -114,59 +106,53 @@ int vboxRegister(void) ...@@ -114,59 +106,53 @@ int vboxRegister(void)
*/ */
if (uVersion >= 2001052 && uVersion < 2002051) { if (uVersion >= 2001052 && uVersion < 2002051) {
VIR_DEBUG("VirtualBox API version: 2.2"); VIR_DEBUG("VirtualBox API version: 2.2");
driver = &vbox22Driver;
networkDriver = &vbox22NetworkDriver; networkDriver = &vbox22NetworkDriver;
storageDriver = &vbox22StorageDriver; storageDriver = &vbox22StorageDriver;
} else if (uVersion >= 2002051 && uVersion < 3000051) { } else if (uVersion >= 2002051 && uVersion < 3000051) {
VIR_DEBUG("VirtualBox API version: 3.0"); VIR_DEBUG("VirtualBox API version: 3.0");
driver = &vbox30Driver;
networkDriver = &vbox30NetworkDriver; networkDriver = &vbox30NetworkDriver;
storageDriver = &vbox30StorageDriver; storageDriver = &vbox30StorageDriver;
} else if (uVersion >= 3000051 && uVersion < 3001051) { } else if (uVersion >= 3000051 && uVersion < 3001051) {
VIR_DEBUG("VirtualBox API version: 3.1"); VIR_DEBUG("VirtualBox API version: 3.1");
driver = &vbox31Driver;
networkDriver = &vbox31NetworkDriver; networkDriver = &vbox31NetworkDriver;
storageDriver = &vbox31StorageDriver; storageDriver = &vbox31StorageDriver;
} else if (uVersion >= 3001051 && uVersion < 3002051) { } else if (uVersion >= 3001051 && uVersion < 3002051) {
VIR_DEBUG("VirtualBox API version: 3.2"); VIR_DEBUG("VirtualBox API version: 3.2");
driver = &vbox32Driver;
networkDriver = &vbox32NetworkDriver; networkDriver = &vbox32NetworkDriver;
storageDriver = &vbox32StorageDriver; storageDriver = &vbox32StorageDriver;
} else if (uVersion >= 3002051 && uVersion < 4000051) { } else if (uVersion >= 3002051 && uVersion < 4000051) {
VIR_DEBUG("VirtualBox API version: 4.0"); VIR_DEBUG("VirtualBox API version: 4.0");
driver = &vbox40Driver;
networkDriver = &vbox40NetworkDriver; networkDriver = &vbox40NetworkDriver;
storageDriver = &vbox40StorageDriver; storageDriver = &vbox40StorageDriver;
} else if (uVersion >= 4000051 && uVersion < 4001051) { } else if (uVersion >= 4000051 && uVersion < 4001051) {
VIR_DEBUG("VirtualBox API version: 4.1"); VIR_DEBUG("VirtualBox API version: 4.1");
driver = &vbox41Driver;
networkDriver = &vbox41NetworkDriver; networkDriver = &vbox41NetworkDriver;
storageDriver = &vbox41StorageDriver; storageDriver = &vbox41StorageDriver;
} else if (uVersion >= 4001051 && uVersion < 4002020) { } else if (uVersion >= 4001051 && uVersion < 4002020) {
VIR_DEBUG("VirtualBox API version: 4.2"); VIR_DEBUG("VirtualBox API version: 4.2");
driver = &vbox42Driver;
networkDriver = &vbox42NetworkDriver; networkDriver = &vbox42NetworkDriver;
storageDriver = &vbox42StorageDriver; storageDriver = &vbox42StorageDriver;
} else if (uVersion >= 4002020 && uVersion < 4002051) { } else if (uVersion >= 4002020 && uVersion < 4002051) {
VIR_DEBUG("VirtualBox API version: 4.2.20 or higher"); VIR_DEBUG("VirtualBox API version: 4.2.20 or higher");
driver = &vbox42_20Driver;
networkDriver = &vbox42_20NetworkDriver; networkDriver = &vbox42_20NetworkDriver;
storageDriver = &vbox42_20StorageDriver; storageDriver = &vbox42_20StorageDriver;
} else if (uVersion >= 4002051 && uVersion < 4003004) { } else if (uVersion >= 4002051 && uVersion < 4003004) {
VIR_DEBUG("VirtualBox API version: 4.3"); VIR_DEBUG("VirtualBox API version: 4.3");
driver = &vbox43Driver;
networkDriver = &vbox43NetworkDriver; networkDriver = &vbox43NetworkDriver;
storageDriver = &vbox43StorageDriver; storageDriver = &vbox43StorageDriver;
} else if (uVersion >= 4003004 && uVersion < 4003051) { } else if (uVersion >= 4003004 && uVersion < 4003051) {
VIR_DEBUG("VirtualBox API version: 4.3.4 or higher"); VIR_DEBUG("VirtualBox API version: 4.3.4 or higher");
driver = &vbox43_4Driver;
networkDriver = &vbox43_4NetworkDriver; networkDriver = &vbox43_4NetworkDriver;
storageDriver = &vbox43_4StorageDriver; storageDriver = &vbox43_4StorageDriver;
} else { } else {
VIR_DEBUG("Unsupported VirtualBox API version: %u", uVersion); VIR_DEBUG("Unsupported VirtualBox API version: %u", uVersion);
} }
/* Register vboxUniformedAPI. */ /* Register vboxUniformedAPI. */
vboxRegisterUniformedAPI(uVersion); 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");
} }
......
...@@ -6478,86 +6478,6 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI) ...@@ -6478,86 +6478,6 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI)
* Function Tables * Function Tables
*/ */
virDriver NAME(Driver) = {
.no = VIR_DRV_VBOX,
.name = "VBOX",
.connectOpen = vboxConnectOpen, /* 0.6.3 */
.connectClose = vboxConnectClose, /* 0.6.3 */
.connectGetVersion = vboxConnectGetVersion, /* 0.6.3 */
.connectGetHostname = vboxConnectGetHostname, /* 0.6.3 */
.connectGetMaxVcpus = vboxConnectGetMaxVcpus, /* 0.6.3 */
.nodeGetInfo = vboxNodeGetInfo, /* 0.6.3 */
.connectGetCapabilities = vboxConnectGetCapabilities, /* 0.6.3 */
.connectListDomains = vboxConnectListDomains, /* 0.6.3 */
.connectNumOfDomains = vboxConnectNumOfDomains, /* 0.6.3 */
.connectListAllDomains = vboxConnectListAllDomains, /* 0.9.13 */
.domainCreateXML = vboxDomainCreateXML, /* 0.6.3 */
.domainLookupByID = vboxDomainLookupByID, /* 0.6.3 */
.domainLookupByUUID = vboxDomainLookupByUUID, /* 0.6.3 */
.domainLookupByName = vboxDomainLookupByName, /* 0.6.3 */
.domainSuspend = vboxDomainSuspend, /* 0.6.3 */
.domainResume = vboxDomainResume, /* 0.6.3 */
.domainShutdown = vboxDomainShutdown, /* 0.6.3 */
.domainShutdownFlags = vboxDomainShutdownFlags, /* 0.9.10 */
.domainReboot = vboxDomainReboot, /* 0.6.3 */
.domainDestroy = vboxDomainDestroy, /* 0.6.3 */
.domainDestroyFlags = vboxDomainDestroyFlags, /* 0.9.4 */
.domainGetOSType = vboxDomainGetOSType, /* 0.6.3 */
.domainSetMemory = vboxDomainSetMemory, /* 0.6.3 */
.domainGetInfo = vboxDomainGetInfo, /* 0.6.3 */
.domainGetState = vboxDomainGetState, /* 0.9.2 */
.domainSave = vboxDomainSave, /* 0.6.3 */
.domainSetVcpus = vboxDomainSetVcpus, /* 0.7.1 */
.domainSetVcpusFlags = vboxDomainSetVcpusFlags, /* 0.8.5 */
.domainGetVcpusFlags = vboxDomainGetVcpusFlags, /* 0.8.5 */
.domainGetMaxVcpus = vboxDomainGetMaxVcpus, /* 0.7.1 */
.domainGetXMLDesc = vboxDomainGetXMLDesc, /* 0.6.3 */
.connectListDefinedDomains = vboxConnectListDefinedDomains, /* 0.6.3 */
.connectNumOfDefinedDomains = vboxConnectNumOfDefinedDomains, /* 0.6.3 */
.domainCreate = vboxDomainCreate, /* 0.6.3 */
.domainCreateWithFlags = vboxDomainCreateWithFlags, /* 0.8.2 */
.domainDefineXML = vboxDomainDefineXML, /* 0.6.3 */
.domainUndefine = vboxDomainUndefine, /* 0.6.3 */
.domainUndefineFlags = vboxDomainUndefineFlags, /* 0.9.5 */
.domainAttachDevice = vboxDomainAttachDevice, /* 0.6.3 */
.domainAttachDeviceFlags = vboxDomainAttachDeviceFlags, /* 0.7.7 */
.domainDetachDevice = vboxDomainDetachDevice, /* 0.6.3 */
.domainDetachDeviceFlags = vboxDomainDetachDeviceFlags, /* 0.7.7 */
.domainUpdateDeviceFlags = vboxDomainUpdateDeviceFlags, /* 0.8.0 */
.nodeGetCellsFreeMemory = vboxNodeGetCellsFreeMemory, /* 0.6.5 */
.nodeGetFreeMemory = vboxNodeGetFreeMemory, /* 0.6.5 */
#if VBOX_API_VERSION >= 4000000
.domainScreenshot = vboxDomainScreenshot, /* 0.9.2 */
#endif
#if VBOX_API_VERSION > 2002000 && VBOX_API_VERSION < 4000000
.connectDomainEventRegister = vboxConnectDomainEventRegister, /* 0.7.0 */
.connectDomainEventDeregister = vboxConnectDomainEventDeregister, /* 0.7.0 */
#endif
.connectIsEncrypted = vboxConnectIsEncrypted, /* 0.7.3 */
.connectIsSecure = vboxConnectIsSecure, /* 0.7.3 */
.domainIsActive = vboxDomainIsActive, /* 0.7.3 */
.domainIsPersistent = vboxDomainIsPersistent, /* 0.7.3 */
.domainIsUpdated = vboxDomainIsUpdated, /* 0.8.6 */
#if VBOX_API_VERSION > 2002000 && VBOX_API_VERSION < 4000000
.connectDomainEventRegisterAny = vboxConnectDomainEventRegisterAny, /* 0.8.0 */
.connectDomainEventDeregisterAny = vboxConnectDomainEventDeregisterAny, /* 0.8.0 */
#endif
.domainSnapshotCreateXML = vboxDomainSnapshotCreateXML, /* 0.8.0 */
.domainSnapshotGetXMLDesc = vboxDomainSnapshotGetXMLDesc, /* 0.8.0 */
.domainSnapshotNum = vboxDomainSnapshotNum, /* 0.8.0 */
.domainSnapshotListNames = vboxDomainSnapshotListNames, /* 0.8.0 */
.domainSnapshotLookupByName = vboxDomainSnapshotLookupByName, /* 0.8.0 */
.domainHasCurrentSnapshot = vboxDomainHasCurrentSnapshot, /* 0.8.0 */
.domainSnapshotGetParent = vboxDomainSnapshotGetParent, /* 0.9.7 */
.domainSnapshotCurrent = vboxDomainSnapshotCurrent, /* 0.8.0 */
.domainSnapshotIsCurrent = vboxDomainSnapshotIsCurrent, /* 0.9.13 */
.domainSnapshotHasMetadata = vboxDomainSnapshotHasMetadata, /* 0.9.13 */
.domainRevertToSnapshot = vboxDomainRevertToSnapshot, /* 0.8.0 */
.domainSnapshotDelete = vboxDomainSnapshotDelete, /* 0.8.0 */
.connectIsAlive = vboxConnectIsAlive, /* 0.9.8 */
.nodeGetFreePages = vboxNodeGetFreePages, /* 1.2.6 */
};
virNetworkDriver NAME(NetworkDriver) = { virNetworkDriver NAME(NetworkDriver) = {
"VBOX", "VBOX",
.networkOpen = vboxNetworkOpen, /* 0.6.4 */ .networkOpen = vboxNetworkOpen, /* 0.6.4 */
......
...@@ -532,111 +532,8 @@ typedef struct { ...@@ -532,111 +532,8 @@ typedef struct {
bool supportScreenshot; bool supportScreenshot;
} vboxUniformedAPI; } vboxUniformedAPI;
/* libvirt API
* These API would be removed after we generate the
* vboxDriver in common code.
*/
virDrvOpenStatus vboxConnectOpen(virConnectPtr conn,
virConnectAuthPtr auth,
unsigned int flags);
int vboxConnectClose(virConnectPtr conn);
int vboxDomainSave(virDomainPtr dom, const char *path);
int vboxConnectGetVersion(virConnectPtr conn, unsigned long *version);
char *vboxConnectGetHostname(virConnectPtr conn);
int vboxConnectIsSecure(virConnectPtr conn);
int vboxConnectIsEncrypted(virConnectPtr conn);
int vboxConnectIsAlive(virConnectPtr conn);
int vboxConnectGetMaxVcpus(virConnectPtr conn, const char *type);
char *vboxConnectGetCapabilities(virConnectPtr conn);
int vboxConnectListDomains(virConnectPtr conn, int *ids, int nids);
int vboxConnectNumOfDomains(virConnectPtr conn);
virDomainPtr vboxDomainLookupByID(virConnectPtr conn, int id);
virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn, virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn,
const unsigned char *uuid); const unsigned char *uuid);
virDomainPtr
vboxDomainLookupByName(virConnectPtr conn, const char *name);
virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml);
int vboxDomainUndefineFlags(virDomainPtr dom, unsigned int flags);
int vboxDomainUndefine(virDomainPtr dom);
int vboxDomainCreateWithFlags(virDomainPtr dom, unsigned int flags);
int vboxDomainCreate(virDomainPtr dom);
virDomainPtr vboxDomainCreateXML(virConnectPtr conn, const char *xml,
unsigned int flags);
int vboxDomainIsActive(virDomainPtr dom);
int vboxDomainIsPersistent(virDomainPtr dom);
int vboxDomainIsUpdated(virDomainPtr dom);
int vboxDomainSuspend(virDomainPtr dom);
int vboxDomainResume(virDomainPtr dom);
int vboxDomainShutdownFlags(virDomainPtr dom, unsigned int flags);
int vboxDomainShutdown(virDomainPtr dom);
int vboxDomainReboot(virDomainPtr dom, unsigned int flags);
int vboxDomainDestroyFlags(virDomainPtr dom, unsigned int flags);
int vboxDomainDestroy(virDomainPtr dom);
char *vboxDomainGetOSType(virDomainPtr dom);
int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory);
int vboxDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info);
int vboxDomainGetState(virDomainPtr dom, int *state,
int *reason, unsigned int flags);
int vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
unsigned int flags);
int vboxDomainSetVcpus(virDomainPtr dom, unsigned int nvcpus);
int vboxDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags);
int vboxDomainGetMaxVcpus(virDomainPtr dom);
char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags);
int vboxConnectListDefinedDomains(virConnectPtr conn,
char ** const names, int maxnames);
int vboxConnectNumOfDefinedDomains(virConnectPtr conn);
int vboxDomainAttachDevice(virDomainPtr dom, const char *xml);
int vboxDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
unsigned int flags);
int vboxDomainUpdateDeviceFlags(virDomainPtr dom, const char *xml,
unsigned int flags);
int vboxDomainDetachDevice(virDomainPtr dom, const char *xml);
int vboxDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
unsigned int flags);
virDomainSnapshotPtr
vboxDomainSnapshotCreateXML(virDomainPtr dom,
const char *xmlDesc,
unsigned int flags);
char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot,
unsigned int flags);
int vboxDomainSnapshotNum(virDomainPtr dom, unsigned int flags);
int vboxDomainSnapshotListNames(virDomainPtr dom, char **names,
int nameslen, unsigned int flags);
virDomainSnapshotPtr
vboxDomainSnapshotLookupByName(virDomainPtr dom, const char *name,
unsigned int flags);
int vboxDomainHasCurrentSnapshot(virDomainPtr dom, unsigned int flags);
virDomainSnapshotPtr
vboxDomainSnapshotGetParent(virDomainSnapshotPtr snapshot,
unsigned int flags);
virDomainSnapshotPtr
vboxDomainSnapshotCurrent(virDomainPtr dom, unsigned int flags);
int vboxDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot,
unsigned int flags);
int vboxDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot,
unsigned int flags);
int vboxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
unsigned int flags);
int vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
unsigned int flags);
char *vboxDomainScreenshot(virDomainPtr dom, virStreamPtr st,
unsigned int screen, unsigned int flags);
int vboxConnectListAllDomains(virConnectPtr conn, virDomainPtr **domains,
unsigned int flags);
int vboxNodeGetInfo(virConnectPtr conn, virNodeInfoPtr nodeinfo);
int vboxNodeGetCellsFreeMemory(virConnectPtr conn,
unsigned long long *freeMems,
int startCell,
int maxCells);
unsigned long long vboxNodeGetFreeMemory(virConnectPtr);
int vboxNodeGetFreePages(virConnectPtr conn,
unsigned int npages,
unsigned int *pages,
int startCell,
unsigned int cellCount,
unsigned long long *counts,
unsigned int flags);
/* Version specified functions for installing uniformed API */ /* Version specified functions for installing uniformed API */
void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI); void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册