提交 4afcaa88 编写于 作者: C Chen Hanxiao 提交者: John Ferlan

cmdDomblkinfo: introduce helper cmdDomblkinfoPrint

Introduce helper cmdDomblkinfoPrint for printing.
Signed-off-by: NChen Hanxiao <chenhanxiao@gmail.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 17b47342
...@@ -400,6 +400,30 @@ static const vshCmdOptDef opts_domblkinfo[] = { ...@@ -400,6 +400,30 @@ static const vshCmdOptDef opts_domblkinfo[] = {
{.name = NULL} {.name = NULL}
}; };
static void
cmdDomblkinfoPrint(vshControl *ctl,
const virDomainBlockInfo *info,
bool 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);
}
}
static bool static bool
cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
{ {
...@@ -420,21 +444,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) ...@@ -420,21 +444,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
human = vshCommandOptBool(cmd, "human"); human = vshCommandOptBool(cmd, "human");
if (!human) { cmdDomblkinfoPrint(ctl, &info, 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; ret = true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册