[libvirt] [PATCH] 3/3 524280 pass max lease option to dnsmasq

Daniel Veillard veillard at redhat.com
Fri Nov 6 17:11:48 UTC 2009


On Wed, Oct 14, 2009 at 10:58:24AM +0100, Daniel P. Berrange wrote:
> On Tue, Oct 13, 2009 at 04:14:59PM +0200, Daniel Veillard wrote:
> >     * src/network/bridge_driver.c: when exec'ing dnsmaq, if there are
> >       DHCP ranges defined, then compute and pass the --dhcp-lease-max
> >       deriving the maximum number of leases
> > 
> > diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
> > index 95bc810..bffb6f7 100644
> > --- a/src/network/bridge_driver.c
> > +++ b/src/network/bridge_driver.c
> > @@ -365,6 +365,7 @@ networkBuildDnsmasqArgv(virConnectPtr conn,
> >                          const char *pidfile,
> >                          const char ***argv) {
> >      int i, len, r;
> > +    int nbleases = 0;
> >      char *pidfileArg;
> >      char buf[1024];
> >  
> > @@ -398,6 +399,8 @@ networkBuildDnsmasqArgv(virConnectPtr conn,
> >          2 + /* --except-interface lo */
> >          2 + /* --listen-address 10.0.0.1 */
> >          (2 * network->def->nranges) + /* --dhcp-range 10.0.0.2,10.0.0.254 */
> > +        /* --dhcp-lease-max=xxx if needed */
> > +        (network->def->nranges ? 0 : 1) +
> >          /*  --dhcp-host 01:23:45:67:89:0a,hostname,10.0.0.3 */
> >          (2 * network->def->nhosts) +
> >          /* --enable-tftp --tftp-root /srv/tftp */
> > @@ -462,6 +465,12 @@ networkBuildDnsmasqArgv(virConnectPtr conn,
> >  
> >          APPEND_ARG(*argv, i++, "--dhcp-range");
> >          APPEND_ARG(*argv, i++, buf);
> > +        nbleases += network->def->ranges[r].size;
> > +    }
> > +
> > +    if (network->def->nranges > 0) {
> > +        snprintf(buf, sizeof(buf), "--dhcp-lease-max=%d", nbleases);
> > +        APPEND_ARG(*argv, i++, buf);
> >      }
> >  
> >      for (r = 0 ; r < network->def->nhosts ; r++) {
> 
> ACK,
> 
> Daniel

  Okay, applied after having rebased the previous patch and fixed an
array indexing problem in getIPv4Addr() after the ntoh conversion.
This fixes 524280 and with the usual default network we have

/usr/sbin/dnsmasq --strict-order --bind-interfaces
--pid-file=/var/run/libvirt/network/default.pid --conf-file=
--listen-address 192.168.122.1 --except-interface lo --dhcp-range
192.168.122.2,192.168.122.254 --dhcp-lease-max=253

running,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/




More information about the libvir-list mailing list