Bug 913446 - RFE: network: allow configuring dhcp lease time
Summary: RFE: network: allow configuring dhcp lease time
Keywords:
Status: NEW
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: All
OS: All
unspecified
unspecified
Target Milestone: ---
Assignee: Libvirt Maintainers
QA Contact:
URL:
Whiteboard: LibvirtFirstBug
: 1244736 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-02-21 09:35 UTC by xingxing
Modified: 2019-11-30 22:31 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Bugzilla 1131554 'medium' 'CLOSED' 'libvirt-client is not able to set dhcp lease time' 2019-12-02 19:03:18 UTC

Internal Links: 1131554

Description xingxing 2013-02-21 09:35:09 UTC
Description of problem:
when use libvirt defined network for vm,there are too many dnsmasq log in /var/log/messages, and in a windows vm, we can see a lot of dhcp fail log,sometimes when the dhcp lease time over,the windows vm cannot get ip through dhcp again.

dnsmasq support set dhcp lease time use --dhcp-range option like:
--dhcp-range 192.168.122.2,192,168,122,254,2d
the default is 1h, this time may be too short for us,so it's better for 
libvirt to support this option to set the lease time.

Version-Release number of selected component (if applicable):
[root@test ~]# uname -r
2.6.32-279.22.1.el6.x86_64
[root@test ~]# rpm -q libvirt
libvirt-0.9.10-21.el6_3.8.x86_64
[root@test ~]# virsh version
Compiled against library: libvir 0.9.10
Using library: libvir 0.9.10
Using API: QEMU 0.9.10
Running hypervisor: QEMU 0.12.1

How reproducible:
100%

Steps to Reproduce:
1.virsh net-start default
2.ps ax|grep dnsmasq
  
Actual results:
[root@test1 ~]# virsh net-start default
Network default started

[root@test1 ~]# ps ax|grep dnsmasq
 2933 ?        S      0:00 /usr/sbin/dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/libvirt/network/default.pid --conf-file= --except-interface lo --listen-address 10.0.0.1 --dhcp-range 10.0.0.2,10.0.0.254 --dhcp-leasefile=/var/lib/libvirt/dnsmasq/default.leases --dhcp-lease-max=253 --dhcp-no-override --dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile

Expected results:
/usr/sbin/dnsmasq --strict-order ... --dhcp-range 10.0.0.2,10.0.0.254,infinite(or other lease time) --dhcp-leasefile=/var/lib/libvirt/d....

Additional info:

Comment 3 Alberto Ruiz 2015-10-22 16:23:55 UTC
*** Bug 1244736 has been marked as a duplicate of this bug. ***

Comment 4 Alberto Ruiz 2015-10-22 16:39:56 UTC
I looked into this from the implementation POV, basically the network XML format does not support this at all so everything relies on dnsmasq's default lease time. This should be trivially fixed by adding an XML tag for the lease expiry length and setting it in the dhcp-range record accordingly, if the XML tag uses the same format as dnsmasq then there's no translation needed.

Comment 5 Alberto Ruiz 2016-02-13 10:33:01 UTC
Any progress on this?

Comment 6 Cole Robinson 2016-04-10 12:50:36 UTC
(In reply to Alberto Ruiz from comment #5)
> Any progress on this?

No, I doubt anyone is actively working on this. If you need this feature then I suggest sending patches, it should be fairly straight forward as you suggest.

Possible XML could be <dhcp leaseTime=XXX/>  or <dhcp><leaseTime>XXX</leaseTime> or <dhcp><lease time=XXX/>

network XML format extended in src/conf/network_conf.c
dnsmasq option handling in src/network/bridge_driver.c
extend documentation and test suite

An example commit to follow that handles all those bits:

commit 298fa4858ced29e2c42681635a5a8dcd6da0b231
Author: Josh Stone <jistone@redhat.com>
Date:   Wed Dec 3 16:01:33 2014 -0800

    network: Let domains be restricted to local DNS

Comment 7 Alberto Ruiz 2016-04-13 16:06:09 UTC
I've created an attemptive patch for this, any feedback is welcome:

https://github.com/libvirt/libvirt/compare/master...aruiz:master

Comment 8 Cole Robinson 2016-04-14 22:18:21 UTC
Thanks for the patch! A quick look that seems sensible except like the patch points out we should sanitize or handle the time string value. We may not want to do straight passthrough to dnsmasq since then we our XML API is dependent on their semantics.

Please git send-email that patch to libvir-list@redhat.com, even as is, so we can discuss that point with a larger audience

Comment 9 Peter Krempa 2016-09-23 07:50:29 UTC
This did not make the list yet.

Comment 10 Alberto Ruiz 2016-09-23 07:52:05 UTC
I actually have a local branch where I'm implementing this, I struggled with making hostfiles part of the testable outcomes as I want to add support for leasetime on a per host basis as part of the patch.

Comment 11 Peter Krempa 2016-09-23 07:56:27 UTC
You probably should then assign the bug to yourself to notify people you are working on it.

In the meanwhile we have a submission on the libvir-list:

https://www.redhat.com/archives/libvir-list/2016-September/msg01063.html

If you have different opinion how to implement it you should respond to that patch.

Comment 12 Alberto Ruiz 2016-10-06 21:16:28 UTC
I've finally rebased my patchset to a private branch in my github account:

https://github.com/libvirt/libvirt/compare/master...aruiz:master

Before I propose this in the list I need to write the actual tests cases for all the per-hosts lease combinations (hostsfiles are kinda complicated and have many syntaxes depending on ipv4/6 and other aspects).

Will prolly spend some time on this tomorrow and propose the final patchset on the list. Sorry it took me so long.

Comment 13 Alberto Ruiz 2016-10-19 22:52:21 UTC
I've proposed an updated patch with no further comments:

https://www.redhat.com/archives/libvir-list/2016-October/msg00561.html

Comment 14 Paul Elliott 2017-06-05 14:53:07 UTC
This patch would be really useful to our specific use case. Is there anything we can do to help this ticket progress?

Comment 15 Alberto Ruiz 2017-06-20 17:39:01 UTC
The patch works, I submitted it to the mailing list but it got ignored. Not sure what to do to move things forward.

Comment 16 Alberto Ruiz 2017-06-23 00:51:53 UTC
You can follow the discussion in this thread:

https://www.redhat.com/archives/libvir-list/2017-June/msg00983.html


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