vbox: Add support for version 7.0 SDK

As advertised in previous commit that added the SDK header file,
there were some changes to the API:

1) IVirtualBox::OpenMachine() and IVirtualBox::CreateMachine()
   now have @password argument to deal with password protected
   settings files. Well, we don't have that wired now (and we
   don't create such files). If we ever want to support user
   settings files that are password protected (e.g. via
   virSecret) we can wire this argument. For now, just pass NULL.

2) IMachine::GetAudioAdapter() is gone. But it can be replaced
   with IMachine::GetAudioSettings() + IMachine::GetAdapter()
   combo.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/419
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Michal Privoznik 2023-01-18 15:37:22 +01:00
parent 3ffb5742cb
commit 106d795faf
6 changed files with 49 additions and 0 deletions

View File

@ -1,5 +1,6 @@
vbox_driver_sources = [
'vbox_V6_1.c',
'vbox_V7_0.c',
'vbox_common.c',
'vbox_driver.c',
'vbox_network.c',

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

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

View File

@ -442,6 +442,8 @@ typedef nsISupports IKeyboard;
result = 0; \
if (uVersion >= 6000051 && uVersion < 6001051) { \
vbox61InstallUniformedAPI(&gVBoxAPI); \
} else if (uVersion >= 7000000 && uVersion < 7001000) { \
vbox70InstallUniformedAPI(&gVBoxAPI); \
} else { \
result = -1; \
} \

View File

@ -883,6 +883,8 @@ virStorageDriver *vboxGetStorageDriver(uint32_t uVersion)
*/
if (uVersion >= 6000051 && uVersion < 6001051) {
vbox61InstallUniformedAPI(&gVBoxAPI);
} else if (uVersion >= 7000000 && uVersion < 7000004) {
vbox70InstallUniformedAPI(&gVBoxAPI);
} else {
return NULL;
}

View File

@ -46,6 +46,8 @@
/* This one changes from version to version. */
#if VBOX_API_VERSION == 6001000
# include "vbox_CAPI_v6_1.h"
#elif VBOX_API_VERSION == 7000000
# include "vbox_CAPI_v7_0.h"
#else
# error "Unsupported VBOX_API_VERSION"
#endif
@ -584,7 +586,11 @@ _virtualboxGetMachine(IVirtualBox *vboxObj, vboxIID *iid, IMachine **machine)
static nsresult
_virtualboxOpenMachine(IVirtualBox *vboxObj, PRUnichar *settingsFile, IMachine **machine)
{
#if VBOX_API_VERSION >= 7000000
return vboxObj->vtbl->OpenMachine(vboxObj, settingsFile, NULL, machine);
#else
return vboxObj->vtbl->OpenMachine(vboxObj, settingsFile, machine);
#endif
}
static nsresult
@ -612,6 +618,19 @@ _virtualboxCreateMachine(struct _vboxDriver *data, virDomainDef *def, IMachine *
vboxIIDFromUUID(&iid, def->uuid);
createFlags = g_strdup_printf("UUID=%s,forceOverwrite=0", uuidstr);
VBOX_UTF8_TO_UTF16(createFlags, &createFlagsUtf16);
#if VBOX_API_VERSION >= 7000000
rc = data->vboxObj->vtbl->CreateMachine(data->vboxObj,
NULL,
machineNameUtf16,
0,
nsnull,
nsnull,
createFlagsUtf16,
NULL,
NULL,
NULL,
machine);
#else
rc = data->vboxObj->vtbl->CreateMachine(data->vboxObj,
NULL,
machineNameUtf16,
@ -620,6 +639,7 @@ _virtualboxCreateMachine(struct _vboxDriver *data, virDomainDef *def, IMachine *
nsnull,
createFlagsUtf16,
machine);
#endif
VIR_FREE(createFlags);
VBOX_UTF16_FREE(machineNameUtf16);
VBOX_UTF16_FREE(createFlagsUtf16);
@ -802,7 +822,17 @@ _machineGetBIOSSettings(IMachine *machine, IBIOSSettings **bios)
static nsresult
_machineGetAudioAdapter(IMachine *machine, IAudioAdapter **audioadapter)
{
#if VBOX_API_VERSION >= 7000000
IAudioSettings *audioSettings = NULL;
nsresult rc;
rc = machine->vtbl->GetAudioSettings(machine, &audioSettings);
if (NS_FAILED(rc))
return rc;
return audioSettings->vtbl->GetAdapter(audioSettings, audioadapter);
#else
return machine->vtbl->GetAudioAdapter(machine, audioadapter);
#endif
}
static nsresult

View File

@ -551,3 +551,4 @@ virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn,
/* Version specified functions for installing uniformed API */
void vbox61InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
void vbox70InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);