]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: pool-info: introduce option --bytes
authorChen Hanxiao <chenhanxiao@gmail.com>
Wed, 4 Jan 2017 01:01:21 +0000 (09:01 +0800)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 11 Jan 2017 00:24:41 +0000 (19:24 -0500)
By default, pool-info will convert sizes to human friendly units.

This patch will introduce option [--bytes].
If specified, the raw sizes will be in the output.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
docs/news.xml
tools/virsh-pool.c
tools/virsh.pod

index 80d582ebe647776e2c13cb1dc8ea95d11f0d95db..52be1c14bc453756554fbd869207cfc7b34d9429 100644 (file)
           features going forward.
         </description>
       </change>
+      <change>
+        <summary>
+          virsh: pool-info: introduce option --bytes
+        </summary>
+        <description>
+          Add option --bytes to virsh pool-info in order ti allow display
+          of units in bytes rather than default of human readable output.
+        </description>
+      </change>
     </section>
     <section title="Bug fixes">
       <change>
index 45b538efacf997f7f9a5c904e9198312b2fe0fa9..6806b7aa330cdc4a7838f52495879c56172e0453 100644 (file)
@@ -1589,6 +1589,10 @@ static const vshCmdInfo info_pool_info[] = {
 static const vshCmdOptDef opts_pool_info[] = {
     VIRSH_COMMON_OPT_POOL_FULL,
 
+    {.name = "bytes",
+     .type = VSH_OT_BOOL,
+     .help = N_("Reture pool info in bytes"),
+    },
     {.name = NULL}
 };
 
@@ -1600,11 +1604,14 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd)
     int autostart = 0;
     int persistent = 0;
     bool ret = true;
+    bool bytes = false;
     char uuid[VIR_UUID_STRING_BUFLEN];
 
     if (!(pool = virshCommandOptPool(ctl, cmd, "pool", NULL)))
         return false;
 
+    bytes = vshCommandOptBool(cmd, "bytes");
+
     vshPrint(ctl, "%-15s %s\n", _("Name:"), virStoragePoolGetName(pool));
 
     if (virStoragePoolGetUUIDString(pool, &uuid[0]) == 0)
@@ -1633,14 +1640,20 @@ cmdPoolInfo(vshControl *ctl, const vshCmd *cmd)
 
         if (info.state == VIR_STORAGE_POOL_RUNNING ||
             info.state == VIR_STORAGE_POOL_DEGRADED) {
-            val = vshPrettyCapacity(info.capacity, &unit);
-            vshPrint(ctl, "%-15s %2.2lf %s\n", _("Capacity:"), val, unit);
+            if (bytes) {
+                vshPrint(ctl, "%-15s %llu\n", _("Capacity:"), info.capacity);
+                vshPrint(ctl, "%-15s %llu\n", _("Allocation:"), info.allocation);
+                vshPrint(ctl, "%-15s %llu\n", _("Available:"), info.available);
+            } else {
+                val = vshPrettyCapacity(info.capacity, &unit);
+                vshPrint(ctl, "%-15s %2.2lf %s\n", _("Capacity:"), val, unit);
 
-            val = vshPrettyCapacity(info.allocation, &unit);
-            vshPrint(ctl, "%-15s %2.2lf %s\n", _("Allocation:"), val, unit);
+                val = vshPrettyCapacity(info.allocation, &unit);
+                vshPrint(ctl, "%-15s %2.2lf %s\n", _("Allocation:"), val, unit);
 
-            val = vshPrettyCapacity(info.available, &unit);
-            vshPrint(ctl, "%-15s %2.2lf %s\n", _("Available:"), val, unit);
+                val = vshPrettyCapacity(info.available, &unit);
+                vshPrint(ctl, "%-15s %2.2lf %s\n", _("Available:"), val, unit);
+            }
         }
     } else {
         ret = false;
index b95d67f661680530b77201d749f62ca80aa21240..cfa7a24165d856b2f6eb6c8f0f423fa53e094096 100644 (file)
@@ -3616,9 +3616,10 @@ except that it does some error checking.
 The editor used can be supplied by the C<$VISUAL> or C<$EDITOR> environment
 variables, and defaults to C<vi>.
 
-=item B<pool-info> I<pool-or-uuid>
+=item B<pool-info> [I<--bytes>] I<pool-or-uuid>
 
-Returns basic information about the I<pool> object.
+Returns basic information about the I<pool> object. If I<--bytes> is specified the sizes
+of basic info are not converted to human friendly units.
 
 =item B<pool-list> [I<--inactive>] [I<--all>]
                    [I<--persistent>] [I<--transient>]