[libvirt PATCH 09/10] vbox: add support for version 6.1 SDK

Daniel P. Berrangé berrange at redhat.com
Fri Apr 17 12:01:34 UTC 2020


Changes in the API:

 - APIs related to the graphics adapter are no longer on the
   IMachine interface, but on a IGraphicsAdapter interface
 - The LaunchVMProcess method takes a list of env variables
   instead of a single variable containing a concatenated
   list. Since we only ever pass a single env variable, we
   can simply stuff it straight into a list.
 - The DHCP server start method no longer needs the network
   name

Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
---
 src/vbox/Makefile.inc.am      |  2 +
 src/vbox/vbox_V6_1.c          | 13 ++++++
 src/vbox/vbox_common.h        |  2 +
 src/vbox/vbox_storage.c       |  2 +
 src/vbox/vbox_tmpl.c          | 87 ++++++++++++++++++++++++++++++++++-
 src/vbox/vbox_uniformed_api.h |  1 +
 6 files changed, 106 insertions(+), 1 deletion(-)
 create mode 100644 src/vbox/vbox_V6_1.c

diff --git a/src/vbox/Makefile.inc.am b/src/vbox/Makefile.inc.am
index fdc6537d51..c5c6d538e7 100644
--- a/src/vbox/Makefile.inc.am
+++ b/src/vbox/Makefile.inc.am
@@ -9,6 +9,8 @@ VBOX_DRIVER_SOURCES = \
 	vbox/vbox_CAPI_v5_2.h \
 	vbox/vbox_CAPI_v6_0.h \
 	vbox/vbox_V6_0.c \
+	vbox/vbox_CAPI_v6_1.h \
+	vbox/vbox_V6_1.c \
 	vbox/vbox_common.c \
 	vbox/vbox_common.h \
 	vbox/vbox_uniformed_api.h \
diff --git a/src/vbox/vbox_V6_1.c b/src/vbox/vbox_V6_1.c
new file mode 100644
index 0000000000..aa4017043b
--- /dev/null
+++ b/src/vbox/vbox_V6_1.c
@@ -0,0 +1,13 @@
+/** @file vbox_V6_1.c
+ * C file to include support for multiple versions of VirtualBox
+ * at runtime.
+ */
+
+#include <config.h>
+
+/** The API Version */
+#define VBOX_API_VERSION 6001000
+/** Version specific prefix. */
+#define NAME(name) vbox61##name
+
+#include "vbox_tmpl.c"
diff --git a/src/vbox/vbox_common.h b/src/vbox/vbox_common.h
index 7c29d92789..6144714477 100644
--- a/src/vbox/vbox_common.h
+++ b/src/vbox/vbox_common.h
@@ -433,6 +433,8 @@ typedef nsISupports IKeyboard;
             vbox52InstallUniformedAPI(&gVBoxAPI); \
         } else if (uVersion >= 6000000 && uVersion < 6000051) { \
             vbox60InstallUniformedAPI(&gVBoxAPI); \
+        } else if (uVersion >= 6000051 && uVersion < 6001051) { \
+            vbox61InstallUniformedAPI(&gVBoxAPI); \
         } else { \
             result = -1; \
         } \
diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c
index 83172ee1fe..ee491fa596 100644
--- a/src/vbox/vbox_storage.c
+++ b/src/vbox/vbox_storage.c
@@ -884,6 +884,8 @@ virStorageDriverPtr vboxGetStorageDriver(uint32_t uVersion)
         vbox52InstallUniformedAPI(&gVBoxAPI);
     } else if (uVersion >= 6000000 && uVersion < 6000051) {
         vbox60InstallUniformedAPI(&gVBoxAPI);
+    } else if (uVersion >= 6000051 && uVersion < 6001051) {
+        vbox61InstallUniformedAPI(&gVBoxAPI);
     } else {
         return NULL;
     }
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 9ac7f88b0f..a1a462cc74 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -53,6 +53,8 @@
 # include "vbox_CAPI_v5_2.h"
 #elif VBOX_API_VERSION == 6000000
 # include "vbox_CAPI_v6_0.h"
+#elif VBOX_API_VERSION == 6001000
+# include "vbox_CAPI_v6_1.h"
 #else
 # error "Unsupported VBOX_API_VERSION"
 #endif
@@ -753,8 +755,14 @@ _machineLaunchVMProcess(vboxDriverPtr data,
                         PRUnichar *sessionType, PRUnichar *env,
                         IProgress **progress)
 {
+#if VBOX_API_VERSION >= 6001000
+    PRUnichar *envlist[] = { env };
+    return machine->vtbl->LaunchVMProcess(machine, data->vboxSession,
+                                          sessionType, 1, envlist, progress);
+#else
     return machine->vtbl->LaunchVMProcess(machine, data->vboxSession,
                                           sessionType, env, progress);
+#endif
 }
 
 static nsresult
@@ -914,51 +922,123 @@ _machineSetBootOrder(IMachine *machine, PRUint32 position, PRUint32 device)
 static nsresult
 _machineGetVRAMSize(IMachine *machine, PRUint32 *VRAMSize)
 {
+#if VBOX_API_VERSION >= 6001000
+    IGraphicsAdapter *ga;
+    nsresult ret;
+    ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
+    if (NS_FAILED(ret))
+        return ret;
+    return ga->vtbl->GetVRAMSize(ga, VRAMSize);
+#else
     return machine->vtbl->GetVRAMSize(machine, VRAMSize);
+#endif
 }
 
 static nsresult
 _machineSetVRAMSize(IMachine *machine, PRUint32 VRAMSize)
 {
+#if VBOX_API_VERSION >= 6001000
+    IGraphicsAdapter *ga;
+    nsresult ret;
+    ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
+    if (NS_FAILED(ret))
+        return ret;
+    return ga->vtbl->SetVRAMSize(ga, VRAMSize);
+#else
     return machine->vtbl->SetVRAMSize(machine, VRAMSize);
+#endif
 }
 
 static nsresult
 _machineGetMonitorCount(IMachine *machine, PRUint32 *monitorCount)
 {
+#if VBOX_API_VERSION >= 6001000
+    IGraphicsAdapter *ga;
+    nsresult ret;
+    ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
+    if (NS_FAILED(ret))
+        return ret;
+    return ga->vtbl->GetMonitorCount(ga, monitorCount);
+#else
     return machine->vtbl->GetMonitorCount(machine, monitorCount);
+#endif
 }
 
 static nsresult
 _machineSetMonitorCount(IMachine *machine, PRUint32 monitorCount)
 {
+#if VBOX_API_VERSION >= 6001000
+    IGraphicsAdapter *ga;
+    nsresult ret;
+    ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
+    if (NS_FAILED(ret))
+        return ret;
+    return ga->vtbl->SetMonitorCount(ga, monitorCount);
+#else
     return machine->vtbl->SetMonitorCount(machine, monitorCount);
+#endif
 }
 
 static nsresult
 _machineGetAccelerate3DEnabled(IMachine *machine, PRBool *accelerate3DEnabled)
 {
+#if VBOX_API_VERSION >= 6001000
+    IGraphicsAdapter *ga;
+    nsresult ret;
+    ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
+    if (NS_FAILED(ret))
+        return ret;
+    return ga->vtbl->GetAccelerate3DEnabled(ga, accelerate3DEnabled);
+#else
     return machine->vtbl->GetAccelerate3DEnabled(machine, accelerate3DEnabled);
+#endif
 }
 
 static nsresult
 _machineSetAccelerate3DEnabled(IMachine *machine, PRBool accelerate3DEnabled)
 {
+#if VBOX_API_VERSION >= 6001000
+    IGraphicsAdapter *ga;
+    nsresult ret;
+    ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
+    if (NS_FAILED(ret))
+        return ret;
+    return ga->vtbl->SetAccelerate3DEnabled(ga, accelerate3DEnabled);
+#else
     return machine->vtbl->SetAccelerate3DEnabled(machine, accelerate3DEnabled);
+#endif
 }
 
 static nsresult
 _machineGetAccelerate2DVideoEnabled(IMachine *machine,
                                     PRBool *accelerate2DVideoEnabled)
 {
+#if VBOX_API_VERSION >= 6001000
+    IGraphicsAdapter *ga;
+    nsresult ret;
+    ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
+    if (NS_FAILED(ret))
+        return ret;
+    return ga->vtbl->GetAccelerate2DVideoEnabled(ga, accelerate2DVideoEnabled);
+#else
     return machine->vtbl->GetAccelerate2DVideoEnabled(machine, accelerate2DVideoEnabled);
+#endif
 }
 
 static nsresult
 _machineSetAccelerate2DVideoEnabled(IMachine *machine,
                                     PRBool accelerate2DVideoEnabled)
 {
+#if VBOX_API_VERSION >= 6001000
+    IGraphicsAdapter *ga;
+    nsresult ret;
+    ret = machine->vtbl->GetGraphicsAdapter(machine, &ga);
+    if (NS_FAILED(ret))
+        return ret;
+    return ga->vtbl->SetAccelerate2DVideoEnabled(ga, accelerate2DVideoEnabled);
+#else
     return machine->vtbl->SetAccelerate2DVideoEnabled(machine, accelerate2DVideoEnabled);
+#endif
 }
 
 static nsresult
@@ -2058,11 +2138,16 @@ _dhcpServerSetConfiguration(IDHCPServer *dhcpServer, PRUnichar *IPAddress,
 }
 
 static nsresult
-_dhcpServerStart(IDHCPServer *dhcpServer, PRUnichar *networkName,
+_dhcpServerStart(IDHCPServer *dhcpServer, PRUnichar *networkName G_GNUC_UNUSED,
                  PRUnichar *trunkName, PRUnichar *trunkType)
 {
+#if VBOX_API_VERSION >= 6001000
+    return dhcpServer->vtbl->Start(dhcpServer,
+                                   trunkName, trunkType);
+#else
     return dhcpServer->vtbl->Start(dhcpServer, networkName,
                                    trunkName, trunkType);
+#endif
 }
 
 static nsresult
diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h
index 9ab3afc4d5..aa508cadca 100644
--- a/src/vbox/vbox_uniformed_api.h
+++ b/src/vbox/vbox_uniformed_api.h
@@ -557,3 +557,4 @@ virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn,
 /* Version specified functions for installing uniformed API */
 void vbox52InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
 void vbox60InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
+void vbox61InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
-- 
2.25.2




More information about the libvir-list mailing list