|
|
982648 |
From bc34e4669322664483b370f6c606a9caaaea4d5a Mon Sep 17 00:00:00 2001
|
|
|
982648 |
Message-Id: <bc34e4669322664483b370f6c606a9caaaea4d5a@dist-git>
|
|
|
982648 |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
|
982648 |
Date: Thu, 26 Jul 2018 11:41:09 +0200
|
|
|
982648 |
Subject: [PATCH] networkGetDHCPLeases: Don't always report error if unable to
|
|
|
982648 |
read leases file
|
|
|
982648 |
|
|
|
982648 |
https://bugzilla.redhat.com/show_bug.cgi?id=1600468
|
|
|
982648 |
|
|
|
982648 |
If we are unable to read leases file (no matter what the reason
|
|
|
982648 |
is), we return 0 - just like if there were no leases. However,
|
|
|
982648 |
because we use virFileReadAll() an error is printed into the log.
|
|
|
982648 |
Note that not all networks have leases file - only those for
|
|
|
982648 |
which we start dnsmasq.
|
|
|
982648 |
|
|
|
982648 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
982648 |
Reviewed-by: Erik Skultety <eskultet@redhat.com>
|
|
|
982648 |
(cherry picked from commit 142c4b10fd8f55b7d2e86f5a184608da70f2edd3)
|
|
|
982648 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
982648 |
Reviewed-by: Erik Skultety <eskultet@redhat.com>
|
|
|
982648 |
---
|
|
|
982648 |
src/network/bridge_driver.c | 21 ++++++++++++++-------
|
|
|
982648 |
1 file changed, 14 insertions(+), 7 deletions(-)
|
|
|
982648 |
|
|
|
982648 |
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
|
|
|
982648 |
index ac849581ec..1ad95d524c 100644
|
|
|
982648 |
--- a/src/network/bridge_driver.c
|
|
|
982648 |
+++ b/src/network/bridge_driver.c
|
|
|
982648 |
@@ -4157,13 +4157,20 @@ networkGetDHCPLeases(virNetworkPtr net,
|
|
|
982648 |
custom_lease_file = networkDnsmasqLeaseFileNameCustom(driver, def->bridge);
|
|
|
982648 |
|
|
|
982648 |
/* Read entire contents */
|
|
|
982648 |
- if ((custom_lease_file_len = virFileReadAll(custom_lease_file,
|
|
|
982648 |
- VIR_NETWORK_DHCP_LEASE_FILE_SIZE_MAX,
|
|
|
982648 |
- &lease_entries)) < 0) {
|
|
|
982648 |
- /* Even though src/network/leaseshelper.c guarantees the existence of
|
|
|
982648 |
- * leases file (even if no leases are present), and the control reaches
|
|
|
982648 |
- * here, instead of reporting error, return 0 leases */
|
|
|
982648 |
- rv = 0;
|
|
|
982648 |
+ if ((custom_lease_file_len = virFileReadAllQuiet(custom_lease_file,
|
|
|
982648 |
+ VIR_NETWORK_DHCP_LEASE_FILE_SIZE_MAX,
|
|
|
982648 |
+ &lease_entries)) < 0) {
|
|
|
982648 |
+ /* Not all networks are guaranteed to have leases file.
|
|
|
982648 |
+ * Only those which run dnsmasq. Therefore, if we failed
|
|
|
982648 |
+ * to read the leases file, don't report error. Return 0
|
|
|
982648 |
+ * leases instead. */
|
|
|
982648 |
+ if (errno == ENOENT) {
|
|
|
982648 |
+ rv = 0;
|
|
|
982648 |
+ } else {
|
|
|
982648 |
+ virReportSystemError(errno,
|
|
|
982648 |
+ _("Unable to read leases file: %s"),
|
|
|
982648 |
+ custom_lease_file);
|
|
|
982648 |
+ }
|
|
|
982648 |
goto error;
|
|
|
982648 |
}
|
|
|
982648 |
|
|
|
982648 |
--
|
|
|
982648 |
2.18.0
|
|
|
982648 |
|