# HG changeset patch
# User Jim Fehlig <jfehlig(a)novell.com>
# Date 1226700347 25200
# Node ID 7d43dee14fefe065b3258116bc5f09d3daa3576b
# Parent 917158bf07b442f0178db870b1f8aceafd2d5401
Do not default network source if none is provided in dev xml
When adding resources to a running domain, the network source is set
to default values on redefine even if no source was defined in the
device xml. The domain will fail to restart if the default source does
not exist.
Signed-off-by: Jim Fehlig <jfehlig(a)novell.com>
diff -r 917158bf07b4 -r 7d43dee14fef libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Wed Nov 05 15:13:38 2008 -0800
+++ b/libxkutil/device_parsing.c Fri Nov 14 15:05:47 2008 -0700
@@ -317,25 +317,8 @@ static int parse_net_device(xmlNode *ino
if (ndev->mac == NULL)
goto err;
- if (ndev->source == NULL) {
- if (STREQC(ndev->type, "bridge")) {
- ndev->source = strdup(DEFAULT_BRIDGE);
- CU_DEBUG("No bridge, taking default of `%s'\n",
- ndev->source);
- } else if (STREQC(ndev->type, "network")) {
- 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
- */
- CU_DEBUG("No network source, and no known default");
- goto err;
- }
- }
+ if (ndev->source == NULL)
+ CU_DEBUG("No network source defined, leaving blank\n");
vdev->type = CIM_RES_TYPE_NET;
vdev->id = strdup(ndev->mac);
diff -r 917158bf07b4 -r 7d43dee14fef libxkutil/xmlgen.c
--- a/libxkutil/xmlgen.c Wed Nov 05 15:13:38 2008 -0800
+++ b/libxkutil/xmlgen.c Fri Nov 14 15:05:47 2008 -0700
@@ -206,16 +206,26 @@ static bool bridge_net_to_xml(char **xml
char *script = "vif-bridge";
struct net_device *net = &dev->dev.net;
- ret = asprintf(&_xml,
- "<interface type='%s'>\n"
- " <source bridge='%s'/>\n"
- " <mac address='%s'/>\n"
- " <script path='%s'/>\n"
- "</interface>\n",
- net->type,
- net->source,
- net->mac,
- script);
+ if (net->source == NULL)
+ ret = asprintf(&_xml,
+ "<interface type='%s'>\n"
+ " <mac address='%s'/>\n"
+ " <script path='%s'/>\n"
+ "</interface>\n",
+ net->type,
+ net->mac,
+ script);
+ else
+ ret = asprintf(&_xml,
+ "<interface type='%s'>\n"
+ " <source bridge='%s'/>\n"
+ " <mac address='%s'/>\n"
+ " <script path='%s'/>\n"
+ "</interface>\n",
+ net->type,
+ net->source,
+ net->mac,
+ script);
if (ret == -1)
return false;
@@ -234,16 +244,21 @@ static bool network_net_to_xml(char **xm
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);
+ ret = asprintf(&_xml,
+ "<interface type='%s'>\n"
+ " <mac address='%s'/>\n"
+ "</interface>\n",
+ net->type,
+ net->mac);
+ else
+ 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