[libvirt] [PATCH][Network] Make dhcp service enabled only if //ip/dhcp exists in network xml

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@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

On Fri, Mar 26, 2010 at 02:25:18AM +0900, Satoru SATOH wrote:
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.
NACK, this is delibrate. Even when DHCP is turned off, dnsmasq is still used to provide DNS resolution to guests. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

I understand. Thanks for your explanation! - satoru On Thu, Mar 25, 2010 at 05:35:20PM +0000, Daniel P. Berrange wrote:
On Fri, Mar 26, 2010 at 02:25:18AM +0900, Satoru SATOH wrote:
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.
NACK, this is delibrate. Even when DHCP is turned off, dnsmasq is still used to provide DNS resolution to guests.
Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (2)
-
Daniel P. Berrange
-
Satoru SATOH