Signed-off-by: K Shiva Kiran <shiva_kr@xxxxxxxxxx> --- tools/virsh-nwfilter.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c index 801a52746e..ca803865bf 100644 --- a/tools/virsh-nwfilter.c +++ b/tools/virsh-nwfilter.c @@ -407,6 +407,10 @@ static const vshCmdInfo info_nwfilter_list[] = { }; static const vshCmdOptDef opts_nwfilter_list[] = { + {.name = "title", + .type = VSH_OT_BOOL, + .help = N_("show network filter title") + }, {.name = NULL} }; @@ -416,13 +420,18 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) size_t i; char uuid[VIR_UUID_STRING_BUFLEN]; bool ret = false; + bool optTitle = vshCommandOptBool(cmd, "title"); struct virshNWFilterList *list = NULL; g_autoptr(vshTable) table = NULL; if (!(list = virshNWFilterListCollect(ctl, 0))) return false; - table = vshTableNew(_("UUID"), _("Name"), NULL); + if (optTitle) + table = vshTableNew(_("UUID"), _("Name"), _("Title"), NULL); + else + table = vshTableNew(_("UUID"), _("Name"), NULL); + if (!table) goto cleanup; @@ -430,11 +439,26 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) virNWFilterPtr nwfilter = list->filters[i]; virNWFilterGetUUIDString(nwfilter, uuid); - if (vshTableRowAppend(table, - uuid, - virNWFilterGetName(nwfilter), - NULL) < 0) - goto cleanup; + + if (optTitle) { + g_autofree char *title = NULL; + if (!(title = virshGetNWFilterDescription(ctl, nwfilter, true, 0, 0))) + goto cleanup; + + if (vshTableRowAppend(table, + uuid, + virNWFilterGetName(nwfilter), + title, + NULL) < 0) + goto cleanup; + + } else { + if (vshTableRowAppend(table, + uuid, + virNWFilterGetName(nwfilter), + NULL) < 0) + goto cleanup; + } } vshTablePrintToStdout(table, ctl); -- 2.42.0