render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Pablo Greco 40546a
From 53282d1e7f34724c6be7704ec56324c507894397 Mon Sep 17 00:00:00 2001
Pablo Greco 40546a
Message-Id: <53282d1e7f34724c6be7704ec56324c507894397@dist-git>
Pablo Greco 40546a
From: Laine Stump <laine@laine.org>
Pablo Greco 40546a
Date: Tue, 30 Jul 2019 15:30:50 +0200
Pablo Greco 40546a
Subject: [PATCH] util: suppress unimportant ovs-vsctl errors when getting
Pablo Greco 40546a
 interface stats
Pablo Greco 40546a
MIME-Version: 1.0
Pablo Greco 40546a
Content-Type: text/plain; charset=UTF-8
Pablo Greco 40546a
Content-Transfer-Encoding: 8bit
Pablo Greco 40546a
Pablo Greco 40546a
commit edaf13565 modified the stats retrieval for OVS interfaces to
Pablo Greco 40546a
not fail when one of the fields was unrecognized by the ovs-vsctl
Pablo Greco 40546a
command, but ovs-vsctl was still returning an error, and libvirt was
Pablo Greco 40546a
cluttering the logs with these inconsequential error messages.
Pablo Greco 40546a
Pablo Greco 40546a
This patch modifies the GET_STAT macro to add "--if-exists" to the
Pablo Greco 40546a
ovs-vsctl command, which causes it to return an empty string (and exit
Pablo Greco 40546a
with success) if the requested statistic isn't in its database, thus
Pablo Greco 40546a
eliminating the ugly error messages from the log.
Pablo Greco 40546a
Pablo Greco 40546a
Resolves: https://bugzilla.redhat.com/1683175
Pablo Greco 40546a
Pablo Greco 40546a
Signed-off-by: Laine Stump <laine@laine.org>
Pablo Greco 40546a
(cherry picked from commit 3f7cba3f5ea1731b9028b89b671cbd7e7d5e0421)
Pablo Greco 40546a
Pablo Greco 40546a
Prerequisite of: https://bugzilla.redhat.com/show_bug.cgi?id=1721434
Pablo Greco 40546a
Pablo Greco 40546a
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Pablo Greco 40546a
Message-Id: <e0309b32467a30a8a9be8371ef8cbba1713d662c.1564493409.git.mprivozn@redhat.com>
Pablo Greco 40546a
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Pablo Greco 40546a
---
Pablo Greco 40546a
 src/util/virnetdevopenvswitch.c | 6 +++---
Pablo Greco 40546a
 1 file changed, 3 insertions(+), 3 deletions(-)
Pablo Greco 40546a
Pablo Greco 40546a
diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
Pablo Greco 40546a
index 2f5c7ac789..cb403aaf2e 100644
Pablo Greco 40546a
--- a/src/util/virnetdevopenvswitch.c
Pablo Greco 40546a
+++ b/src/util/virnetdevopenvswitch.c
Pablo Greco 40546a
@@ -342,10 +342,10 @@ virNetDevOpenvswitchInterfaceStats(const char *ifname,
Pablo Greco 40546a
         virCommandFree(cmd); \
Pablo Greco 40546a
         cmd = virCommandNew(OVSVSCTL); \
Pablo Greco 40546a
         virNetDevOpenvswitchAddTimeout(cmd); \
Pablo Greco 40546a
-        virCommandAddArgList(cmd, "get", "Interface", ifname, \
Pablo Greco 40546a
-                             "statistics:" name, NULL); \
Pablo Greco 40546a
+        virCommandAddArgList(cmd, "--if-exists", "get", "Interface", \
Pablo Greco 40546a
+                             ifname, "statistics:" name, NULL); \
Pablo Greco 40546a
         virCommandSetOutputBuffer(cmd, &output); \
Pablo Greco 40546a
-        if (virCommandRun(cmd, NULL) < 0) { \
Pablo Greco 40546a
+        if (virCommandRun(cmd, NULL) < 0 || !output || !*output || *output == '\n') { \
Pablo Greco 40546a
             stats->member = -1; \
Pablo Greco 40546a
         } else { \
Pablo Greco 40546a
             if (virStrToLong_ll(output, &tmp, 10, &stats->member) < 0 || \
Pablo Greco 40546a
-- 
Pablo Greco 40546a
2.22.0
Pablo Greco 40546a