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

[libvirt] [PATCH 05/13] vbox: Rewrite vboxConnectNumOfDefinedNetworks



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

diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index e532393..fc5faca 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -7580,6 +7580,41 @@ int vboxConnectListNetworks(virConnectPtr conn, char **const names, int nnames)
     return ret;
 }
 
+int vboxConnectNumOfDefinedNetworks(virConnectPtr conn)
+{
+    VBOX_OBJECT_HOST_CHECK(conn, int, 0);
+    vboxArray networkInterfaces = VBOX_ARRAY_INITIALIZER;
+    size_t i = 0;
+
+    gVBoxAPI.UArray.vboxArrayGet(&networkInterfaces, host,
+                                 gVBoxAPI.UArray.handleHostGetNetworkInterfaces(host));
+
+    for (i = 0; i < networkInterfaces.count; i++) {
+        IHostNetworkInterface *networkInterface = networkInterfaces.items[i];
+        PRUint32 status = HostNetworkInterfaceStatus_Unknown;
+        PRUint32 interfaceType = 0;
+
+        if (!networkInterface)
+            continue;
+
+        gVBoxAPI.UIHNInterface.GetInterfaceType(networkInterface, &interfaceType);
+        if (interfaceType != HostNetworkInterfaceType_HostOnly)
+            continue;
+
+        gVBoxAPI.UIHNInterface.GetStatus(networkInterface, &status);
+
+        if (status == HostNetworkInterfaceStatus_Down)
+            ret++;
+    }
+
+    gVBoxAPI.UArray.vboxArrayRelease(&networkInterfaces);
+
+    VBOX_RELEASE(host);
+
+    VIR_DEBUG("numActive: %d", ret);
+    return ret;
+}
+
 /**
  * Function Tables
  */
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 738547f..52d0b1f 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -2060,40 +2060,6 @@ _registerDomainEvent(virDriverPtr driver)
  * The Network Functions here on
  */
 
-static int vboxConnectNumOfDefinedNetworks(virConnectPtr conn)
-{
-    VBOX_OBJECT_HOST_CHECK(conn, int, 0);
-    vboxArray networkInterfaces = VBOX_ARRAY_INITIALIZER;
-    size_t i = 0;
-
-    vboxArrayGet(&networkInterfaces, host, host->vtbl->GetNetworkInterfaces);
-
-    for (i = 0; i < networkInterfaces.count; i++) {
-        IHostNetworkInterface *networkInterface = networkInterfaces.items[i];
-
-        if (networkInterface) {
-            PRUint32 interfaceType = 0;
-
-            networkInterface->vtbl->GetInterfaceType(networkInterface, &interfaceType);
-            if (interfaceType == HostNetworkInterfaceType_HostOnly) {
-                PRUint32 status = HostNetworkInterfaceStatus_Unknown;
-
-                networkInterface->vtbl->GetStatus(networkInterface, &status);
-
-                if (status == HostNetworkInterfaceStatus_Down)
-                    ret++;
-            }
-        }
-    }
-
-    vboxArrayRelease(&networkInterfaces);
-
-    VBOX_RELEASE(host);
-
-    VIR_DEBUG("numActive: %d", ret);
-    return ret;
-}
-
 static int vboxConnectListDefinedNetworks(virConnectPtr conn, char **const names, int nnames) {
     VBOX_OBJECT_HOST_CHECK(conn, int, 0);
     vboxArray networkInterfaces = VBOX_ARRAY_INITIALIZER;
diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h
index ec8e334..2ca90ff 100644
--- a/src/vbox/vbox_uniformed_api.h
+++ b/src/vbox/vbox_uniformed_api.h
@@ -550,6 +550,7 @@ virDrvOpenStatus vboxNetworkOpen(virConnectPtr conn,
 int vboxNetworkClose(virConnectPtr conn);
 int vboxConnectNumOfNetworks(virConnectPtr conn);
 int vboxConnectListNetworks(virConnectPtr conn, char **const names, int nnames);
+int vboxConnectNumOfDefinedNetworks(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]