]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: Implement vshTable API to domblkinfo
authorSimon Kobyda <skobyda@redhat.com>
Fri, 21 Sep 2018 14:17:18 +0000 (16:17 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 24 Sep 2018 07:09:14 +0000 (09:09 +0200)
Signed-off-by: Simon Kobyda <skobyda@redhat.com>
tools/virsh-domain-monitor.c

index 00ff6a649169256b413bff2f05972f155534a3aa..b6fe31cc72be25c6f2ba63a12f70f2f54992159e 100644 (file)
@@ -460,6 +460,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
     char *cap = NULL;
     char *alloc = NULL;
     char *phy = NULL;
+    vshTablePtr table = NULL;
 
     if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
         return false;
@@ -483,11 +484,10 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
         if (ndisks < 0)
             goto cleanup;
 
-        /* print the title */
-        vshPrintExtra(ctl, "%-10s %-15s %-15s %-15s\n", _("Target"),
-                      _("Capacity"), _("Allocation"), _("Physical"));
-        vshPrintExtra(ctl, "-----------------------------"
-                      "------------------------\n");
+        /* title */
+        table = vshTableNew(_("Target"), _("Capacity"), _("Allocation"), _("Physical"), NULL);
+        if (!table)
+            goto cleanup;
 
         for (i = 0; i < ndisks; i++) {
             ctxt->node = disks[i];
@@ -512,11 +512,15 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
 
             if (!cmdDomblkinfoGet(ctl, &info, &cap, &alloc, &phy, human))
                 goto cleanup;
-            vshPrint(ctl, "%-10s %-15s %-15s %-15s\n", target, cap, alloc, phy);
+            if (vshTableRowAppend(table, target, cap, alloc, phy, NULL) < 0)
+                goto cleanup;
 
             VIR_FREE(target);
             VIR_FREE(protocol);
         }
+
+        vshTablePrintToStdout(table, ctl);
+
     } else {
         if (virDomainGetBlockInfo(dom, device, &info, 0) < 0)
             goto cleanup;
@@ -531,6 +535,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
     ret = true;
 
  cleanup:
+    vshTableFree(table);
     VIR_FREE(cap);
     VIR_FREE(alloc);
     VIR_FREE(phy);