From nobody Tue Apr 30 04:33:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1553713509016181.1854609561567; Wed, 27 Mar 2019 12:05:09 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 38A013001C90; Wed, 27 Mar 2019 19:04:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A4C6B182FE; Wed, 27 Mar 2019 19:04:52 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8A86141F3D; Wed, 27 Mar 2019 19:04:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2RJ4lI7001578 for ; Wed, 27 Mar 2019 15:04:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id AF97D6013C; Wed, 27 Mar 2019 19:04:47 +0000 (UTC) Received: from vhost2.laine.org (ovpn-116-122.phx2.redhat.com [10.3.116.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5262787C1; Wed, 27 Mar 2019 19:04:43 +0000 (UTC) From: Laine Stump To: libvir-list@redhat.com Date: Wed, 27 Mar 2019 15:04:39 -0400 Message-Id: <20190327190439.27293-1-laine@laine.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Michal Privoznik Subject: [libvirt] [PATCH] util: suppress unimportant ovs-vsctl errors when getting interface stats X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 27 Mar 2019 19:05:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" 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 --- src/util/virnetdevopenvswitch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitc= h.c index 4fa3a5742a..e5a45f59ec 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -335,10 +335,10 @@ virNetDevOpenvswitchInterfaceStats(const char *ifname, virCommandFree(cmd); \ cmd =3D 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 =3D=3D '\n= ') { \ stats->member =3D -1; \ } else { \ if (virStrToLong_ll(output, &tmp, 10, &stats->member) < 0 || \ --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list