[PATCH 14/15] vbox: Add support for version 7.0 SDK

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/vbox/meson.build          |  1 +
 src/vbox/vbox_V7_0.c          | 13 +++++++++++++
 src/vbox/vbox_common.h        |  2 ++
 src/vbox/vbox_storage.c       |  2 ++
 src/vbox/vbox_tmpl.c          | 30 ++++++++++++++++++++++++++++++
 src/vbox/vbox_uniformed_api.h |  1 +
 6 files changed, 49 insertions(+)
 create mode 100644 src/vbox/vbox_V7_0.c

diff --git a/src/vbox/meson.build b/src/vbox/meson.build
index fddf3edf30..1b0dad3336 100644
--- a/src/vbox/meson.build
+++ b/src/vbox/meson.build
@@ -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
index 0000000000..32c01111b7
--- /dev/null
+++ b/src/vbox/vbox_V7_0.c
@@ -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"
diff --git a/src/vbox/vbox_common.h b/src/vbox/vbox_common.h
index e56e9c0fc2..ec2f9637dc 100644
--- a/src/vbox/vbox_common.h
+++ b/src/vbox/vbox_common.h
@@ -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; \
         } \
diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c
index 73d8962553..27d8a474f2 100644
--- a/src/vbox/vbox_storage.c
+++ b/src/vbox/vbox_storage.c
@@ -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;
     }
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 3aaa6b4c81..d850fe3fe1 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -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);
     vboxIIDUnalloc(&iid);
@@ -801,7 +821,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
diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h
index 316f0d8b11..c1a2af1d42 100644
--- a/src/vbox/vbox_uniformed_api.h
+++ b/src/vbox/vbox_uniformed_api.h
@@ -551,3 +551,4 @@ virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn,
 
 /* Version specified functions for installing uniformed API */
 void vbox61InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
+void vbox70InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
-- 
2.39.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux