mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
Add new domblkinfo command to virsh
virsh # domblkinfo demoguest /dev/hda2 Capacity: 1048576000 Allocation: 104857600 Physical: 104857600 * tools/virsh.c: Implement domblkinfo command mapping to the new virDomainGetBlockInfo API
This commit is contained in:
parent
db57a7bed8
commit
7703c2c90a
@ -1044,6 +1044,53 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* "domblkinfo" command
|
||||||
|
*/
|
||||||
|
static const vshCmdInfo info_domblkinfo[] = {
|
||||||
|
{"help", N_("domain block device size information")},
|
||||||
|
{"desc", N_("Get block device size info for a domain.")},
|
||||||
|
{NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
static const vshCmdOptDef opts_domblkinfo[] = {
|
||||||
|
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
|
||||||
|
{"device", VSH_OT_DATA, VSH_OFLAG_REQ, N_("block device")},
|
||||||
|
{NULL, 0, 0, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
cmdDomblkinfo(vshControl *ctl, const vshCmd *cmd)
|
||||||
|
{
|
||||||
|
virDomainBlockInfo info;
|
||||||
|
virDomainPtr dom;
|
||||||
|
int ret = TRUE;
|
||||||
|
const char *device;
|
||||||
|
|
||||||
|
if (!vshConnectionUsability(ctl, ctl->conn, TRUE))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (!(device = vshCommandOptString (cmd, "device", NULL))) {
|
||||||
|
virDomainFree(dom);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (virDomainGetBlockInfo(dom, device, &info, 0) < 0) {
|
||||||
|
virDomainFree(dom);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
vshPrint(ctl, "%-15s %llu\n", _("Capacity:"), info.capacity);
|
||||||
|
vshPrint(ctl, "%-15s %llu\n", _("Allocation:"), info.allocation);
|
||||||
|
vshPrint(ctl, "%-15s %llu\n", _("Physical:"), info.physical);
|
||||||
|
|
||||||
|
virDomainFree(dom);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "suspend" command
|
* "suspend" command
|
||||||
*/
|
*/
|
||||||
@ -8661,6 +8708,7 @@ static const vshCmdDef commands[] = {
|
|||||||
{"domblkstat", cmdDomblkstat, opts_domblkstat, info_domblkstat},
|
{"domblkstat", cmdDomblkstat, opts_domblkstat, info_domblkstat},
|
||||||
{"domifstat", cmdDomIfstat, opts_domifstat, info_domifstat},
|
{"domifstat", cmdDomIfstat, opts_domifstat, info_domifstat},
|
||||||
{"dommemstat", cmdDomMemStat, opts_dommemstat, info_dommemstat},
|
{"dommemstat", cmdDomMemStat, opts_dommemstat, info_dommemstat},
|
||||||
|
{"domblkinfo", cmdDomblkinfo, opts_domblkinfo, info_domblkinfo},
|
||||||
{"domxml-from-native", cmdDomXMLFromNative, opts_domxmlfromnative, info_domxmlfromnative},
|
{"domxml-from-native", cmdDomXMLFromNative, opts_domxmlfromnative, info_domxmlfromnative},
|
||||||
{"domxml-to-native", cmdDomXMLToNative, opts_domxmltonative, info_domxmltonative},
|
{"domxml-to-native", cmdDomXMLToNative, opts_domxmltonative, info_domxmltonative},
|
||||||
{"dumpxml", cmdDumpXML, opts_dumpxml, info_dumpxml},
|
{"dumpxml", cmdDumpXML, opts_dumpxml, info_dumpxml},
|
||||||
|
@ -296,6 +296,10 @@ Get network interface stats for a running domain.
|
|||||||
|
|
||||||
Get memory stats for a running domain.
|
Get memory stats for a running domain.
|
||||||
|
|
||||||
|
=item B<domblkinfo> I<domain> I<block-device>
|
||||||
|
|
||||||
|
Get block device size info for a domain.
|
||||||
|
|
||||||
=item B<dominfo> I<domain-id>
|
=item B<dominfo> I<domain-id>
|
||||||
|
|
||||||
Returns basic information about the domain.
|
Returns basic information about the domain.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user