diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 76caa7e5e06d5f7caec1844e0025feddc3160d44..109febda70c9ae6f107f802e812dcf311c93ba73 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -369,6 +369,7 @@ networkBuildDnsmasqArgv(virConnectPtr conn, const char *pidfile, const char ***argv) { int i, len, r; + int nbleases = 0; char *pidfileArg; char buf[1024]; @@ -402,6 +403,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 */ @@ -466,6 +469,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++) {