From: Laine Stump Date: Wed, 27 Mar 2019 18:58:45 +0000 (-0400) Subject: util: suppress unimportant ovs-vsctl errors when getting interface stats X-Git-Tag: v5.2.0-rc2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f7cba3f5ea1731b9028b89b671cbd7e7d5e0421;p=thirdparty%2Flibvirt.git util: suppress unimportant ovs-vsctl errors when getting interface stats 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 --- diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c index 4fa3a5742a..c99ecfbf15 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -335,10 +335,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 || \