Bug 868389
Summary: | virsh net-update to do a live add of a static host to a network that previously had no static hosts, reports success, but doesn't take effect until network is restarted. | ||
---|---|---|---|
Product: | Red Hat Enterprise Linux 6 | Reporter: | Laine Stump <laine> |
Component: | libvirt | Assignee: | Laine Stump <laine> |
Status: | CLOSED ERRATA | QA Contact: | Virtualization Bugs <virt-bugs> |
Severity: | unspecified | Docs Contact: | |
Priority: | unspecified | ||
Version: | 6.3 | CC: | acathrow, dyasny, dyuan, mjenner, mzhan, rwu, whuang, ydu |
Target Milestone: | rc | ||
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | libvirt-0.10.2-5.el6 | Doc Type: | Bug Fix |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2013-02-21 07:10:38 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Laine Stump
2012-10-19 17:16:40 UTC
Fix sent upstream. Awaiting ACK: https://www.redhat.com/archives/libvir-list/2012-October/msg01077.html Commited upstream: commit 1cb1f9dabf8e9c9fc8dfadbb3097776ca5f2c68c Author: Laine Stump <laine> Date: Fri Oct 19 16:15:44 2012 -0400 network: always create dnsmasq hosts and addnhosts files, even if empty 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. Verify this bug with libvirt-0.10.2-5.el6.x86_64. Steps 1. Start the default network, and check the dnsmasq commandline, both dhcp-hostsfile and addn-hosts files are created # ps aux|grep dnsmasq nobody 23193 0.0 0.0 12884 680 ? S 17:47 0:00 /usr/sbin/dnsmasq --strict-order --bind-interfaces --local=// --domain-needed --pid-file=/var/run/libvirt/network/default.pid --conf-file= --except-interface lo --listen-address 192.168.122.1 --dhcp-range 192.168.122.2,192.168.122.2 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases --dhcp-lease-max=1 --dhcp-no-override --dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile --addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts 1.2. update the default network to add a static host # virsh net-update default add ip-dhcp-host "<host mac='52:54:00:f9:d4:63' ip='192.168.122.200' />" Updated network default live state # virsh net-dumpxml default <network> <name>default</name> <uuid>a13a4e7a-31db-b59a-7a35-985bceb84000</uuid> <forward mode='nat'/> <bridge name='virbr0' stp='on' delay='0' /> <mac address='52:54:00:F4:C7:A5'/> <ip address='192.168.122.1' netmask='255.255.255.0'> <dhcp> <range start='192.168.122.2' end='192.168.122.254' /> <host mac='52:54:00:f9:d4:63' ip='192.168.122.200' /> </dhcp> </ip> </network> #cat /var/lib/libvirt/dnsmasq/default.hostsfile 52:54:00:f9:d4:63,192.168.122.200 2. Define and start a network with no dhcp rang and static host # virsh net-dumpxml default <network> <name>default</name> <uuid>a13a4e7a-31db-b59a-7a35-985bceb84000</uuid> <forward mode='nat'/> <bridge name='virbr0' stp='on' delay='0' /> <mac address='52:54:00:F4:C7:A5'/> <ip address='192.168.122.1' netmask='255.255.255.0'> </ip> </network> and check the dnsmasq commandline, and there's no dhcp-hostsfile and addn-hosts files # ps aux|grep dnsmasq nobody 23935 0.0 0.0 12880 572 ? S 18:02 0:00 /usr/sbin/dnsmasq --strict-order --bind-interfaces --local=// --domain-needed --pid-file=/var/run/libvirt/network/default.pid --conf-file= --except-interface lo --listen-address 192.168.122.1 --addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts 2.1 update the default network to add a static host # virsh net-update default add ip-dhcp-host "<host mac='52:54:00:f9:d4:63' ip='192.168.122.200' />" # virsh net-dumpxml default <network> <name>default</name> <uuid>a13a4e7a-31db-b59a-7a35-985bceb84000</uuid> <forward mode='nat'/> <bridge name='virbr0' stp='on' delay='0' /> <mac address='52:54:00:F4:C7:A5'/> <ip address='192.168.122.1' netmask='255.255.255.0'> <dhcp> <host mac='52:54:00:f9:d4:62' ip='192.168.122.201' /> </dhcp> </ip> </network> and dnsmasq service is restarted: # ps aux|grep dnsmasq nobody 24039 0.0 0.0 12884 612 ? S 18:15 0:00 /usr/sbin/dnsmasq --strict-order --bind-interfaces --local=// --domain-needed --pid-file=/var/run/libvirt/network/default.pid --conf-file= --except-interface lo --listen-address 192.168.122.1 --dhcp-range 192.168.122.1,static --dhcp-no-override --dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile --addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts 2.2 update the default network to delete a static host # virsh net-update default delete ip-dhcp-host "<host mac='52:54:00:f9:d4:62' ip='192.168.122.201' />" Updated network default live state # virsh net-dumpxml default <network> <name>default</name> <uuid>a13a4e7a-31db-b59a-7a35-985bceb84000</uuid> <forward mode='nat'/> <bridge name='virbr0' stp='on' delay='0' /> <mac address='52:54:00:F4:C7:A5'/> <ip address='192.168.122.1' netmask='255.255.255.0'> </ip> </network> and dnsmasq service is restarted: # ps aux|grep dnsmasq nobody 24206 0.0 0.0 12880 576 ? S 18:19 0:00 /usr/sbin/dnsmasq --strict-order --bind-interfaces --local=// --domain-needed --pid-file=/var/run/libvirt/network/default.pid --conf-file= --except-interface lo --listen-address 192.168.122.1 --addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHSA-2013-0276.html |