[libvirt] [PATCH 1/4] virsh-pool: Unify spacing of listing function

Peter Krempa pkrempa at redhat.com
Tue Nov 12 16:48:53 UTC 2013


Change the alignment to match the domain listing function.

Before:

$ virsh pool-list
Name                 State      Autostart
-----------------------------------------
boot-scratch         active     no
default              active     no
glusterpool          active     no

$ virsh pool-list --details
Name          State    Autostart  Persistent    Capacity  Allocation  Available
-------------------------------------------------------------------------------
boot-scratch  running  no         yes         117.99 GiB  101.40 GiB  16.60 GiB
default       running  no         yes         117.99 GiB  101.40 GiB  16.60 GiB
glusterpool   running  no         yes          29.40 GiB   44.23 MiB  29.36 GiB

After:

$ virsh pool-list
 Name                 State      Autostart
-------------------------------------------
 boot-scratch         active     no
 default              active     no
 glusterpool          active     no

$ virsh pool-list --details
 Name          State    Autostart  Persistent    Capacity  Allocation  Available
---------------------------------------------------------------------------------
 boot-scratch  running  no         yes         117.99 GiB  101.40 GiB  16.60 GiB
 default       running  no         yes         117.99 GiB  101.40 GiB  16.60 GiB
 glusterpool   running  no         yes          29.40 GiB   44.23 MiB  29.36 GiB
---
 tools/virsh-pool.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
index c771226..18fe242 100644
--- a/tools/virsh-pool.c
+++ b/tools/virsh-pool.c
@@ -1191,14 +1191,14 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
     /* Output basic info then return if --details option not selected */
     if (!details) {
         /* Output old style header */
-        vshPrintExtra(ctl, "%-20s %-10s %-10s\n", _("Name"), _("State"),
+        vshPrintExtra(ctl, " %-20s %-10s %-10s\n", _("Name"), _("State"),
                       _("Autostart"));
-        vshPrintExtra(ctl, "-----------------------------------------\n");
+        vshPrintExtra(ctl, "-------------------------------------------\n");

         /* Output old style pool info */
         for (i = 0; i < list->npools; i++) {
             const char *name = virStoragePoolGetName(list->pools[i]);
-            vshPrint(ctl, "%-20s %-10s %-10s\n",
+            vshPrint(ctl, " %-20s %-10s %-10s\n",
                  name,
                  poolInfoTexts[i].state,
                  poolInfoTexts[i].autostart);
@@ -1266,7 +1266,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
      * the longest string.
      */
     ret = virAsprintf(&outputStr,
-              "%%-%lus  %%-%lus  %%-%lus  %%-%lus  %%%lus  %%%lus  %%%lus\n",
+              " %%-%lus  %%-%lus  %%-%lus  %%-%lus  %%%lus  %%%lus  %%%lus\n",
               (unsigned long) nameStrLength,
               (unsigned long) stateStrLength,
               (unsigned long) autostartStrLength,
@@ -1285,7 +1285,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
     for (i = nameStrLength + stateStrLength + autostartStrLength
                            + persistStrLength + capStrLength
                            + allocStrLength + availStrLength
-                           + 12; i > 0; i--)
+                           + 14; i > 0; i--)
         vshPrintExtra(ctl, "-");
     vshPrintExtra(ctl, "\n");

-- 
1.8.4.3




More information about the libvir-list mailing list