[libvirt] [PATCH 2/2] Network: Add support for DNS hosts definition

Paolo Bonzini pbonzini at redhat.com
Thu Mar 31 08:16:42 UTC 2011


> +<zeroOrMore>
> +<element name="host">
> +<attribute name="ip"><ref name="ipv4-addr"/></attribute>
> +<zeroOrMore>
> +<element name="hostname"><text/></element>
> +</zeroOrMore>

oneOrMore hostname elements seems preferrable.

> +    if ((fd = open(hostsFile,

You can use fopen and fprintf.

This function also should be in src/util/dnsmasq.c (e.g. with addnhost* 
APIs in that file and dnsmasqAddHost as a public API).  See the 
hostsfile* APIs there.

Then you could further split the patch this way:

- one patch that moves the creation of the dnsmasqContext into 
networkSaveDnsmasqHostsfile;

- one patch that makes src/util/dnsmasq.c create the hostsfile only 
after the first call to dnsmasqAddDhcpHost

- this would be the third patch in the series, and it would add 
dnsmasqAddHost calls in networkSaveDnsmasqHostsfile

> diff --git a/tests/networkxml2xmlin/nat-network-dns-hosts.xml b/tests/networkxml2xmlin/nat-network-dns-hosts.xml
> new file mode 100644
> index 0000000..fe545cf

Uhm, libvirt has no tests that actually check whether the dnsmasq 
command line works?  That's a bit bad, perhaps you can add them...

Paolo




More information about the libvir-list mailing list