[PATCH 11/16] virsh: Add option --title for nwfilter-list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux