mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
networkGetDHCPLeases: Don't always report error if unable to read leases file
https://bugzilla.redhat.com/show_bug.cgi?id=1600468 If we are unable to read leases file (no matter what the reason is), we return 0 - just like if there were no leases. However, because we use virFileReadAll() an error is printed into the log. Note that not all networks have leases file - only those for which we start dnsmasq. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
2eb748d259
commit
142c4b10fd
@ -4235,13 +4235,20 @@ networkGetDHCPLeases(virNetworkPtr net,
|
|||||||
custom_lease_file = networkDnsmasqLeaseFileNameCustom(driver, def->bridge);
|
custom_lease_file = networkDnsmasqLeaseFileNameCustom(driver, def->bridge);
|
||||||
|
|
||||||
/* Read entire contents */
|
/* Read entire contents */
|
||||||
if ((custom_lease_file_len = virFileReadAll(custom_lease_file,
|
if ((custom_lease_file_len = virFileReadAllQuiet(custom_lease_file,
|
||||||
VIR_NETWORK_DHCP_LEASE_FILE_SIZE_MAX,
|
VIR_NETWORK_DHCP_LEASE_FILE_SIZE_MAX,
|
||||||
&lease_entries)) < 0) {
|
&lease_entries)) < 0) {
|
||||||
/* Even though src/network/leaseshelper.c guarantees the existence of
|
/* Not all networks are guaranteed to have leases file.
|
||||||
* leases file (even if no leases are present), and the control reaches
|
* Only those which run dnsmasq. Therefore, if we failed
|
||||||
* here, instead of reporting error, return 0 leases */
|
* to read the leases file, don't report error. Return 0
|
||||||
rv = 0;
|
* leases instead. */
|
||||||
|
if (errno == ENOENT) {
|
||||||
|
rv = 0;
|
||||||
|
} else {
|
||||||
|
virReportSystemError(errno,
|
||||||
|
_("Unable to read leases file: %s"),
|
||||||
|
custom_lease_file);
|
||||||
|
}
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user