Libvirtd enabls DHCP service on virtual networks even if the element
'//ip/dhcp' does not exist in the network xml. The following patch fixes
this problem.
Signed-off-by: Satoru SATOH <satoru.satoh(a)gmail.com>
---
src/conf/network_conf.c | 2 ++
src/conf/network_conf.h | 2 ++
src/network/bridge_driver.c | 5 +----
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 1f3a44c..e41775a 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -466,6 +466,8 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
if ((ip = virXPathNode("./ip[1]", ctxt)) &&
virNetworkIPParseXML(def, ip) < 0)
goto error;
+
+ def->dhcp = (virXPathNode("./ip/dhcp", ctxt) != NULL ? 1 : 0);
}
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index 127a23a..847ddd3 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -74,6 +74,8 @@ struct _virNetworkDef {
char *netmask;
char *network;
+ unsigned int dhcp;
+
unsigned int nranges; /* Zero or more dhcp ranges */
virNetworkDHCPRangeDefPtr ranges;
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 83ab00e..6dcf7b4 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -943,12 +943,9 @@ static int networkStartNetworkDaemon(struct network_driver *driver,
goto err_delbr2;
}
- if ((network->def->ipAddress ||
- network->def->nranges) &&
- dhcpStartDhcpDaemon(network) < 0)
+ if (network->def->dhcp && dhcpStartDhcpDaemon(network) < 0)
goto err_delbr2;
-
/* Persist the live configuration now we have bridge info */
if (virNetworkSaveConfig(NETWORK_STATE_DIR, network->def) < 0) {
goto err_kill;
--
1.6.2.5