[PATCH 08/13] virsh: Implement vshTable API to domblklist

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

 



Signed-off-by: Simon Kobyda <skobyda@xxxxxxxxxx>
---
 tools/virsh-domain-monitor.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 05db825716..b9b6739287 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -589,6 +589,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
     char *device = NULL;
     char *target = NULL;
     char *source = NULL;
+    vshTablePtr table = NULL;
 
     if (vshCommandOptBool(cmd, "inactive"))
         flags |= VIR_DOMAIN_XML_INACTIVE;
@@ -603,12 +604,12 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
 
     if (details)
-        vshPrintExtra(ctl, "%-10s %-10s %-10s %s\n", _("Type"),
-                      _("Device"), _("Target"), _("Source"));
+        table = vshTableNew("Type", "Device", "Target", "Source", NULL);
     else
-        vshPrintExtra(ctl, "%-10s %s\n", _("Target"), _("Source"));
+        table = vshTableNew("Target", "Source", NULL);
 
-    vshPrintExtra(ctl, "------------------------------------------------\n");
+    if (!table)
+        goto cleanup;
 
     for (i = 0; i < ndisks; i++) {
         ctxt->node = disks[i];
@@ -633,10 +634,13 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
                                 "|./source/@name"
                                 "|./source/@volume)", ctxt);
         if (details) {
-            vshPrint(ctl, "%-10s %-10s %-10s %s\n", type, device,
-                     target, source ? source : "-");
+            if (vshTableRowAppend(table, type, device, target,
+                                  source ? source : "-", NULL) < 0)
+                goto cleanup;
         } else {
-            vshPrint(ctl, "%-10s %s\n", target, source ? source : "-");
+            if (vshTableRowAppend(table, target,
+                                  source ? source : "-", NULL) < 0)
+                goto cleanup;
         }
 
         VIR_FREE(source);
@@ -645,9 +649,12 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
         VIR_FREE(type);
     }
 
+    vshTablePrintToStdout(table, ctl);
+
     ret = true;
 
  cleanup:
+    vshTableFree(table);
     VIR_FREE(source);
     VIR_FREE(target);
     VIR_FREE(device);
-- 
2.17.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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