From f4bdf2e3abe210ee4134dc650e0b9afd60adfcec Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 3 May 2016 17:24:55 +0200 Subject: [PATCH] virsh: volume: Add --bytes to 'vol-info' --- tools/virsh-volume.c | 23 +++++++++++++++++++---- tools/virsh.pod | 4 +++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 9cc8e5219f..d35fee15b2 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -992,6 +992,10 @@ static const vshCmdInfo info_vol_info[] = { static const vshCmdOptDef opts_vol_info[] = { VIRSH_COMMON_OPT_VOLUME_VOL, VIRSH_COMMON_OPT_POOL_OPTIONAL, + {.name = "bytes", + .type = VSH_OT_BOOL, + .help = N_("sizes are represented in bytes rather than pretty units") + }, {.name = NULL} }; @@ -1000,6 +1004,7 @@ cmdVolInfo(vshControl *ctl, const vshCmd *cmd) { virStorageVolInfo info; virStorageVolPtr vol; + bool bytes = vshCommandOptBool(cmd, "bytes"); bool ret = true; if (!(vol = virshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) @@ -1014,11 +1019,21 @@ cmdVolInfo(vshControl *ctl, const vshCmd *cmd) vshPrint(ctl, "%-15s %s\n", _("Type:"), virshVolumeTypeToString(info.type)); - val = vshPrettyCapacity(info.capacity, &unit); - vshPrint(ctl, "%-15s %2.2lf %s\n", _("Capacity:"), val, unit); + if (bytes) { + vshPrint(ctl, "%-15s %llu %s\n", _("Capacity:"), + info.capacity, _("bytes")); + } 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); + if (bytes) { + vshPrint(ctl, "%-15s %llu %s\n", _("Allocation:"), + info.allocation, _("bytes")); + } else { + val = vshPrettyCapacity(info.allocation, &unit); + vshPrint(ctl, "%-15s %2.2lf %s\n", _("Allocation:"), val, unit); + } } else { ret = false; } diff --git a/tools/virsh.pod b/tools/virsh.pod index 90ab47db8a..2a95df7458 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -3639,11 +3639,13 @@ is in. I is the name or key or path of the volume to output the XML of. =item B [I<--pool> I] I +[I<--bytes>] Returns basic information about the given storage volume. I<--pool> I is the name or UUID of the storage pool the volume is in. I is the name or key or path of the volume -to return information for. +to return information for. If I<--bytes> is specified the sizes are not +converted to human friendly units. =item B [I<--pool> I] [I<--details>] -- GitLab