---
src/vbox/vbox_common.c | 24 +++++++++++++++++++++++
src/vbox/vbox_common.h | 1 +
src/vbox/vbox_tmpl.c | 42 ++++++++++++++++++-----------------------
src/vbox/vbox_uniformed_api.h | 8 ++++++++
4 files changed, 51 insertions(+), 24 deletions(-)
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index f380c78..1c67eea 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -437,3 +437,27 @@ int vboxConnectIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
{
return 1;
}
+
+int
+vboxConnectGetMaxVcpus(virConnectPtr conn, const char *type ATTRIBUTE_UNUSED)
+{
+ VBOX_OBJECT_CHECK(conn, int, -1);
+ PRUint32 maxCPUCount = 0;
+
+ /* VirtualBox Supports only hvm and thus the type passed to it
+ * has no meaning, setting it to ATTRIBUTE_UNUSED
+ */
+ ISystemProperties *systemProperties = NULL;
+
+ gVBoxAPI.UIVirtualBox.GetSystemProperties(data->vboxObj, &systemProperties);
+ if (!systemProperties)
+ goto cleanup;
+ gVBoxAPI.UISystemProperties.GetMaxGuestCPUCount(systemProperties, &maxCPUCount);
+
+ if (maxCPUCount > 0)
+ ret = maxCPUCount;
+
+ cleanup:
+ VBOX_RELEASE(systemProperties);
+ return ret;
+}
diff --git a/src/vbox/vbox_common.h b/src/vbox/vbox_common.h
index aa6be11..e01fa51 100644
--- a/src/vbox/vbox_common.h
+++ b/src/vbox/vbox_common.h
@@ -166,6 +166,7 @@ typedef void ISession;
typedef void IConsole;
typedef void IProgress;
typedef void IMachine;
+typedef void ISystemProperties;
typedef void IVirtualBoxCallback;
typedef void nsIEventQueue;
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index e08d7cc..e17b06f 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -911,30 +911,6 @@ vboxSocketParseAddrUtf16(vboxGlobalData *data, const PRUnichar
*utf16,
return result;
}
-static int
-vboxConnectGetMaxVcpus(virConnectPtr conn, const char *type ATTRIBUTE_UNUSED)
-{
- VBOX_OBJECT_CHECK(conn, int, -1);
- PRUint32 maxCPUCount = 0;
-
- /* VirtualBox Supports only hvm and thus the type passed to it
- * has no meaning, setting it to ATTRIBUTE_UNUSED
- */
- ISystemProperties *systemProperties = NULL;
-
- data->vboxObj->vtbl->GetSystemProperties(data->vboxObj,
&systemProperties);
- if (systemProperties) {
- systemProperties->vtbl->GetMaxGuestCPUCount(systemProperties,
&maxCPUCount);
- VBOX_RELEASE(systemProperties);
- }
-
- if (maxCPUCount > 0)
- ret = maxCPUCount;
-
- return ret;
-}
-
-
static char *vboxConnectGetCapabilities(virConnectPtr conn) {
VBOX_OBJECT_CHECK(conn, char *, NULL);
@@ -11340,6 +11316,12 @@ _virtualboxGetMachine(vboxGlobalData *data, vboxIIDUnion *iidu,
IMachine **machi
#endif /* VBOX_API_VERSION >= 4000000 */
+static nsresult
+_virtualboxGetSystemProperties(IVirtualBox *vboxObj, ISystemProperties
**systemProperties)
+{
+ return vboxObj->vtbl->GetSystemProperties(vboxObj, systemProperties);
+}
+
#if VBOX_API_VERSION < 4000000
static nsresult
@@ -11398,6 +11380,12 @@ _progressGetResultCode(IProgress *progress, resultCodeUnion
*resultCode)
#endif /* VBOX_API_VERSION != 2002000 */
}
+static nsresult
+_systemPropertiesGetMaxGuestCPUCount(ISystemProperties *systemProperties, PRUint32
*maxCPUCount)
+{
+ return systemProperties->vtbl->GetMaxGuestCPUCount(systemProperties,
maxCPUCount);
+}
+
static nsresult _nsisupportsRelease(void *Ihandle)
{
/* It is safety to convert a pointer from IVirtual(or structs
@@ -11429,6 +11417,7 @@ static vboxUniformedIID _UIID = {
static vboxUniformedIVirtualBox _UIVirtualBox = {
.GetVersion = _virtualboxGetVersion,
.GetMachine = _virtualboxGetMachine,
+ .GetSystemProperties = _virtualboxGetSystemProperties,
};
static vboxUniformedISession _UISession = {
@@ -11446,6 +11435,10 @@ static vboxUniformedIProgress _UIProgress = {
.GetResultCode = _progressGetResultCode,
};
+static vboxUniformedISystemProperties _UISystemProperties = {
+ .GetMaxGuestCPUCount = _systemPropertiesGetMaxGuestCPUCount,
+};
+
static vboxUniformednsISupports _nsUISupports = {
.Release = _nsisupportsRelease,
};
@@ -11462,6 +11455,7 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI)
pVBoxAPI->UISession = _UISession;
pVBoxAPI->UIConsole = _UIConsole;
pVBoxAPI->UIProgress = _UIProgress;
+ pVBoxAPI->UISystemProperties = _UISystemProperties;
pVBoxAPI->nsUISupports = _nsUISupports;
#if (VBOX_XPCOMC_VERSION == 0x00010000U) || (VBOX_API_VERSION == 2002000)
diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h
index e586c3c..4bd0cf7 100644
--- a/src/vbox/vbox_uniformed_api.h
+++ b/src/vbox/vbox_uniformed_api.h
@@ -163,6 +163,7 @@ typedef struct {
typedef struct {
nsresult (*GetVersion)(IVirtualBox *vboxObj, PRUnichar **versionUtf16);
nsresult (*GetMachine)(vboxGlobalData *data, vboxIIDUnion *iidu, IMachine
**machine);
+ nsresult (*GetSystemProperties)(IVirtualBox *vboxObj, ISystemProperties
**systemProperties);
} vboxUniformedIVirtualBox;
/* Functions for ISession */
@@ -183,6 +184,11 @@ typedef struct {
nsresult (*GetResultCode)(IProgress *progress, resultCodeUnion *resultCode);
} vboxUniformedIProgress;
+/* Functions for ISystemProperties */
+typedef struct {
+ nsresult (*GetMaxGuestCPUCount)(ISystemProperties *systemProperties, PRUint32
*maxCPUCount);
+} vboxUniformedISystemProperties;
+
/* Functions for nsISupports */
typedef struct {
nsresult (*Release)(void *Ihandle);
@@ -201,6 +207,7 @@ typedef struct {
vboxUniformedISession UISession;
vboxUniformedIConsole UIConsole;
vboxUniformedIProgress UIProgress;
+ vboxUniformedISystemProperties UISystemProperties;
vboxUniformednsISupports nsUISupports;
/* vbox API features */
bool fWatchNeedInitialize;
@@ -222,6 +229,7 @@ char *vboxConnectGetHostname(virConnectPtr conn);
int vboxConnectIsSecure(virConnectPtr conn);
int vboxConnectIsEncrypted(virConnectPtr conn);
int vboxConnectIsAlive(virConnectPtr conn);
+int vboxConnectGetMaxVcpus(virConnectPtr conn, const char *type);
/* Version specified functions for installing uniformed API */
void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
--
1.7.9.5