Bug 611793

Summary: Static only DHCP not supported in network configs.
Product: Red Hat Enterprise Linux 6 Reporter: Daniel Berrangé <berrange>
Component: libvirtAssignee: Laine Stump <laine>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: low    
Version: 6.0CC: berrange, ccui, dallan, dyuan, eblake, jdenemar, llim, neil, virt-maint, xen-maint, xhu
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-0.8.7-1.el6 Doc Type: Bug Fix
Doc Text:
If the configuration for a virtual network only contained static address definitions, dnsmasq (the DHCP server used by libvirt) was started incorrectly and would not respond to any DHCP requests. Any guests with MAC address/IP address pairs listed in static address definitions were then unable to acquire their IP addresses. libvirt now starts up dnsmasq with the correct options so that these statically configured addresses are properly served to the guests.
Story Points: ---
Clone Of: 597363 Environment:
Last Closed: 2011-05-19 13:19:26 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Daniel Berrangé 2010-07-06 14:43:51 UTC
+++ This bug was initially created as a clone of Bug #597363 +++

Description of problem:

If you specify only 'host' entries in the dhcp section, then no dnsmasq is started up.


Version-Release number of selected component (if applicable):
Using library: libvir 0.6.3



How reproducible:


Steps to Reproduce:

Use network 

<network>
  <name>brbb6fd2</name>
  <uuid>f90a9a4b-449b-ae12-c0ac-d80255141a77</uuid>
  <forward dev='bond0' mode='route'/>
  <bridge name='brbb6fd2' stp='off' forwardDelay='0' />
  <ip address='10.187.111.209' netmask='255.255.255.252'>
    <dhcp>
      <host mac='00:16:3e:bb:6f:d2' name='xenhvmlvm' ip='10.187.111.210' />
    </dhcp>
  </ip>
</network>

and start the network. 

  
Actual results:

No dnsmasq is started.


Expected results:

Should start up a dnsmasq serving only static entries by including an appropriate dhcp-range flag.

For example above should including something like:

--dhcp-range=10.187.111.209,static


Additional info:

workaround is to include the network broadcast address as a single range. So for above that would be

    <dhcp>
      <range start='10.187.111.211' end='10.187.111.211' />
      <host mac='00:16:3e:bb:6f:d2' name='xenhvmlvm' ip='10.187.111.210' />
    </dhcp>

Comment 1 Laine Stump 2011-01-04 20:19:37 UTC
This functionality was added in the following upstream commit:

commit df990b445bd85bbd59296acbcaeb9d81543466c8
Author: Jiri Denemark <jdenemar>
Date:   Thu Sep 9 16:00:08 2010 +0200

    bridge: Fix static-only DHCP configuration
    
    For static-only DHCP, i.e. with no <range> but at least one <host>
    element within <dhcp> element, we have to add "--dhcp-range IP,static"
    option to dnsmasq to actually enable the service. Without this option,
    dnsmasq will not respond to DHCP requests.

and included in upstream libvirt-0.8.4.

It will therefore be in the next RHEL6 rebase of libvirt.

Comment 2 Jiri Denemark 2011-01-09 23:58:12 UTC
Built into libvirt-0.8.7-1.el6

Comment 3 xhu 2011-01-11 04:44:47 UTC
Verified it on RHEL6_x86_64 Server with the following component and it passed:
libvirt-0.8.7-1.el6
qemu-kvm-0.12.1.2-2.128.el6
kernel-2.6.32-94.el6

The steps are as follows:
1 define and start the routed network by using the following xml:
# cat statictest.xml
<network>
	<name>statictest</name>
	<forward mode='nat'/>
	<bridge name='s1' stp='on' delay='0' />
        <ip address='192.168.100.1' netmask='255.255.255.0'>
        	<dhcp>
			<host mac='00:16:36:7b:4a:21' name='new-host1' ip='192.168.100.33' />
		</dhcp>
        </ip>
</network>

# virsh net-define statictest.xml
Network statictest defined from statictest.xml

# virsh net-start statictest
Network statictest started

2 Check dnsmasq process option:
# ps -ef|grep dnsmasq|grep statictest
nobody   29523     1  0 11:08 ?        00:00:00 /usr/sbin/dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/libvirt/network/statictest.pid --conf-file=  --listen-address 192.168.100.1 --except-interface lo --dhcp-range 192.168.100.1,static --dhcp-no-override --dhcp-hostsfile=/var/lib/libvirt/dnsmasq/statictest.hostsfile

3 define and start guest using statictest network:
# virsh dumpxml rhel6
...
    <interface type='network'>
      <mac address='52:54:00:8c:c7:f6'/>
      <source network='statictest'/>
      <target dev='vnet0'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
...

4 the guest get IP:  192.168.100.33 hostname: new-host1

Comment 5 Cui Chun 2011-02-09 08:39:07 UTC
Rechecked it on the following test environment according to comment 3. It is passed.

Test environment:
libvirt-0.8.7-5.el6
qemu-kvm-0.12.1.2-2.144.el6
kernel-2.6.32-94.el6

Comment 6 Laine Stump 2011-05-03 17:05:15 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
In previous versions of libvirt, if the configuration for a virtual network only contained static address definitions (ie no dynamic address range), dnsmasq (the dhcp server used by libvirt) was started incorrectly, and would not respond to any DHCP requests. This resulted in the guests with MAC address/IP address pairs listed in the static address definitions being unable to acquire their IP addresses.

libvirt now starts up dnsmasq with the correct options so that these statically configured addresses are properly served to the guests.

Comment 9 Laura Bailey 2011-05-04 06:20:02 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,3 +1 @@
-In previous versions of libvirt, if the configuration for a virtual network only contained static address definitions (ie no dynamic address range), dnsmasq (the dhcp server used by libvirt) was started incorrectly, and would not respond to any DHCP requests. This resulted in the guests with MAC address/IP address pairs listed in the static address definitions being unable to acquire their IP addresses.
+If the configuration for a virtual network only contained static address definitions, dnsmasq (the DHCP server used by libvirt) was started incorrectly and would not respond to any DHCP requests. Any guests with MAC address/IP address pairs listed in static address definitions were then unable to acquire their IP addresses. libvirt now starts up dnsmasq with the correct options so that these statically configured addresses are properly served to the guests.-
-libvirt now starts up dnsmasq with the correct options so that these statically configured addresses are properly served to the guests.

Comment 10 errata-xmlrpc 2011-05-19 13:19:26 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-0596.html