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:
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
[root@test ~]# rpm -q libvirt
[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
Steps to Reproduce:
1.virsh net-start default
2.ps ax|grep dnsmasq
[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
/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....
*** 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:
Author: Josh Stone <firstname.lastname@example.org>
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:
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 email@example.com, 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:
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:
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:
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: