提交 d0bef643 编写于 作者: M Martin Pietsch 提交者: Ján Tomko

Add support for VirtualBox 5

上级 541bd183
......@@ -791,6 +791,7 @@ VBOX_DRIVER_SOURCES = \
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_V5_0.c vbox/vbox_CAPI_v5_0.h \
vbox/vbox_common.c vbox/vbox_common.h \
vbox/vbox_uniformed_api.h \
vbox/vbox_get_driver.h \
......
此差异已折叠。
/** @file vbox_V5_0.c
* C file to include support for multiple versions of VirtualBox
* at runtime.
*/
#include <config.h>
/** The API Version */
#define VBOX_API_VERSION 5000000
/** Version specific prefix. */
#define NAME(name) vbox50##name
#include "vbox_tmpl.c"
......@@ -430,6 +430,8 @@ typedef nsISupports IKeyboard;
vbox43InstallUniformedAPI(&gVBoxAPI); \
} else if (uVersion >= 4003004 && uVersion < 4003051) { \
vbox43_4InstallUniformedAPI(&gVBoxAPI); \
} else if (uVersion >= 4003051 && uVersion < 5000051) { \
vbox50InstallUniformedAPI(&gVBoxAPI); \
} else { \
result = -1; \
} \
......
......@@ -908,6 +908,8 @@ virStorageDriverPtr vboxGetStorageDriver(uint32_t uVersion)
vbox43InstallUniformedAPI(&gVBoxAPI);
} else if (uVersion >= 4003004 && uVersion < 4003051) {
vbox43_4InstallUniformedAPI(&gVBoxAPI);
} else if (uVersion >= 4003051 && uVersion < 5000051) {
vbox50InstallUniformedAPI(&gVBoxAPI);
} else {
return NULL;
}
......
......@@ -69,6 +69,8 @@
# include "vbox_CAPI_v4_3.h"
#elif VBOX_API_VERSION == 4003004
# include "vbox_CAPI_v4_3_4.h"
#elif VBOX_API_VERSION == 5000000
# include "vbox_CAPI_v5_0.h"
#else
# error "Unsupport VBOX_API_VERSION"
#endif
......@@ -1311,7 +1313,9 @@ _vboxDomainSnapshotRestore(virDomainPtr dom,
ISnapshot *snapshot)
{
vboxGlobalData *data = dom->conn->privateData;
# if VBOX_API_VERSION < 5000000
IConsole *console = NULL;
# endif /*VBOX_API_VERSION < 5000000*/
IProgress *progress = NULL;
PRUint32 state;
nsresult rc;
......@@ -1344,8 +1348,10 @@ _vboxDomainSnapshotRestore(virDomainPtr dom,
}
rc = VBOX_SESSION_OPEN(domiid.value, machine);
# if VBOX_API_VERSION < 5000000
if (NS_SUCCEEDED(rc))
rc = data->vboxSession->vtbl->GetConsole(data->vboxSession, &console);
# endif /*VBOX_API_VERSION < 5000000*/
if (NS_FAILED(rc)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("could not open VirtualBox session with domain %s"),
......@@ -1353,7 +1359,12 @@ _vboxDomainSnapshotRestore(virDomainPtr dom,
goto cleanup;
}
# if VBOX_API_VERSION < 5000000
rc = console->vtbl->RestoreSnapshot(console, snapshot, &progress);
# elif VBOX_API_VERSION >= 5000000 /*VBOX_API_VERSION < 5000000*/
rc = machine->vtbl->RestoreSnapshot(machine, snapshot, &progress);
# endif /*VBOX_API_VERSION >= 5000000*/
if (NS_FAILED(rc) || !progress) {
if (rc == VBOX_E_INVALID_VM_STATE) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
......@@ -1378,7 +1389,9 @@ _vboxDomainSnapshotRestore(virDomainPtr dom,
cleanup:
VBOX_RELEASE(progress);
# if VBOX_API_VERSION < 5000000
VBOX_RELEASE(console);
# endif /*VBOX_API_VERSION < 5000000*/
VBOX_SESSION_CLOSE();
vboxIIDUnalloc(&domiid);
return ret;
......@@ -2874,7 +2887,11 @@ _virtualboxCreateHardDisk(IVirtualBox *vboxObj, PRUnichar *format,
/* In vbox 2.2 and 3.0, this function will create a IHardDisk object.
* In vbox 3.1 and later, this function will create a IMedium object.
*/
#if VBOX_API_VERSION < 5000000
return vboxObj->vtbl->CreateHardDisk(vboxObj, format, location, hardDisk);
#elif VBOX_API_VERSION >= 5000000 /*VBOX_API_VERSION >= 5000000*/
return vboxObj->vtbl->CreateMedium(vboxObj, format, location, AccessMode_ReadWrite, DeviceType_HardDisk, hardDisk);
#endif /*VBOX_API_VERSION >= 5000000*/
}
static nsresult
......@@ -3366,7 +3383,23 @@ _sessionGetMachine(ISession *session, IMachine **machine)
static nsresult
_consoleSaveState(IConsole *console, IProgress **progress)
{
#if VBOX_API_VERSION < 5000000
return console->vtbl->SaveState(console, progress);
#else /*VBOX_API_VERSION < 5000000*/
IMachine *machine;
nsresult rc;
rc = console->vtbl->GetMachine(console, &machine);
if (NS_SUCCEEDED(rc))
rc = machine->vtbl->SaveState(machine, progress);
else
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unable to get machine from console. (error %d)"), rc);
return rc;
#endif /*VBOX_API_VERSION >= 5000000*/
}
static nsresult
......@@ -3414,7 +3447,25 @@ static nsresult
_consoleTakeSnapshot(IConsole *console, PRUnichar *name,
PRUnichar *description, IProgress **progress)
{
#if VBOX_API_VERSION < 5000000
return console->vtbl->TakeSnapshot(console, name, description, progress);
#else
IMachine *machine;
nsresult rc;
PRUnichar *id = NULL;
bool bpause = true; /*NO live snapshot*/
rc = console->vtbl->GetMachine(console, &machine);
if (NS_SUCCEEDED(rc))
rc = machine->vtbl->TakeSnapshot(machine, name, description, bpause, &id, progress);
else
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unable to get machine from console. (error %d)"), rc);
VBOX_RELEASE(machine);
return rc;
#endif /* VBOX_API_VERSION >= 5000000 */
}
static nsresult
......@@ -3422,9 +3473,24 @@ _consoleDeleteSnapshot(IConsole *console, vboxIIDUnion *iidu, IProgress **progre
{
#if VBOX_API_VERSION < 3001000
return console->vtbl->DiscardSnapshot(console, IID_MEMBER(value), progress);
#else /* VBOX_API_VERSION >= 3001000 */
#elif VBOX_API_VERSION >= 3001000 && VBOX_API_VERSION < 5000000 /* VBOX_API_VERSION >= 3001000 */
return console->vtbl->DeleteSnapshot(console, IID_MEMBER(value), progress);
#endif /* VBOX_API_VERSION >= 3001000 */
#else /* VBOX_API_VERSION >= 5000000 */
IMachine *machine;
nsresult rc;
rc = console->vtbl->GetMachine(console, &machine);
if (NS_SUCCEEDED(rc))
rc = machine->vtbl->DeleteSnapshot(machine, IID_MEMBER(value), progress);
else
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unable to get machine from console. (error %d)"), rc);
VBOX_RELEASE(machine);
return rc;
#endif /* VBOX_API_VERSION >= 5000000 */
}
static nsresult
......@@ -4342,11 +4408,17 @@ _displayGetScreenResolution(IDisplay *display ATTRIBUTE_UNUSED,
#elif VBOX_API_VERSION < 4003000
return display->vtbl->GetScreenResolution(display, screenId, width,
height, bitsPerPixel);
#else /* VBOX_API_VERSION >= 4003000 */
#elif VBOX_API_VERSION < 5000000 /* VBOX_API_VERSION >= 4003000 */
return display->vtbl->GetScreenResolution(display, screenId, width,
height, bitsPerPixel,
xOrigin, yOrigin);
#endif /* VBOX_API_VERSION >= 4003000 */
#else /*VBOX_API_VERSION >= 5000000 */
PRUint32 gms;
return display->vtbl->GetScreenResolution(display, screenId, width,
height, bitsPerPixel,
xOrigin, yOrigin, &gms);
#endif /* VBOX_API_VERSION >= 5000000 */
}
static nsresult
......@@ -4357,10 +4429,10 @@ _displayTakeScreenShotPNGToArray(IDisplay *display ATTRIBUTE_UNUSED,
PRUint32 *screenDataSize ATTRIBUTE_UNUSED,
PRUint8** screenData ATTRIBUTE_UNUSED)
{
#if VBOX_API_VERSION < 4000000
#if VBOX_API_VERSION < 4000000 || VBOX_API_VERSION >= 5000000
vboxUnsupported();
return 0;
#else /* VBOX_API_VERSION >= 4000000 */
#else /* VBOX_API_VERSION >= 4000000 && VBOX_API_VERSION < 5000000 */
return display->vtbl->TakeScreenShotPNGToArray(display, screenId, width,
height, screenDataSize,
screenData);
......
......@@ -628,5 +628,6 @@ void vbox42InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
void vbox42_20InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
void vbox43InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
void vbox43_4InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
void vbox50InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
#endif /* VBOX_UNIFORMED_API_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册