From nobody Mon Feb 9 09:32:46 2026 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1537539458033470.0568331032181; Fri, 21 Sep 2018 07:17:38 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DC89B8CD0; Fri, 21 Sep 2018 14:17:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A05C05C3FD; Fri, 21 Sep 2018 14:17:35 +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 5628B181A12F; Fri, 21 Sep 2018 14:17:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8LEHW0j028252 for ; Fri, 21 Sep 2018 10:17:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1362053C21; Fri, 21 Sep 2018 14:17:32 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E8D517964; Fri, 21 Sep 2018 14:17:31 +0000 (UTC) From: Simon Kobyda To: libvir-list@redhat.com Date: Fri, 21 Sep 2018 16:17:15 +0200 Message-Id: <20180921141724.18879-5-skobyda@redhat.com> In-Reply-To: <20180921141724.18879-1-skobyda@redhat.com> References: <20180921141724.18879-1-skobyda@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Simon Kobyda Subject: [libvirt] [PATCH v2 04/13] virsh: Implement vshTable API to nwfilter-list and nwfilterbinding-list 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: , MIME-Version: 1.0 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 21 Sep 2018 14:17:36 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Simon Kobyda --- tools/virsh-nwfilter.c | 47 +++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c index 1cdbe5053a..b680ea082c 100644 --- a/tools/virsh-nwfilter.c +++ b/tools/virsh-nwfilter.c @@ -31,6 +31,7 @@ #include "viralloc.h" #include "virfile.h" #include "virutil.h" +#include "vsh-table.h" =20 virNWFilterPtr virshCommandOptNWFilterBy(vshControl *ctl, const vshCmd *cmd, @@ -359,26 +360,35 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd AT= TRIBUTE_UNUSED) { size_t i; char uuid[VIR_UUID_STRING_BUFLEN]; + bool ret =3D false; virshNWFilterListPtr list =3D NULL; + vshTablePtr table =3D NULL; =20 if (!(list =3D virshNWFilterListCollect(ctl, 0))) return false; =20 - vshPrintExtra(ctl, " %-36s %-20s \n", _("UUID"), _("Name")); - vshPrintExtra(ctl, "---------------------------------" - "---------------------------------\n"); + table =3D vshTableNew(_("UUID"), _("Name"), NULL); + if (!table) + goto cleanup; =20 for (i =3D 0; i < list->nfilters; i++) { virNWFilterPtr nwfilter =3D list->filters[i]; =20 virNWFilterGetUUIDString(nwfilter, uuid); - vshPrint(ctl, " %-36s %-20s\n", - uuid, - virNWFilterGetName(nwfilter)); + if (vshTableRowAppend(table, + uuid, + virNWFilterGetName(nwfilter), + NULL) < 0) + goto cleanup; } =20 + vshTablePrintToStdout(table, ctl); + + ret =3D true; + cleanup: + vshTableFree(table); virshNWFilterListFree(list); - return true; + return ret; } =20 /* @@ -714,25 +724,34 @@ static bool cmdNWFilterBindingList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) { size_t i; + bool ret =3D false; virshNWFilterBindingListPtr list =3D NULL; + vshTablePtr table =3D NULL; =20 if (!(list =3D virshNWFilterBindingListCollect(ctl, 0))) return false; =20 - vshPrintExtra(ctl, " %-20s %-20s \n", _("Port Dev"), _("Filter")); - vshPrintExtra(ctl, "---------------------------------" - "---------------------------------\n"); + table =3D vshTableNew(_("Port Dev"), _("Filter"), NULL); + if (!table) + goto cleanup; =20 for (i =3D 0; i < list->nbindings; i++) { virNWFilterBindingPtr binding =3D list->bindings[i]; =20 - vshPrint(ctl, " %-20s %-20s\n", - virNWFilterBindingGetPortDev(binding), - virNWFilterBindingGetFilterName(binding)); + if (vshTableRowAppend(table, + virNWFilterBindingGetPortDev(binding), + virNWFilterBindingGetFilterName(binding), + NULL) < 0) + goto cleanup; } =20 + vshTablePrintToStdout(table, ctl); + + ret =3D true; + cleanup: + vshTableFree(table); virshNWFilterBindingListFree(list); - return true; + return ret; } =20 =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list