From: yvinter <yves.vinter(a)bull.net>
---
src/hyperv/hyperv_network_driver.c | 57 ++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/src/hyperv/hyperv_network_driver.c b/src/hyperv/hyperv_network_driver.c
index 22e1144..ee7c0b3 100644
--- a/src/hyperv/hyperv_network_driver.c
+++ b/src/hyperv/hyperv_network_driver.c
@@ -27,8 +27,10 @@
#include "datatypes.h"
#include "viralloc.h"
#include "viruuid.h"
+#include "virstring.h"
#include "hyperv_network_driver.h"
#include "hyperv_wmi.h"
+#include "network_conf.h"
#define VIR_FROM_THIS VIR_FROM_HYPERV
@@ -93,11 +95,66 @@ hypervNetworkLookupByName(virConnectPtr conn, const char *name)
+static char *
+hypervNetworkGetXMLDesc(virNetworkPtr network, unsigned int flags)
+{
+ char *xml = NULL;
+ char uuid_string[VIR_UUID_STRING_BUFLEN];
+ hypervPrivate *priv = network->conn->privateData;
+ virNetworkDefPtr def = NULL;
+ virBuffer query = VIR_BUFFER_INITIALIZER;
+ Msvm_VirtualSwitch *virtualSwitch = NULL;
+
+ /* Flags checked by virNetworkDefFormat */
+
+ if (VIR_ALLOC(def) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ virUUIDFormat(network->uuid, uuid_string);
+
+ /* Get Msvm_VirtualSwitch */
+ virBufferAddLit(&query, MSVM_VIRTUALSWITCH_WQL_SELECT);
+ virBufferAsprintf(&query, "where Name = \"%s\"",
uuid_string);
+ if (hypervGetMsvmVirtualSwitchList(priv, &query, &virtualSwitch) < 0) {
+ goto cleanup;
+ }
+ if (virtualSwitch == NULL) {
+ virReportError(VIR_ERR_NO_NETWORK,
+ _("No network found with UUID %s"), uuid_string);
+ goto cleanup;
+ }
+
+ /* Fill struct */
+ if (virUUIDParse(virtualSwitch->data->Name, def->uuid) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Could not parse UUID from string '%s'"),
+ virtualSwitch->data->Name);
+ return NULL;
+ }
+
+ if (VIR_STRDUP(def->name, virtualSwitch->data->ElementName) < 0)
+ goto cleanup;
+
+ xml = virNetworkDefFormat(def, flags);
+
+ cleanup:
+ virNetworkDefFree(def);
+ hypervFreeObject(priv, (hypervObject *)virtualSwitch);
+ virBufferFreeAndReset(&query);
+
+ return xml;
+}
+
+
+
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 */
};
--
1.9.1