mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
virsh: Implement vshTable API to domblkinfo
Signed-off-by: Simon Kobyda <skobyda@redhat.com>
This commit is contained in:
parent
b9057c639f
commit
2979bbfb0f
@ -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)
|
|||||||
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)
|
|||||||
|
|
||||||
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)
|
|||||||
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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user