Bug 1205045 - Command net-dhcp-leases enhancement
Summary: Command net-dhcp-leases enhancement
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.1
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Pavel Hrdina
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-03-24 06:43 UTC by yanbing du
Modified: 2015-11-19 06:24 UTC (History)
4 users (show)

Fixed In Version: libvirt-1.2.13-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-11-19 06:24:45 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:2202 0 normal SHIPPED_LIVE libvirt bug fix and enhancement update 2015-11-19 08:17:58 UTC

Description yanbing du 2015-03-24 06:43:17 UTC
Description of problem:


Version-Release number of selected component (if applicable):
1. Keep the lease during VM running
2. If the status file not exist, it should be treat as no lease yet, but filter with a specific MAC address should report error.

How reproducible:
libvirt-1.2.8-16.el7_1.2.x86_64 

Steps to Reproduce:
Issue 1:
1. Start a VM, which using the 'default' network:
# virsh dumpxml virt-tests-vm1
...
    <interface type='network'>
      <mac address='52:54:00:11:b5:47'/>
      <source network='default' bridge='virbr0'/>
      <target dev='vnet0'/>
      <model type='virtio'/>
      <alias name='net0'/>
...
2. Check the dhcp leases info
# virsh net-dhcp-leases default
 Expiry Time          MAC address        Protocol  IP address       Hostname        Client ID or DUID
-------------------------------------------------------------------------------------------------------------------
 2015-03-20 12:37:17  52:54:00:11:b5:47  ipv4      192.168.122.107/24       vm2-ydu1   
     -
# cat /var/lib/libvirt/dnsmasq/virbr0.status 
[
    {
        "ip-address": "192.168.122.107",
        "mac-address": "52:54:00:11:b5:47",
        "hostname": "vm2-ydu1",
        "expiry-time": 1426826237
    }
]

Then, keep the VM running and after the time count down to '2015-03-20 12:37:17', and run the command again, there's no lease info return.
But the VM do have the lease, and the 'default.leases' file keep update the expiry time(The value in this example is not update yet)
# cat /var/lib/libvirt/dnsmasq/default.leases
1426750046 52:54:00:11:b5:47 192.168.122.107 vm2-ydu1 *

and the status file not update automatically.

Issue 2:
1. Create/Define start a network(Using the 'default' network a temple)
Just edit network name, bridge name and ip/dhcp range
# virsh net-dumpxml virttestnet
<network>
  <name>virttestnet</name>
  <uuid>34ff4355-ccb8-4a77-98f6-48a0efe477c8</uuid>
  <forward mode='nat'>
    <nat>
      <port start='1024' end='65533'/>
    </nat>
  </forward>
  <bridge name='virbr2' stp='on' delay='0'/>
  <mac address='52:54:00:26:33:12'/>
  <domain name='virttestnet'/>
  <ip address='192.168.110.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.110.2' end='192.168.110.254'/>
    </dhcp>
  </ip>
</network>

As no VM use this network, so the dhcp lease should be empty, and not 'virbr2.status' file create.
There' an error in libvirtd.log:
Mar 23 10:16:20 localhost journal: Failed to open file '/var/lib/libvirt/dnsmasq/virbr2.status': No such file or directory 


2. Run command to check the dhcp leases
# virsh net-dhcp-leases virttestnet
 Expiry Time          MAC address        Protocol  IP address       Hostname        Client ID or DUID
-------------------------------------------------------------------------------------------------------------------

3. Run it again by using an invalid MAC address(Expect command fail)
# virsh  net-dhcp-leases virttestnet --mac 0000000000000000000000000
 Expiry Time          MAC address        Protocol  IP address       Hostname        Client ID or DUID
-------------------------------------------------------------------------------------------------------------------

# echo $?
0


Actual results:


Expected results:
1. command return leases info if there's active interfaces

2. # virsh  net-dhcp-leases virttestnet --mac 0000000000000000000000000
error: Failed to get leases info for virttestnet
error: internal error: no lease with matching MAC address: 0000000000000000000000000

Additional info:

Comment 1 Pavel Hrdina 2015-05-25 14:18:03 UTC
At first, you should have filed those two issues as separated bugs.

Both issues has been fixed in v1.2.11 by commit:

commit 0f87054b61d73493fb505ecb97bd16615bc53699
Author: Nehal J Wani <nehaljw.kkd1@gmail.com>
Date:   Tue Nov 18 22:46:25 2014 +0530

    leaseshelper: improvements to support all events
    
    This patch enables the helper program to detect event(s) triggered when
    there is a change in lease length or expiry and client-id. This
    transfers complete control of leases database to libvirt and obsoletes
    use of the lease database file (<network-name>.leases). That file will
    not be created, read, or written.  This is achieved by adding the option
    --leasefile-ro to dnsmasq and passing a custom env var to leaseshelper,
    which helps us map events related to leases with their corresponding
    network bridges, no matter what the event be.
    
    Also, this requires the addition of a new non-lease entry in our custom
    lease database: "server-duid". It is required to identify a DHCPv6
    server.
    
    Now that dnsmasq doesn't maintain its own leases database, it relies on
    our helper program to tell it about previous leases and server duid.
    Thus, this patch makes our leases program honor an extra action: "init",
    in which it sends the known info in a particular format to dnsmasq
    by printing it to stdout.
    
    The drawback of this change is that upgrade to this new approach does
    not transfer the existing leases for the network if the leaseshelper
    wasn't already used.

Comment 3 Shanzhi Yu 2015-09-10 03:29:42 UTC
Verify this bug with libvirt-1.2.17-8.el7.x86_64


# virsh net-dhcp-leases default 
 Expiry Time          MAC address        Protocol  IP address                Hostname        Client ID or DUID
-------------------------------------------------------------------------------------------------------------------
 2015-09-10 11:34:42  52:54:00:18:95:1f  ipv4      192.168.122.147/24        -               -
 2015-09-10 11:35:07  52:54:00:40:2b:42  ipv4      192.168.122.217/24        test            -


# virsh net-dhcp-leases default 
 Expiry Time          MAC address        Protocol  IP address                Hostname        Client ID or DUID
-------------------------------------------------------------------------------------------------------------------
 2015-09-10 12:00:59  52:54:00:18:95:1f  ipv4      192.168.122.147/24        -               -
 2015-09-10 12:21:16  52:54:00:40:2b:42  ipv4      192.168.122.217/24        test            -

For the second issue, I have file one new bug to track. 
Bug 1261432

Comment 5 errata-xmlrpc 2015-11-19 06:24:45 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.

https://rhn.redhat.com/errata/RHBA-2015-2202.html


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