[libvirt] [PATCH] Make dnsmasq run from libvirtd reading /etc/ethers

The following small patch makes dnsmasq run from libvirtd reading /etc/ethers and enables static ip address assignment with it. Libvirtd already supports static ip address assignment by //ip/dhcp/host element in network xml definition file, however the number of the assignments looks limited by ARG_MAX or similar parameters when dnsmasq is exec-ed. This patch implements a workaround for this issue and the number of static ip assignments becomes only limited by dnsmasq (I'm not sure the exact number but it should large enough for most cases, I guess). Signed-off-by: Satoru SATOH <satoru.satoh@gmail.com> --- src/network/bridge_driver.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 95bc810..725d340 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -391,6 +391,7 @@ networkBuildDnsmasqArgv(virConnectPtr conn, 1 + /* dnsmasq */ 1 + /* --strict-order */ 1 + /* --bind-interfaces */ + 1 + /* --read-ethers */ (network->def->domain?2:0) + /* --domain name */ 2 + /* --pid-file /var/run/libvirt/network/$NAME.pid */ 2 + /* --conf-file "" */ @@ -427,6 +428,7 @@ networkBuildDnsmasqArgv(virConnectPtr conn, */ APPEND_ARG(*argv, i++, "--strict-order"); APPEND_ARG(*argv, i++, "--bind-interfaces"); + APPEND_ARG(*argv, i++, "--read-ethers"); if (network->def->domain) { APPEND_ARG(*argv, i++, "--domain"); -- 1.6.2.5

On Mon, Oct 05, 2009 at 06:00:47AM +0900, Satoru SATOH wrote:
The following small patch makes dnsmasq run from libvirtd reading /etc/ethers and enables static ip address assignment with it.
Libvirtd already supports static ip address assignment by //ip/dhcp/host element in network xml definition file, however the number of the assignments looks limited by ARG_MAX or similar parameters when dnsmasq is exec-ed.
This patch implements a workaround for this issue and the number of static ip assignments becomes only limited by dnsmasq (I'm not sure the exact number but it should large enough for most cases, I guess).
This is the wrong way to approach this priblem since it moves a key configuration parameter outside the scope of the libvirt API. The second problem is that it is a single file per host, whereas libvirt can have multiple independant dnsmasq instances per host each with different config. If the problem is that we're getting too many --dhcp-host args causing us to hit command line length limits, then we should switch to using --dhcp-hostsfile and write out a per-dnsmasq config file in /var/lib/libvirt/network/$NETWORKNAME.dhcpmap Regards, Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Mon, Oct 05, 2009 at 12:53:28PM +0100, Daniel P. Berrange wrote:
On Mon, Oct 05, 2009 at 06:00:47AM +0900, Satoru SATOH wrote:
The following small patch makes dnsmasq run from libvirtd reading /etc/ethers and enables static ip address assignment with it.
Libvirtd already supports static ip address assignment by //ip/dhcp/host element in network xml definition file, however the number of the assignments looks limited by ARG_MAX or similar parameters when dnsmasq is exec-ed.
This patch implements a workaround for this issue and the number of static ip assignments becomes only limited by dnsmasq (I'm not sure the exact number but it should large enough for most cases, I guess).
This is the wrong way to approach this priblem since it moves a key configuration parameter outside the scope of the libvirt API. The second problem is that it is a single file per host, whereas libvirt can have multiple independant dnsmasq instances per host each with different config.
Right. I understand it.
If the problem is that we're getting too many --dhcp-host args causing us to hit command line length limits, then we should switch to using --dhcp-hostsfile and write out a per-dnsmasq config file in /var/lib/libvirt/network/$NETWORKNAME.dhcpmap
Thanks a lot for letting me know about it! I completely missed that option. Your idea looks much much better than mine - using --read-ethers. I'll take some time and try that later. Thanks, Satoru SATOH
participants (2)
-
Daniel P. Berrange
-
Satoru SATOH