# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1200587110 28800
# Node ID e5053e45e1a4a799b0c07a96730fec7783e0b776
# Parent a1fe7e8ff84c4e27245beb259e64de71e6dca740
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 a1fe7e8ff84c -r e5053e45e1a4 libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c Thu Jan 17 08:25:10 2008 -0800
+++ b/libxkutil/xmlgen.c Thu Jan 17 08:25:10 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)