1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-23 21:34:54 +03:00

vbox: Add support for VirtualBox 4.0

Add vboxArrayGetWithUintArg to handle new signature variations. Also
refactor vboxArrayGet* implementation to use a common helper function.

Deal with the incompatible changes in the VirtualBox 4.0 API. This
includes major changes in virtual machine and storage medium lookup,
in RDP server property handling, in session/lock handling and other
minor areas.

VirtualBox 4.0 also dropped the old event API and replaced it with a
completely new one. This is not fixed yet and will be addressed in
another patch. Therefore, currently the domain events are supported
for VirtualBox 3.x only.

Based on initial work from Jean-Baptiste Rouault.
This commit is contained in:
Matthias Bolte 2010-12-27 23:35:30 +01:00
parent c4ce8333ac
commit 8d2e24d6a8
9 changed files with 7926 additions and 173 deletions

View File

@ -264,7 +264,8 @@ VBOX_DRIVER_SOURCES = \
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_V3_2.c vbox/vbox_CAPI_v3_2.h
vbox/vbox_V3_2.c vbox/vbox_CAPI_v3_2.h \
vbox/vbox_V4_0.c vbox/vbox_CAPI_v4_0.h
VBOX_DRIVER_EXTRA_DIST = \
vbox/vbox_tmpl.c vbox/README \

7451
src/vbox/vbox_CAPI_v4_0.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -660,25 +660,18 @@ VBoxCGlueTerm(void)
*/
typedef HRESULT __stdcall (*SafeArrayGetter)(void *self, SAFEARRAY **array);
typedef HRESULT __stdcall (*SafeArrayGetterWithArg)(void *self, void *arg, SAFEARRAY **array);
typedef HRESULT __stdcall (*SafeArrayGetterWithPtrArg)(void *self, void *arg, SAFEARRAY **array);
typedef HRESULT __stdcall (*SafeArrayGetterWithUintArg)(void *self, PRUint32 arg, SAFEARRAY **array);
/*
* Call the getter with self as first argument and fill the array with the
* returned items.
*/
nsresult
vboxArrayGet(vboxArray *array, void *self, void *getter)
static nsresult
vboxArrayGetHelper(vboxArray *array, HRESULT hrc, SAFEARRAY *safeArray)
{
HRESULT hrc;
SAFEARRAY *safeArray = NULL;
void **items = NULL;
array->items = NULL;
array->count = 0;
array->handle = NULL;
hrc = ((SafeArrayGetter)getter)(self, &safeArray);
if (FAILED(hrc)) {
return hrc;
}
@ -697,39 +690,49 @@ vboxArrayGet(vboxArray *array, void *self, void *getter)
return hrc;
}
/*
* Call the getter with self as first argument and fill the array with the
* returned items.
*/
nsresult
vboxArrayGet(vboxArray *array, void *self, void *getter)
{
HRESULT hrc;
SAFEARRAY *safeArray = NULL;
hrc = ((SafeArrayGetter)getter)(self, &safeArray);
return vboxArrayGetHelper(array, hrc, safeArray);
}
/*
* Call the getter with self as first argument and arg as second argument
* and fill the array with the returned items.
*/
nsresult
vboxArrayGetWithArg(vboxArray *array, void *self, void *getter, void *arg)
vboxArrayGetWithPtrArg(vboxArray *array, void *self, void *getter, void *arg)
{
HRESULT hrc;
SAFEARRAY *safeArray = NULL;
void **items = NULL;
array->items = NULL;
array->count = 0;
array->handle = NULL;
hrc = ((SafeArrayGetterWithPtrArg)getter)(self, arg, &safeArray);
hrc = ((SafeArrayGetterWithArg)getter)(self, arg, &safeArray);
return vboxArrayGetHelper(array, hrc, safeArray);
}
if (FAILED(hrc)) {
return hrc;
}
/*
* Call the getter with self as first argument and arg as second argument
* and fill the array with the returned items.
*/
nsresult
vboxArrayGetWithUintArg(vboxArray *array, void *self, void *getter, PRUint32 arg)
{
HRESULT hrc;
SAFEARRAY *safeArray = NULL;
hrc = SafeArrayAccessData(safeArray, (void **)&items);
hrc = ((SafeArrayGetterWithUintArg)getter)(self, arg, &safeArray);
if (FAILED(hrc)) {
SafeArrayDestroy(safeArray);
return hrc;
}
array->items = items;
array->count = safeArray->rgsabound[0].cElements;
array->handle = safeArray;
return hrc;
return vboxArrayGetHelper(array, hrc, safeArray);
}
/*

View File

@ -41,7 +41,8 @@ struct _vboxArray {
# define VBOX_ARRAY_INITIALIZER { NULL, 0, NULL }
nsresult vboxArrayGet(vboxArray *array, void *self, void *getter);
nsresult vboxArrayGetWithArg(vboxArray *array, void *self, void *getter, void *arg);
nsresult vboxArrayGetWithPtrArg(vboxArray *array, void *self, void *getter, void *arg);
nsresult vboxArrayGetWithUintArg(vboxArray *array, void *self, void *getter, PRUint32 arg);
void vboxArrayRelease(vboxArray *array);
# define vboxArrayUnalloc vboxArrayRelease

13
src/vbox/vbox_V4_0.c Normal file
View File

@ -0,0 +1,13 @@
/** @file vbox_V4_0.c
* C file to include support for multiple versions of VirtualBox
* at runtime.
*/
#include <config.h>
/** The API Version */
#define VBOX_API_VERSION 4000
/** Version specific prefix. */
#define NAME(name) vbox40##name
#include "vbox_tmpl.c"

View File

@ -264,24 +264,15 @@ VBoxCGlueTerm(void)
*/
typedef nsresult (*ArrayGetter)(void *self, PRUint32 *count, void ***items);
typedef nsresult (*ArrayGetterWithArg)(void *self, void *arg, PRUint32 *count, void ***items);
typedef nsresult (*ArrayGetterWithPtrArg)(void *self, void *arg, PRUint32 *count, void ***items);
typedef nsresult (*ArrayGetterWithUintArg)(void *self, PRUint32 arg, PRUint32 *count, void ***items);
/*
* Call the getter with self as first argument and fill the array with the
* returned items.
*/
nsresult
vboxArrayGet(vboxArray *array, void *self, void *getter)
static nsresult
vboxArrayGetHelper(vboxArray *array, nsresult nsrc, void **items, PRUint32 count)
{
nsresult nsrc;
void **items = NULL;
PRUint32 count = 0;
array->items = NULL;
array->count = 0;
nsrc = ((ArrayGetter)getter)(self, &count, &items);
if (NS_FAILED(nsrc)) {
return nsrc;
}
@ -293,29 +284,51 @@ vboxArrayGet(vboxArray *array, void *self, void *getter)
}
/*
* Call the getter with self as first argument and arg as second argument
* and fill the array with the returned items.
* Call the getter with self as first argument and fill the array with the
* returned items.
*/
nsresult
vboxArrayGetWithArg(vboxArray *array, void *self, void *getter, void *arg)
vboxArrayGet(vboxArray *array, void *self, void *getter)
{
nsresult nsrc;
void **items = NULL;
PRUint32 count = 0;
array->items = NULL;
array->count = 0;
nsrc = ((ArrayGetter)getter)(self, &count, &items);
nsrc = ((ArrayGetterWithArg)getter)(self, arg, &count, &items);
return vboxArrayGetHelper(array, nsrc, items, count);
}
if (NS_FAILED(nsrc)) {
return nsrc;
}
/*
* Call the getter with self as first argument and arg as second argument
* and fill the array with the returned items.
*/
nsresult
vboxArrayGetWithPtrArg(vboxArray *array, void *self, void *getter, void *arg)
{
nsresult nsrc;
void **items = NULL;
PRUint32 count = 0;
array->items = items;
array->count = count;
nsrc = ((ArrayGetterWithPtrArg)getter)(self, arg, &count, &items);
return nsrc;
return vboxArrayGetHelper(array, nsrc, items, count);
}
/*
* Call the getter with self as first argument and arg as second argument
* and fill the array with the returned items.
*/
nsresult
vboxArrayGetWithUintArg(vboxArray *array, void *self, void *getter, PRUint32 arg)
{
nsresult nsrc;
void **items = NULL;
PRUint32 count = 0;
nsrc = ((ArrayGetterWithUintArg)getter)(self, arg, &count, &items);
return vboxArrayGetHelper(array, nsrc, items, count);
}
/*
@ -345,7 +358,6 @@ vboxArrayRelease(vboxArray *array)
array->count = 0;
}
/*
* Unalloc all items in the array and reset it.
*/

View File

@ -48,7 +48,8 @@ struct _vboxArray {
# define VBOX_ARRAY_INITIALIZER { NULL, 0 }
nsresult vboxArrayGet(vboxArray *array, void *self, void *getter);
nsresult vboxArrayGetWithArg(vboxArray *array, void *self, void *getter, void *arg);
nsresult vboxArrayGetWithPtrArg(vboxArray *array, void *self, void *getter, void *arg);
nsresult vboxArrayGetWithUintArg(vboxArray *array, void *self, void *getter, PRUint32 arg);
void vboxArrayRelease(vboxArray *array);
void vboxArrayUnalloc(vboxArray *array);

View File

@ -57,6 +57,9 @@ extern virStorageDriver vbox31StorageDriver;
extern virDriver vbox32Driver;
extern virNetworkDriver vbox32NetworkDriver;
extern virStorageDriver vbox32StorageDriver;
extern virDriver vbox40Driver;
extern virNetworkDriver vbox40NetworkDriver;
extern virStorageDriver vbox40StorageDriver;
static virDriver vboxDriverDummy;
@ -114,6 +117,11 @@ int vboxRegister(void) {
driver = &vbox32Driver;
networkDriver = &vbox32NetworkDriver;
storageDriver = &vbox32StorageDriver;
} else if (uVersion >= 3002051 && uVersion < 4000051) {
DEBUG0("VirtualBox API version: 4.0");
driver = &vbox40Driver;
networkDriver = &vbox40NetworkDriver;
storageDriver = &vbox40StorageDriver;
} else {
DEBUG0("Unsupport VirtualBox API version");
}

File diff suppressed because it is too large Load Diff