[libvirt] static address assignment via dnsmasq

I want my VMs to be assigned static addresses by hostname. I would prefer to set up a generic way to configure dnsmasq, since I don't think this is the last thing I'll want to change about address assignment. I saw this patch from "Mads Chr. Olesen" https://www.redhat.com/archives/libvir-list/2008-April/msg00327.html But it seems like a lot of work to give access to only one dnsmasq option. I'm working on a patch that enables a dnsmasq.d directory where you can (optionally) put individual configuration files. I have not fully tested it yet, so please don't consider this an official submission. I also don't feel that I have spent enough time with the code to understand the 'philosphy' if you will, the guiding attitudes. Is the all-XML approach better according the libvirt developer community standards? If so, why? Thanks. Untested patch follows. Please let me know if I'm on the right path and if not, why. --Kurt diff -u /root/libvirt-0.4.4-virgin/src/qemu_driver.c ./qemu_driver.c --- /root/libvirt-0.4.4-virgin/src/qemu_driver.c 2008-06-12 07:52:53.000000000 -0700 +++ ./qemu_driver.c 2008-07-13 11:31:26.000000000 -0700 @@ -1048,6 +1048,7 @@ 1 + /* --bind-interfaces */ 2 + /* --pid-file "" */ 2 + /* --conf-file "" */ + 2 + /* --conf-dir DNSMASQCONF_DIR */ /*2 + *//* --interface virbr0 */ 2 + /* --except-interface lo */ 2 + /* --listen-address 10.0.0.1 */ @@ -1081,6 +1082,9 @@ APPEND_ARG(*argv, i++, "--conf-file"); APPEND_ARG(*argv, i++, ""); + APPEND_ARG(*argv, i++, "--conf-dir"); + APPEND_ARG(*argv, i++, DNSMASQCONF_DIR); + /* * XXX does not actually work, due to some kind of * race condition setting up ipv6 addresses on the diff -u /root/libvirt-0.4.4-virgin/src/qemu_driver.h ./qemu_driver.h --- /root/libvirt-0.4.4-virgin/src/qemu_driver.h 2008-04-23 07:19:02.000000000 -0700 +++ ./qemu_driver.h 2008-07-13 11:26:47.000000000 -0700 @@ -33,6 +33,8 @@ int qemudRegister(void); +#define DNSMASQCONF_DIR SYSCONF_DIR "/dnsmasq.d" + #endif /* WITH_QEMU */ #endif /* QEMUD_DRIVER_H */ -- ---------------------------------------------------------------------- Merlot Research Group, Inc kls[at]merlot.com "Quality is free, but only to those who are willing to pay heavily for it." (Lister, DeMarco: "Peopleware")

On Mon, Jul 14, 2008 at 10:49:39AM -0700, Kurt Sussman wrote:
I want my VMs to be assigned static addresses by hostname. I would prefer to set up a generic way to configure dnsmasq, since I don't think this is the last thing I'll want to change about address assignment.
I saw this patch from "Mads Chr. Olesen"
https://www.redhat.com/archives/libvir-list/2008-April/msg00327.html
But it seems like a lot of work to give access to only one dnsmasq option.
The point of the impl quoted above is - The use of Dnsmasq is a private implementation detail that must remain hidden from applications using libvirt, so an alternate DNS/DHCP impl can we switched in without breaking apps using it - It provides applications a programmatic API for controlling the address assignment, because you cannot assume login access to the OS running dnsmasq. - It ensures the configuration of the network is fully specified in a single place, so can be guarenteed identical across all machines using the same XML configuraiton. For all these reasons, we explicitly do not use a configuration file with dnsmasq - indeed we explicitly disable it, and do not intend to support its use. 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 :|
participants (2)
-
Daniel P. Berrange
-
Kurt Sussman