mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-14 23:24:23 +03:00
vbox: Rewrite vboxConnectNumOfDomains
This commit is contained in:
parent
0958334ac0
commit
5f15b511e9
@ -516,3 +516,38 @@ int vboxConnectListDomains(virConnectPtr conn, int *ids, int nids)
|
|||||||
gVBoxAPI.UArray.vboxArrayRelease(&machines);
|
gVBoxAPI.UArray.vboxArrayRelease(&machines);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int vboxConnectNumOfDomains(virConnectPtr conn)
|
||||||
|
{
|
||||||
|
VBOX_OBJECT_CHECK(conn, int, -1);
|
||||||
|
vboxArray machines = VBOX_ARRAY_INITIALIZER;
|
||||||
|
PRUint32 state;
|
||||||
|
nsresult rc;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES);
|
||||||
|
if (NS_FAILED(rc)) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("Could not get number of Domains, rc=%08x"), (unsigned)rc);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
for (i = 0; i < machines.count; ++i) {
|
||||||
|
IMachine *machine = machines.items[i];
|
||||||
|
|
||||||
|
if (machine) {
|
||||||
|
PRBool isAccessible = PR_FALSE;
|
||||||
|
gVBoxAPI.UIMachine.GetAccessible(machine, &isAccessible);
|
||||||
|
if (isAccessible) {
|
||||||
|
gVBoxAPI.UIMachine.GetState(machine, &state);
|
||||||
|
if (gVBoxAPI.machineStateChecker.Online(state))
|
||||||
|
ret++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
gVBoxAPI.UArray.vboxArrayRelease(&machines);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
@ -921,42 +921,6 @@ vboxSocketParseAddrUtf16(vboxGlobalData *data, const PRUnichar *utf16,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vboxConnectNumOfDomains(virConnectPtr conn)
|
|
||||||
{
|
|
||||||
VBOX_OBJECT_CHECK(conn, int, -1);
|
|
||||||
vboxArray machines = VBOX_ARRAY_INITIALIZER;
|
|
||||||
PRUint32 state;
|
|
||||||
nsresult rc;
|
|
||||||
size_t i;
|
|
||||||
|
|
||||||
rc = vboxArrayGet(&machines, data->vboxObj, data->vboxObj->vtbl->GetMachines);
|
|
||||||
if (NS_FAILED(rc)) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Could not get number of Domains, rc=%08x"), (unsigned)rc);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
for (i = 0; i < machines.count; ++i) {
|
|
||||||
IMachine *machine = machines.items[i];
|
|
||||||
|
|
||||||
if (machine) {
|
|
||||||
PRBool isAccessible = PR_FALSE;
|
|
||||||
machine->vtbl->GetAccessible(machine, &isAccessible);
|
|
||||||
if (isAccessible) {
|
|
||||||
machine->vtbl->GetState(machine, &state);
|
|
||||||
if ((state >= MachineState_FirstOnline) &&
|
|
||||||
(state <= MachineState_LastOnline))
|
|
||||||
ret++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
vboxArrayRelease(&machines);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static virDomainPtr vboxDomainCreateXML(virConnectPtr conn, const char *xml,
|
static virDomainPtr vboxDomainCreateXML(virConnectPtr conn, const char *xml,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
|
@ -256,6 +256,7 @@ int vboxConnectIsAlive(virConnectPtr conn);
|
|||||||
int vboxConnectGetMaxVcpus(virConnectPtr conn, const char *type);
|
int vboxConnectGetMaxVcpus(virConnectPtr conn, const char *type);
|
||||||
char *vboxConnectGetCapabilities(virConnectPtr conn);
|
char *vboxConnectGetCapabilities(virConnectPtr conn);
|
||||||
int vboxConnectListDomains(virConnectPtr conn, int *ids, int nids);
|
int vboxConnectListDomains(virConnectPtr conn, int *ids, int nids);
|
||||||
|
int vboxConnectNumOfDomains(virConnectPtr conn);
|
||||||
|
|
||||||
/* Version specified functions for installing uniformed API */
|
/* Version specified functions for installing uniformed API */
|
||||||
void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
|
void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user