Bug 1375047

Summary: Configured host names missing from virsh net-dhcp-leases output
Product: Red Hat Enterprise Linux 7 Reporter: Andrew Beekhof <abeekhof>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: unspecified    
Version: 7.2CC: rbalakri
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-09-12 04:37:18 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:

Description Andrew Beekhof 2016-09-12 04:17:00 UTC
Description of problem:

I have been using:

   virsh net-update default add ip-dhcp-host "<host mac='${MAC}'
name='${name}-${offset}' ip='192.168.122.$(( $lastoct + $offset ))'/>"
--live --config

on Fedora 23 to allow hosts to pick up names and allow easy host -> ip
lookups by parsing the output of 'virsh net-dhcp-leases ...'

However, when I moved the same logic over to 7.2 the hostname is
missing in virsh (as well as in the dhcp client on the guests):

# virsh net-dhcp-leases default
 Expiry Time          MAC address        Protocol  IP address
      Hostname        Client ID or DUID
-------------------------------------------------------------------------------------------------------------------
 2016-09-09 14:17:52  54:52:00:86:01:01  ipv4      192.168.124.158/24
      -               -
 2016-09-09 14:17:56  54:52:00:86:01:02  ipv4      192.168.124.159/24
      -               -
 2016-09-09 14:18:00  54:52:00:86:01:03  ipv4      192.168.124.160/24
      -               -

despite 'name' being populated in the 'host' entry.

# virsh net-dumpxml default
<network>
  <name>default</name>
  <uuid>2215facb-0f96-40f1-b5d4-28d46675d18d</uuid>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65535'/>
    </nat>
  </forward>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='52:54:00:43:4b:30'/>
  <ip address='192.168.124.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.124.2' end='192.168.124.254'/>
      <host mac='54:52:00:86:01:01' name='kube-1' ip='192.168.122.87'/>
      <host mac='54:52:00:86:01:02' name='kube-2' ip='192.168.122.88'/>
      <host mac='54:52:00:86:01:03' name='kube-3' ip='192.168.122.89'/>
    </dhcp>
  </ip>
</network>

Version-Release number of selected component (if applicable):

libvirt-1.2.17-13.el7_2.5.src.rpm

How reproducible:

100%

Steps to Reproduce:
1. sudo virsh net-update default add ip-dhcp-host "<host mac='${SOMEMAC}' name='test-1' ip='192.168.124.158'/>" --live --config
2. create and start a VM that uses ${SOMEMAC}
3. virsh net-dhcp-leases default

Actual results:

# virsh net-dhcp-leases default
 Expiry Time          MAC address        Protocol  IP address
      Hostname        Client ID or DUID
-------------------------------------------------------------------------------------------------------------------
 2016-09-09 14:17:52  54:52:00:86:01:01  ipv4      192.168.124.158/24
      -               -


Expected results:

 Expiry Time          MAC address        Protocol  IP address
      Hostname        Client ID or DUID
-------------------------------------------------------------------------------------------------------------------
 2016-09-09 14:17:52  54:52:00:86:01:01  ipv4      192.168.124.158/24
      test-1               -

Additional info:

Comment 1 Andrew Beekhof 2016-09-12 04:37:01 UTC
Bah

Apparently this is what happens when you specify an IP outside of the network's dhcp range:

      <range start='192.168.124.2' end='192.168.124.254'/>
      <host mac='54:52:00:86:01:01' name='kube-1' ip='192.168.122.87'/>