From: yvinter <yves.vinter(a)bull.net>
---
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 84267b7..2063090 100644
--- a/src/hyperv/hyperv_network_driver.c
+++ b/src/hyperv/hyperv_network_driver.c
@@ -228,6 +228,85 @@ hypervConnectListNetworks(virConnectPtr conn, char **const names, int
maxnames)
+static int
+hypervConnectNumOfDefinedNetworks(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
+hypervConnectListDefinedNetworks(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 */
@@ -236,6 +315,8 @@ static virNetworkDriver hypervNetworkDriver = {
.networkGetXMLDesc = hypervNetworkGetXMLDesc, /* 1.2.10 */
.connectNumOfNetworks = hypervConnectNumOfNetworks, /* 1.2.10 */
.connectListNetworks = hypervConnectListNetworks, /* 1.2.10 */
+ .connectNumOfDefinedNetworks = hypervConnectNumOfDefinedNetworks, /* 1.2.10 */
+ .connectListDefinedNetworks = hypervConnectListDefinedNetworks, /* 1.2.10 */
};
--
1.9.1