[PATCH 42/66] vbox: Rewrite vboxConnectNumOfDefinedDomains

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

 



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

diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index fcde620..cd9fede 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -3993,3 +3993,43 @@ int vboxConnectListDefinedDomains(virConnectPtr conn,
     gVBoxAPI.UArray.vboxArrayRelease(&machines);
     return ret;
 }
+
+int vboxConnectNumOfDefinedDomains(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 Defined Domains, rc=%08x"),
+                       (unsigned)rc);
+        goto cleanup;
+    }
+
+    ret = 0;
+    for (i = 0; i < machines.count; ++i) {
+        PRBool isAccessible = PR_FALSE;
+        IMachine *machine = machines.items[i];
+
+        if (!machine)
+            continue;
+
+        gVBoxAPI.UIMachine.GetAccessible(machine, &isAccessible);
+        if (!isAccessible)
+            continue;
+
+        gVBoxAPI.UIMachine.GetState(machine, &state);
+        if (gVBoxAPI.machineStateChecker.Inactive(state)) {
+            ret++;
+        }
+    }
+
+ cleanup:
+    gVBoxAPI.UArray.vboxArrayRelease(&machines);
+    return ret;
+}
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 7479f23..239ee67 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -966,44 +966,6 @@ static virDomainState _vboxConvertState(PRUint32 state)
     }
 }
 
-static int vboxConnectNumOfDefinedDomains(virConnectPtr conn)
-{
-    VBOX_OBJECT_CHECK(conn, int, -1);
-    vboxArray machines = VBOX_ARRAY_INITIALIZER;
-    PRUint32 state       = MachineState_Null;
-    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 Defined 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;
-}
-
 #if VBOX_API_VERSION < 3001000
 
 static void
diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h
index 7ff6b57..f57eaa9 100644
--- a/src/vbox/vbox_uniformed_api.h
+++ b/src/vbox/vbox_uniformed_api.h
@@ -520,6 +520,7 @@ int vboxDomainGetMaxVcpus(virDomainPtr dom);
 char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags);
 int vboxConnectListDefinedDomains(virConnectPtr conn,
                                   char ** const names, int maxnames);
+int vboxConnectNumOfDefinedDomains(virConnectPtr conn);
 
 /* Version specified functions for installing uniformed API */
 void vbox22InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
-- 
1.7.9.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]