diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 4a75b88a11..cb73f97dcd 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -439,3 +439,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 800e7ccf40..c4147a1519 100644 --- a/src/vbox/vbox_common.h +++ b/src/vbox/vbox_common.h @@ -167,5 +167,6 @@ typedef nsISupports ISession; typedef nsISupports IConsole; typedef nsISupports IProgress; typedef nsISupports IMachine; +typedef nsISupports ISystemProperties; #endif /* VBOX_COMMON_H */ diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index af7180945b..954bc5c577 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -914,30 +914,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); @@ -11346,6 +11322,12 @@ _virtualboxGetMachine(IVirtualBox *vboxObj, 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 @@ -11404,6 +11386,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 vboxUniformedPFN _UPFN = { .Initialize = _pfnInitialize, .Uninitialize = _pfnUninitialize, @@ -11431,6 +11419,7 @@ static vboxUniformednsISupports _nsUISupports = { static vboxUniformedIVirtualBox _UIVirtualBox = { .GetVersion = _virtualboxGetVersion, .GetMachine = _virtualboxGetMachine, + .GetSystemProperties = _virtualboxGetSystemProperties, }; static vboxUniformedISession _UISession = { @@ -11448,6 +11437,10 @@ static vboxUniformedIProgress _UIProgress = { .GetResultCode = _progressGetResultCode, }; +static vboxUniformedISystemProperties _UISystemProperties = { + .GetMaxGuestCPUCount = _systemPropertiesGetMaxGuestCPUCount, +}; + void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI) { pVBoxAPI->APIVersion = VBOX_API_VERSION; @@ -11461,6 +11454,7 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI) pVBoxAPI->UISession = _UISession; pVBoxAPI->UIConsole = _UIConsole; pVBoxAPI->UIProgress = _UIProgress; + pVBoxAPI->UISystemProperties = _UISystemProperties; #if VBOX_API_VERSION <= 2002000 || VBOX_API_VERSION >= 4000000 pVBoxAPI->domainEventCallbacks = 0; diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h index 434b8d795f..2cc0674fc6 100644 --- a/src/vbox/vbox_uniformed_api.h +++ b/src/vbox/vbox_uniformed_api.h @@ -171,6 +171,7 @@ typedef struct { typedef struct { nsresult (*GetVersion)(IVirtualBox *vboxObj, PRUnichar **versionUtf16); nsresult (*GetMachine)(IVirtualBox *vboxObj, vboxIIDUnion *iidu, IMachine **machine); + nsresult (*GetSystemProperties)(IVirtualBox *vboxObj, ISystemProperties **systemProperties); } vboxUniformedIVirtualBox; /* Functions for ISession */ @@ -191,6 +192,11 @@ typedef struct { nsresult (*GetResultCode)(IProgress *progress, resultCodeUnion *resultCode); } vboxUniformedIProgress; +/* Functions for ISystemProperties */ +typedef struct { + nsresult (*GetMaxGuestCPUCount)(ISystemProperties *systemProperties, PRUint32 *maxCPUCount); +} vboxUniformedISystemProperties; + typedef struct { /* vbox API version */ uint32_t APIVersion; @@ -205,6 +211,7 @@ typedef struct { vboxUniformedISession UISession; vboxUniformedIConsole UIConsole; vboxUniformedIProgress UIProgress; + vboxUniformedISystemProperties UISystemProperties; /* vbox API features */ bool domainEventCallbacks; bool hasStaticGlobalData; @@ -225,6 +232,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);