
# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1216824788 25200 # Node ID caa024a3a0938bcb709df190a02fcce0d738c165 # Parent e8d39d291bb30a5337605c4ba97f20acb97ab859 Don't clobber KVM user-type network devices when we redefine a guest. This also makes KVM_NetworkPort expose an instance for user-type interfaces, and thus causes 03_user_netport to pass. Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r e8d39d291bb3 -r caa024a3a093 libxkutil/device_parsing.c --- a/libxkutil/device_parsing.c Wed Jul 23 07:37:23 2008 -0700 +++ b/libxkutil/device_parsing.c Wed Jul 23 07:53:08 2008 -0700 @@ -310,6 +310,8 @@ ndev->source = strdup(DEFAULT_NETWORK); CU_DEBUG("No network, taking default of `%s'\n", ndev->source); + } else if (STREQC(ndev->type, "user")){ + CU_DEBUG("Leaving source blank for user net type"); } else { /* This likely indicates an unsupported * network configuration diff -r e8d39d291bb3 -r caa024a3a093 libxkutil/xmlgen.c --- a/libxkutil/xmlgen.c Wed Jul 23 07:37:23 2008 -0700 +++ b/libxkutil/xmlgen.c Wed Jul 23 07:53:08 2008 -0700 @@ -244,12 +244,36 @@ return true; } +static bool user_net_to_xml(char **xml, struct virt_device *dev) +{ + int ret; + char *_xml; + struct net_device *net = &dev->dev.net; + + ret = asprintf(&_xml, + "<interface type='%s'>\n" + " <mac address='%s'/>\n" + "</interface>\n", + net->type, + net->mac); + 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 network_net_to_xml(xml, dev); else if (STREQ(dev->dev.net.type, "bridge")) return bridge_net_to_xml(xml, dev); + else if (STREQ(dev->dev.net.type, "user")) + return user_net_to_xml(xml, dev); else return false; }