[PATCH 10/21] Added implementation for virConnectNumOfNetworks and virConnectListNetworks

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

 



From: yvinter <yves.vinter@xxxxxxxx>

---
 src/hyperv/hyperv_network_driver.c | 81 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

diff --git a/src/hyperv/hyperv_network_driver.c b/src/hyperv/hyperv_network_driver.c
index ee7c0b3..84267b7 100644
--- a/src/hyperv/hyperv_network_driver.c
+++ b/src/hyperv/hyperv_network_driver.c
@@ -149,12 +149,93 @@ hypervNetworkGetXMLDesc(virNetworkPtr network, unsigned int flags)
 
 
 
+static int
+hypervConnectNumOfNetworks(virConnectPtr conn)
+{
+    int result = -1, count = 0;
+    hypervPrivate *priv = conn->privateData;
+    virBuffer query = VIR_BUFFER_INITIALIZER;
+    Msvm_VirtualSwitch *virtualSwitchList = NULL;
+    Msvm_VirtualSwitch *virtualSwitch = NULL;
+    
+    virBufferAddLit(&query, MSVM_VIRTUALSWITCH_WQL_SELECT);
+    virBufferAsprintf(&query, "where HealthState = %d", 5);
+    if (hypervGetMsvmVirtualSwitchList(priv, &query, &virtualSwitchList) < 0) {
+        goto cleanup;
+    }
+    
+    for (virtualSwitch = virtualSwitchList; virtualSwitch != NULL;
+         virtualSwitch = virtualSwitch->next) {
+        count++;
+    }
+    
+    result = count;
+    
+ cleanup:
+    hypervFreeObject(priv, (hypervObject *) virtualSwitchList);
+    virBufferFreeAndReset(&query);
+
+    return result;
+}
+
+
+
+static int
+hypervConnectListNetworks(virConnectPtr conn, char **const names, int maxnames)
+{
+    int i, count = 0;
+    bool success = false;
+    hypervPrivate *priv = conn->privateData;
+    virBuffer query = VIR_BUFFER_INITIALIZER;
+    Msvm_VirtualSwitch *virtualSwitchList = NULL;
+    Msvm_VirtualSwitch *virtualSwitch = NULL;
+    
+    if (maxnames <= 0)
+        return 0;
+    
+    virBufferAddLit(&query, MSVM_VIRTUALSWITCH_WQL_SELECT);
+    virBufferAsprintf(&query, "where HealthState = %d", 5);
+    if (hypervGetMsvmVirtualSwitchList(priv, &query, &virtualSwitchList) < 0) {
+        goto cleanup;
+    }
+    
+    for (virtualSwitch = virtualSwitchList; virtualSwitch != NULL;
+         virtualSwitch = virtualSwitch->next) {
+        if (VIR_STRDUP(names[count], virtualSwitch->data->ElementName) < 0) {
+            goto cleanup;
+        }
+        count++;
+        if (count >= maxnames) {
+            break;
+        }
+    }
+    
+    success = true;
+    
+ cleanup:
+    if (!success) {
+        for (i = 0; i < count; ++i) {
+            VIR_FREE(names[i]);
+        }
+        count = -1;
+    }
+
+    hypervFreeObject(priv, (hypervObject *) virtualSwitchList);
+    virBufferFreeAndReset(&query);
+
+    return count;
+}
+
+
+
 static virNetworkDriver hypervNetworkDriver = {
     .name = "Hyper-V",
     .networkOpen = hypervNetworkOpen, /* 0.9.5 */
     .networkClose = hypervNetworkClose, /* 0.9.5 */
     .networkLookupByName = hypervNetworkLookupByName, /* 1.2.10 */
     .networkGetXMLDesc = hypervNetworkGetXMLDesc, /* 1.2.10 */
+    .connectNumOfNetworks = hypervConnectNumOfNetworks, /* 1.2.10 */
+    .connectListNetworks = hypervConnectListNetworks, /* 1.2.10 */
 };
 
 
-- 
1.9.1

--
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]