RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 868389 - 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.
Summary: virsh net-update to do a live add of a static host to a network that previous...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.3
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Laine Stump
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-10-19 17:16 UTC by Laine Stump
Modified: 2013-02-21 07:10 UTC (History)
8 users (show)

Fixed In Version: libvirt-0.10.2-5.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-02-21 07:10:38 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2013:0276 0 normal SHIPPED_LIVE Moderate: libvirt security, bug fix, and enhancement update 2013-02-20 21:18:26 UTC

Description Laine Stump 2012-10-19 17:16:40 UTC
The following description of the problem (written by whuang) comes from Bug 844404:

> I found an issue , when net-1 start but  without "<host mac='*' ip='*' />" 
> the dnsmasq process do not have
> --dhcp-hostsfile=/var/lib/libvirt/dnsmasq/net-1.hostsfile so 
> At this env , we run :
> #virsh net-update net-1 add ip-dhcp-host  "<host mac='52:54:00:5a:a0:8b'
> ip='192.168.200.200' />"
> Updated network net-1 live state 
> 
> # virsh net-dumpxml net-1
> <network connections='1'>
>   <name>net-1</name>
>   <uuid>d7f1e011-6347-5c14-1941-46d7ff1b5e57</uuid>
>   <forward mode='nat'/>
>   <bridge name='net-test' stp='on' delay='0' />
>   <mac address='52:54:00:E7:56:E9'/>
>   <ip address='192.168.200.1' netmask='255.255.255.0'>
>     <dhcp>
>       <range start='192.168.200.2' end='192.168.200.254' />
>       <host mac='52:54:00:5a:a0:8b' ip='192.168.200.200' />
>     </dhcp>
>   </ip>
> </network>
> 
> #there is not hostsfile in the dnsmasq process
> #ps -ef |grep net-1
> nobody   25556     1  0 12:44 ?        00:00:00 /usr/sbin/dnsmasq
> --strict-order --bind-interfaces --local=// --domain-needed
> --pid-file=/var/run/libvirt/network/net-1.pid --conf-file=
> --except-interface lo --listen-address 192.168.200.1 --dhcp-range
> 192.168.200.2,192.168.200.254
> --dhcp-leasefile=/var/lib/libvirt/dnsmasq/net-1.leases --dhcp-lease-max=253
> --dhcp-no-override
> 
> 
> Then start a guest with net-1 network and check its ip.
> libvirt will create net-1.hostsfile but the guest still can not be allocated
> correct ip .
> 
> Libvirt net should start dnsmasq always with --dhcp-hostsfile even the file
> is empty right ? is there a RFE bug ?

Comment 1 Laine Stump 2012-10-20 07:53:56 UTC
Fix sent upstream. Awaiting ACK:

  https://www.redhat.com/archives/libvir-list/2012-October/msg01077.html

Comment 2 Laine Stump 2012-10-21 15:00:33 UTC
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.

Comment 5 yanbing du 2012-10-24 10:30:34 UTC
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

Comment 6 errata-xmlrpc 2013-02-21 07:10:38 UTC
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


Note You need to log in before you can comment on or make changes to this bug.