diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 3db4795d289650881315d288a472d9537af03698..0ca53e438e6c2efd77e473dd250015aa7f12ffb5 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -396,6 +396,10 @@ static const vshCmdOptDef opts_domblkinfo[] = { .flags = VSH_OFLAG_REQ, .help = N_("block device") }, + {.name = "human", + .type = VSH_OT_BOOL, + .help = N_("Human readable output") + }, {.name = NULL} }; @@ -405,6 +409,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) virDomainBlockInfo info; virDomainPtr dom; bool ret = false; + bool human = false; const char *device = NULL; if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) @@ -416,9 +421,23 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) if (virDomainGetBlockInfo(dom, device, &info, 0) < 0) goto cleanup; - vshPrint(ctl, "%-15s %llu\n", _("Capacity:"), info.capacity); - vshPrint(ctl, "%-15s %llu\n", _("Allocation:"), info.allocation); - vshPrint(ctl, "%-15s %llu\n", _("Physical:"), info.physical); + human = vshCommandOptBool(cmd, "human"); + + if (!human) { + vshPrint(ctl, "%-15s %llu\n", _("Capacity:"), info.capacity); + vshPrint(ctl, "%-15s %llu\n", _("Allocation:"), info.allocation); + vshPrint(ctl, "%-15s %llu\n", _("Physical:"), info.physical); + } else { + double val; + const char *unit; + + val = vshPrettyCapacity(info.capacity, &unit); + vshPrint(ctl, "%-15s %-.3lf %s\n", _("Capacity:"), val, unit); + val = vshPrettyCapacity(info.allocation, &unit); + vshPrint(ctl, "%-15s %-.3lf %s\n", _("Allocation:"), val, unit); + val = vshPrettyCapacity(info.physical, &unit); + vshPrint(ctl, "%-15s %-.3lf %s\n", _("Physical:"), val, unit); + } ret = true; diff --git a/tools/virsh.pod b/tools/virsh.pod index bba5fed37515db549f0040628ca41f29dce01e95..cd1f25fdf45208dbd8efbb576ddaab311a7091d2 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -841,12 +841,13 @@ B command says that a domain was paused due to I/O error. The B command lists all block devices in error state and the error seen on each of them. -=item B I I +=item B I I [I<--human>] Get block device size info for a domain. A I corresponds to a unique target name () or source file () for one of the disk devices attached to I (see -also B for listing these names). +also B for listing these names). If I<--human> is set, the +output will have a human readable output. =item B I [I<--inactive>] [I<--details>]