# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1200504975 28800
# Node ID 81149ab841550817357e38e7d6c88c3049a0fd32
# Parent c505a88eb5e25f5e3b2418312dc48b6602857946
Fix KVM network xml to use virtual network type
...and default the network name for now.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r c505a88eb5e2 -r 81149ab84155 libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c Wed Jan 16 09:36:13 2008 -0800
+++ b/libxkutil/xmlgen.c Wed Jan 16 09:36:15 2008 -0800
@@ -169,7 +169,7 @@ static bool disk_to_xml(char **xml, stru
return true;
}
-static bool net_to_xml(char **xml, struct virt_device *dev)
+static bool xen_net_to_xml(char **xml, struct virt_device *dev)
{
int ret;
char *_xml;
@@ -193,6 +193,43 @@ static bool net_to_xml(char **xml, struc
free(_xml);
return true;
+}
+
+static bool kvm_net_to_xml(char **xml, struct virt_device *dev)
+{
+ int ret;
+ char *_xml;
+ struct net_device *net = &dev->dev.net;
+
+ if (net->source == NULL)
+ net->source = strdup("default");
+
+ ret = asprintf(&_xml,
+ "<interface type='%s'>\n"
+ " <mac address='%s'/>\n"
+ " <source network='%s'/>\n"
+ "</interface>\n",
+ net->type,
+ net->mac,
+ net->source);
+ if (ret == -1)
+ return false;
+ else
+ astrcat(xml, _xml);
+
+ free(_xml);
+
+ return true;
+}
+
+static bool net_to_xml(char **xml, struct virt_device *dev)
+{
+ if (STREQ(dev->dev.net.type, "network"))
+ return kvm_net_to_xml(xml, dev);
+ else if (STREQ(dev->dev.net.type, "bridge"))
+ return xen_net_to_xml(xml, dev);
+ else
+ return false;
}
static bool vcpu_to_xml(char **xml, struct virt_device *dev)