]> xenbits.xensource.com Git - libvirt.git/commitdiff
vbox: Add support for version 7.0 SDK
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 18 Jan 2023 14:37:22 +0000 (15:37 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 24 Jan 2023 09:24:23 +0000 (10:24 +0100)
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>
src/vbox/meson.build
src/vbox/vbox_V7_0.c [new file with mode: 0644]
src/vbox/vbox_common.h
src/vbox/vbox_storage.c
src/vbox/vbox_tmpl.c
src/vbox/vbox_uniformed_api.h

index fddf3edf3093117c84fc1ef3d03dbcf914e6d610..1b0dad3336dbe3c8e4e94467172cba0d38f8ffa2 100644 (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',
diff --git a/src/vbox/vbox_V7_0.c b/src/vbox/vbox_V7_0.c
new file mode 100644 (file)
index 0000000..32c0111
--- /dev/null
@@ -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"
index e56e9c0fc20a09d1b17f92ccc438f594de0ef4c2..ec2f9637dc4f44b84e3ebe13c2acd989218c7f4f 100644 (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; \
         } \
index 73d89625535594624421a4fecab98e65308955cb..27d8a474f228c369919f3b4be76d432e8a650ab3 100644 (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;
     }
index cdce7470cf5eadb888161a930b4d688a835d980c..9976867004e3e51cd5743d69d133a3c8dea3080c 100644 (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,7 @@ _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,
@@ -619,7 +626,20 @@ _virtualboxCreateMachine(struct _vboxDriver *data, virDomainDef *def, IMachine *
                                             nsnull,
                                             nsnull,
                                             createFlagsUtf16,
+                                            NULL,
+                                            NULL,
+                                            NULL,
                                             machine);
+#else
+    rc = data->vboxObj->vtbl->CreateMachine(data->vboxObj,
+                                            NULL,
+                                            machineNameUtf16,
+                                            0,
+                                            nsnull,
+                                            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
index 316f0d8b11e2c348c22233cecbd9411ebcd55b15..c1a2af1d425dcc8fe7c92e1ead46a2358888e20a 100644 (file)
@@ -551,3 +551,4 @@ virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn,
 
 /* Version specified functions for installing uniformed API */
 void vbox61InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
+void vbox70InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);