• L
    network: always create dnsmasq hosts and addnhosts files, even if empty · 1cb1f9da
    Laine Stump 提交于
    This fixes the problem reported in:
    
      https://bugzilla.redhat.com/show_bug.cgi?id=868389
    
    Previously, the dnsmasq hosts file (used for static dhcp entries, and
    addnhosts file (used for additional dns host entries) were only
    created/referenced on the dnsmasq commandline if there was something
    to put in them at the time the network was started. Once we can update
    a network definition while it's active (which is now possible with
    virNetworkUpdate), this is no longer a valid strategy - if there were
    0 dhcp static hosts (resulting in no reference to the hosts file on the
    commandline), then one was later added, the commandline wouldn't have
    linked dnsmasq up to the file, so even though we create it, dnsmasq
    doesn't pay any attention.
    
    The solution is to just always create these files and reference them
    on the dnsmasq commandline (almost always, anyway). That way dnsmasq
    can notice when a new entry is added at runtime (a SIGHUP is sent to
    dnsmasq by virNetworkUdpate whenever a host entry is added or removed)
    
    The exception to this is that the dhcp static hosts file isn't created
    if there are no lease ranges *and* no static hosts. This is because in
    this case dnsmasq won't be setup to listen for dhcp requests anyway -
    in that case, if the count of dhcp hosts goes from 0 to 1, dnsmasq
    will need to be restarted anyway (to get it listening on the dhcp
    port). Likewise, if the dhcp hosts count goes from 1 to 0 (and there
    are no dhcp ranges) we need to restart dnsmasq so that it will stop
    listening on port 67. These special situations are handled in the
    bridge driver's networkUpdate() by checking for ((bool)
    nranges||nhosts) both before and after the update, and triggering a
    dnsmasq restart if the before and after don't match.
    1cb1f9da
routed-network.argv 197 字节