[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 12/66] vbox: Rewrite vboxConnectNumOfDomains



---
 src/vbox/vbox_common.c        |   35 +++++++++++++++++++++++++++++++++++
 src/vbox/vbox_tmpl.c          |   36 ------------------------------------
 src/vbox/vbox_uniformed_api.h |    1 +
 3 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 6de5757..3023fe6 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -516,3 +516,38 @@ int vboxConnectListDomains(virConnectPtr conn, int *ids, int nids)
     gVBoxAPI.UArray.vboxArrayRelease(&machines);
     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;
+}
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index e0033b9..83ea370 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -920,42 +920,6 @@ vboxSocketParseAddrUtf16(vboxGlobalData *data, const PRUnichar *utf16,
     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,
                                         unsigned int flags)
 {
diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h
index b72429b..0b95459 100644
--- a/src/vbox/vbox_uniformed_api.h
+++ b/src/vbox/vbox_uniformed_api.h
@@ -256,6 +256,7 @@ int vboxConnectIsAlive(virConnectPtr conn);
 int vboxConnectGetMaxVcpus(virConnectPtr conn, const char *type);
 char *vboxConnectGetCapabilities(virConnectPtr conn);
 int vboxConnectListDomains(virConnectPtr conn, int *ids, int nids);
+int vboxConnectNumOfDomains(virConnectPtr conn);
 
 /* Version specified functions for installing uniformed API */
 void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
-- 
1.7.9.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]