mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
vbox: Rewrite vboxConnectGetMaxVcpus
This commit is contained in:
parent
427931ae0c
commit
82513be8ba
@ -439,3 +439,27 @@ int vboxConnectIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
|
|||||||
{
|
{
|
||||||
return 1;
|
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;
|
||||||
|
}
|
||||||
|
@ -167,5 +167,6 @@ typedef nsISupports ISession;
|
|||||||
typedef nsISupports IConsole;
|
typedef nsISupports IConsole;
|
||||||
typedef nsISupports IProgress;
|
typedef nsISupports IProgress;
|
||||||
typedef nsISupports IMachine;
|
typedef nsISupports IMachine;
|
||||||
|
typedef nsISupports ISystemProperties;
|
||||||
|
|
||||||
#endif /* VBOX_COMMON_H */
|
#endif /* VBOX_COMMON_H */
|
||||||
|
@ -914,30 +914,6 @@ vboxSocketParseAddrUtf16(vboxGlobalData *data, const PRUnichar *utf16,
|
|||||||
return result;
|
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) {
|
static char *vboxConnectGetCapabilities(virConnectPtr conn) {
|
||||||
VBOX_OBJECT_CHECK(conn, char *, NULL);
|
VBOX_OBJECT_CHECK(conn, char *, NULL);
|
||||||
|
|
||||||
@ -11346,6 +11322,12 @@ _virtualboxGetMachine(IVirtualBox *vboxObj, vboxIIDUnion *iidu, IMachine **machi
|
|||||||
|
|
||||||
#endif /* VBOX_API_VERSION >= 4000000 */
|
#endif /* VBOX_API_VERSION >= 4000000 */
|
||||||
|
|
||||||
|
static nsresult
|
||||||
|
_virtualboxGetSystemProperties(IVirtualBox *vboxObj, ISystemProperties **systemProperties)
|
||||||
|
{
|
||||||
|
return vboxObj->vtbl->GetSystemProperties(vboxObj, systemProperties);
|
||||||
|
}
|
||||||
|
|
||||||
#if VBOX_API_VERSION < 4000000
|
#if VBOX_API_VERSION < 4000000
|
||||||
|
|
||||||
static nsresult
|
static nsresult
|
||||||
@ -11404,6 +11386,12 @@ _progressGetResultCode(IProgress *progress, resultCodeUnion *resultCode)
|
|||||||
#endif /* VBOX_API_VERSION != 2002000 */
|
#endif /* VBOX_API_VERSION != 2002000 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static nsresult
|
||||||
|
_systemPropertiesGetMaxGuestCPUCount(ISystemProperties *systemProperties, PRUint32 *maxCPUCount)
|
||||||
|
{
|
||||||
|
return systemProperties->vtbl->GetMaxGuestCPUCount(systemProperties, maxCPUCount);
|
||||||
|
}
|
||||||
|
|
||||||
static vboxUniformedPFN _UPFN = {
|
static vboxUniformedPFN _UPFN = {
|
||||||
.Initialize = _pfnInitialize,
|
.Initialize = _pfnInitialize,
|
||||||
.Uninitialize = _pfnUninitialize,
|
.Uninitialize = _pfnUninitialize,
|
||||||
@ -11431,6 +11419,7 @@ static vboxUniformednsISupports _nsUISupports = {
|
|||||||
static vboxUniformedIVirtualBox _UIVirtualBox = {
|
static vboxUniformedIVirtualBox _UIVirtualBox = {
|
||||||
.GetVersion = _virtualboxGetVersion,
|
.GetVersion = _virtualboxGetVersion,
|
||||||
.GetMachine = _virtualboxGetMachine,
|
.GetMachine = _virtualboxGetMachine,
|
||||||
|
.GetSystemProperties = _virtualboxGetSystemProperties,
|
||||||
};
|
};
|
||||||
|
|
||||||
static vboxUniformedISession _UISession = {
|
static vboxUniformedISession _UISession = {
|
||||||
@ -11448,6 +11437,10 @@ static vboxUniformedIProgress _UIProgress = {
|
|||||||
.GetResultCode = _progressGetResultCode,
|
.GetResultCode = _progressGetResultCode,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static vboxUniformedISystemProperties _UISystemProperties = {
|
||||||
|
.GetMaxGuestCPUCount = _systemPropertiesGetMaxGuestCPUCount,
|
||||||
|
};
|
||||||
|
|
||||||
void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI)
|
void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI)
|
||||||
{
|
{
|
||||||
pVBoxAPI->APIVersion = VBOX_API_VERSION;
|
pVBoxAPI->APIVersion = VBOX_API_VERSION;
|
||||||
@ -11461,6 +11454,7 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI)
|
|||||||
pVBoxAPI->UISession = _UISession;
|
pVBoxAPI->UISession = _UISession;
|
||||||
pVBoxAPI->UIConsole = _UIConsole;
|
pVBoxAPI->UIConsole = _UIConsole;
|
||||||
pVBoxAPI->UIProgress = _UIProgress;
|
pVBoxAPI->UIProgress = _UIProgress;
|
||||||
|
pVBoxAPI->UISystemProperties = _UISystemProperties;
|
||||||
|
|
||||||
#if VBOX_API_VERSION <= 2002000 || VBOX_API_VERSION >= 4000000
|
#if VBOX_API_VERSION <= 2002000 || VBOX_API_VERSION >= 4000000
|
||||||
pVBoxAPI->domainEventCallbacks = 0;
|
pVBoxAPI->domainEventCallbacks = 0;
|
||||||
|
@ -171,6 +171,7 @@ typedef struct {
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
nsresult (*GetVersion)(IVirtualBox *vboxObj, PRUnichar **versionUtf16);
|
nsresult (*GetVersion)(IVirtualBox *vboxObj, PRUnichar **versionUtf16);
|
||||||
nsresult (*GetMachine)(IVirtualBox *vboxObj, vboxIIDUnion *iidu, IMachine **machine);
|
nsresult (*GetMachine)(IVirtualBox *vboxObj, vboxIIDUnion *iidu, IMachine **machine);
|
||||||
|
nsresult (*GetSystemProperties)(IVirtualBox *vboxObj, ISystemProperties **systemProperties);
|
||||||
} vboxUniformedIVirtualBox;
|
} vboxUniformedIVirtualBox;
|
||||||
|
|
||||||
/* Functions for ISession */
|
/* Functions for ISession */
|
||||||
@ -191,6 +192,11 @@ typedef struct {
|
|||||||
nsresult (*GetResultCode)(IProgress *progress, resultCodeUnion *resultCode);
|
nsresult (*GetResultCode)(IProgress *progress, resultCodeUnion *resultCode);
|
||||||
} vboxUniformedIProgress;
|
} vboxUniformedIProgress;
|
||||||
|
|
||||||
|
/* Functions for ISystemProperties */
|
||||||
|
typedef struct {
|
||||||
|
nsresult (*GetMaxGuestCPUCount)(ISystemProperties *systemProperties, PRUint32 *maxCPUCount);
|
||||||
|
} vboxUniformedISystemProperties;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* vbox API version */
|
/* vbox API version */
|
||||||
uint32_t APIVersion;
|
uint32_t APIVersion;
|
||||||
@ -205,6 +211,7 @@ typedef struct {
|
|||||||
vboxUniformedISession UISession;
|
vboxUniformedISession UISession;
|
||||||
vboxUniformedIConsole UIConsole;
|
vboxUniformedIConsole UIConsole;
|
||||||
vboxUniformedIProgress UIProgress;
|
vboxUniformedIProgress UIProgress;
|
||||||
|
vboxUniformedISystemProperties UISystemProperties;
|
||||||
/* vbox API features */
|
/* vbox API features */
|
||||||
bool domainEventCallbacks;
|
bool domainEventCallbacks;
|
||||||
bool hasStaticGlobalData;
|
bool hasStaticGlobalData;
|
||||||
@ -225,6 +232,7 @@ char *vboxConnectGetHostname(virConnectPtr conn);
|
|||||||
int vboxConnectIsSecure(virConnectPtr conn);
|
int vboxConnectIsSecure(virConnectPtr conn);
|
||||||
int vboxConnectIsEncrypted(virConnectPtr conn);
|
int vboxConnectIsEncrypted(virConnectPtr conn);
|
||||||
int vboxConnectIsAlive(virConnectPtr conn);
|
int vboxConnectIsAlive(virConnectPtr conn);
|
||||||
|
int vboxConnectGetMaxVcpus(virConnectPtr conn, const char *type);
|
||||||
|
|
||||||
/* Version specified functions for installing uniformed API */
|
/* Version specified functions for installing uniformed API */
|
||||||
void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
|
void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
|
||||||
|
Loading…
Reference in New Issue
Block a user