# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1200511049 28800
# Node ID 1aa3a926d114a68640484b85938430fb4a9178f5
# Parent dc3ff9e258b404c1755d5e24f71a75a845d19b02
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 dc3ff9e258b4 -r 1aa3a926d114 libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c Wed Jan 16 11:17:24 2008 -0800
+++ b/libxkutil/xmlgen.c Wed Jan 16 11:17:29 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)