提交 2979bbfb 编写于 作者: S Simon Kobyda 提交者: Michal Privoznik

virsh: Implement vshTable API to domblkinfo

Signed-off-by: NSimon Kobyda <skobyda@redhat.com>
上级 b9057c63
...@@ -460,6 +460,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) ...@@ -460,6 +460,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
char *cap = NULL; char *cap = NULL;
char *alloc = NULL; char *alloc = NULL;
char *phy = NULL; char *phy = NULL;
vshTablePtr table = NULL;
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
return false; return false;
...@@ -483,11 +484,10 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) ...@@ -483,11 +484,10 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
if (ndisks < 0) if (ndisks < 0)
goto cleanup; goto cleanup;
/* print the title */ /* title */
vshPrintExtra(ctl, "%-10s %-15s %-15s %-15s\n", _("Target"), table = vshTableNew(_("Target"), _("Capacity"), _("Allocation"), _("Physical"), NULL);
_("Capacity"), _("Allocation"), _("Physical")); if (!table)
vshPrintExtra(ctl, "-----------------------------" goto cleanup;
"------------------------\n");
for (i = 0; i < ndisks; i++) { for (i = 0; i < ndisks; i++) {
ctxt->node = disks[i]; ctxt->node = disks[i];
...@@ -512,11 +512,15 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) ...@@ -512,11 +512,15 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
if (!cmdDomblkinfoGet(ctl, &info, &cap, &alloc, &phy, human)) if (!cmdDomblkinfoGet(ctl, &info, &cap, &alloc, &phy, human))
goto cleanup; goto cleanup;
vshPrint(ctl, "%-10s %-15s %-15s %-15s\n", target, cap, alloc, phy); if (vshTableRowAppend(table, target, cap, alloc, phy, NULL) < 0)
goto cleanup;
VIR_FREE(target); VIR_FREE(target);
VIR_FREE(protocol); VIR_FREE(protocol);
} }
vshTablePrintToStdout(table, ctl);
} else { } else {
if (virDomainGetBlockInfo(dom, device, &info, 0) < 0) if (virDomainGetBlockInfo(dom, device, &info, 0) < 0)
goto cleanup; goto cleanup;
...@@ -531,6 +535,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd) ...@@ -531,6 +535,7 @@ cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
ret = true; ret = true;
cleanup: cleanup:
vshTableFree(table);
VIR_FREE(cap); VIR_FREE(cap);
VIR_FREE(alloc); VIR_FREE(alloc);
VIR_FREE(phy); VIR_FREE(phy);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册