[libvirt] [PATCH] network: add domain to unqalified names define with <host>

Laine Stump laine at laine.org
Sat Jun 25 05:33:53 UTC 2011


If a domain name is defined for a network, add the --expand-hosts
option to the dnsmasq commandline. This results in the domain being
added to any hostname that is defined in a dns <host> element and
contains no '.' characters (i.e. it is an "unqualified"
hostname). Since PTR records are automatically created for any name
define in <host>, the result of a PTR request will change from the
unqualified name to the qualified name.

This also has the same effect on any hostnames that dnsmasq reads
from the host's /etc/hosts file. Hosts.

I want to make sure that everyone notices that previous paragraph and
has a chance to object if they believe this change in existing
behavior will be detrimental. Note that guests will still be able to
query the unqualified name, with the same results as before; it is
only when a reverse lookup of an IP address is done that the result
will be different, e.g. it will return "f15.example.com" instead of
"f15".

(In the case of guest hostnames that were learned by dnsmasq via DHCP
requests, they were already getting the domain name added on, even
without --expand-hosts).
---
 src/network/bridge_driver.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index f15a7a6..a9a0374 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -614,6 +614,10 @@ networkBuildDnsmasqArgv(virNetworkObjPtr network,
         if (ipdef->nranges || ipdef->nhosts)
             virCommandAddArg(cmd, "--dhcp-no-override");
 
+        /* add domain to any non-qualified hostnames in /etc/hosts or addn-hosts file */
+        if (network->def->domain)
+           virCommandAddArg(cmd, "--expand-hosts");
+
         if ((dctx = networkSaveDnsmasqHostsfile(ipdef, network->def->dns, network->def->name, false))) {
             if (dctx->hostsfile->nhosts)
                 virCommandAddArgPair(cmd, "--dhcp-hostsfile",
-- 
1.7.3.4




More information about the libvir-list mailing list