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