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:
*** Bug 1244736 has been marked as a duplicate of this bug. ***
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.
Any progress on this?
(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> Date: Wed Dec 3 16:01:33 2014 -0800 network: Let domains be restricted to local DNS
I've created an attemptive patch for this, any feedback is welcome: https://github.com/libvirt/libvirt/compare/master...aruiz:master
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, even as is, so we can discuss that point with a larger audience
This did not make the list yet.
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.
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.
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.
I've proposed an updated patch with no further comments: https://www.redhat.com/archives/libvir-list/2016-October/msg00561.html
This patch would be really useful to our specific use case. Is there anything we can do to help this ticket progress?
The patch works, I submitted it to the mailing list but it got ignored. Not sure what to do to move things forward.
You can follow the discussion in this thread: https://www.redhat.com/archives/libvir-list/2017-June/msg00983.html
Another attempt at lease time config here: https://www.redhat.com/archives/libvir-list/2020-April/msg00743.html
And I've merged patches upstream: 8589ecc69f networkxml2xmltest: Complete renaming of @actual 7e5a40fd0f tests: Add tests for <lease/> to cover dnsmasq settings 97a0aa2467 conf: Add <lease/> option for <dhcp/> settings v6.2.0-218-g8589ecc69f