Blame SOURCES/libvirt-util-suppress-unimportant-ovs-vsctl-errors-when-getting-interface-stats.patch

0a7476
From 299fe2bb28582a9e26453355909ee5132c374936 Mon Sep 17 00:00:00 2001
0a7476
Message-Id: <299fe2bb28582a9e26453355909ee5132c374936@dist-git>
0a7476
From: Laine Stump <laine@laine.org>
0a7476
Date: Thu, 2 May 2019 13:23:35 -0400
0a7476
Subject: [PATCH] util: suppress unimportant ovs-vsctl errors when getting
0a7476
 interface stats
0a7476
0a7476
commit edaf13565 modified the stats retrieval for OVS interfaces to
0a7476
not fail when one of the fields was unrecognized by the ovs-vsctl
0a7476
command, but ovs-vsctl was still returning an error, and libvirt was
0a7476
cluttering the logs with these inconsequential error messages.
0a7476
0a7476
This patch modifies the GET_STAT macro to add "--if-exists" to the
0a7476
ovs-vsctl command, which causes it to return an empty string (and exit
0a7476
with success) if the requested statistic isn't in its database, thus
0a7476
eliminating the ugly error messages from the log.
0a7476
0a7476
Resolves: https://bugzilla.redhat.com/1683175
0a7476
0a7476
Signed-off-by: Laine Stump <laine@laine.org>
0a7476
(cherry picked from commit 3f7cba3f5ea1731b9028b89b671cbd7e7d5e0421)
0a7476
Signed-off-by: Laine Stump <laine@redhat.com>
0a7476
Message-Id: <20190502172335.6691-1-laine@redhat.com>
0a7476
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
0a7476
---
0a7476
 src/util/virnetdevopenvswitch.c | 6 +++---
0a7476
 1 file changed, 3 insertions(+), 3 deletions(-)
0a7476
0a7476
diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
0a7476
index f86f698430..f36916a300 100644
0a7476
--- a/src/util/virnetdevopenvswitch.c
0a7476
+++ b/src/util/virnetdevopenvswitch.c
0a7476
@@ -363,10 +363,10 @@ virNetDevOpenvswitchInterfaceStats(const char *ifname,
0a7476
         virCommandFree(cmd); \
0a7476
         cmd = virCommandNew(OVSVSCTL); \
0a7476
         virNetDevOpenvswitchAddTimeout(cmd); \
0a7476
-        virCommandAddArgList(cmd, "get", "Interface", ifname, \
0a7476
-                             "statistics:" name, NULL); \
0a7476
+        virCommandAddArgList(cmd, "--if-exists", "get", "Interface", \
0a7476
+                             ifname, "statistics:" name, NULL); \
0a7476
         virCommandSetOutputBuffer(cmd, &output); \
0a7476
-        if (virCommandRun(cmd, NULL) < 0) { \
0a7476
+        if (virCommandRun(cmd, NULL) < 0 || !output || !*output || *output == '\n') { \
0a7476
             stats->member = -1; \
0a7476
         } else { \
0a7476
             if (virStrToLong_ll(output, &tmp, 10, &stats->member) < 0 || \
0a7476
-- 
0a7476
2.21.0
0a7476