# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1200676457 28800
# Node ID 9a7e8d8094a2cd22c441f894578489bc9ca96d70
# Parent d7cbd655da4e98984ea25a4263b2ed030dec4b58
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 d7cbd655da4e -r 9a7e8d8094a2 libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c Fri Jan 18 09:14:17 2008 -0800
+++ b/libxkutil/xmlgen.c Fri Jan 18 09:14:17 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)