提交 47c724e5 编写于 作者: M Michal Privoznik

virsh: Expose new virDomainFSTrim API

It's exposed under domfstrim command. Although the API
doesn't support specifying mount point yet, expose it
anyway.
上级 6092fea9
......@@ -8300,6 +8300,52 @@ cleanup:
return ret;
}
static const vshCmdInfo info_domfstrim[] = {
{"help", N_("Invoke fstrim on domain's mounted filesystems.")},
{"desc", N_("Invoke fstrim on domain's mounted filesystems.")},
{NULL, NULL}
};
static const vshCmdOptDef opts_domfstrim[] = {
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
{"minimum", VSH_OT_INT, 0, N_("Just a hint to ignore contiguous "
"free ranges smaller than this (Bytes)")},
{"mountpoint", VSH_OT_DATA, 0, N_("which mount point to trim")},
{NULL, 0, 0, NULL}
};
static bool
cmdDomFSTrim(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
bool ret = false;
unsigned long long minimum = 0;
const char *mountPoint = NULL;
unsigned int flags = 0;
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
goto cleanup;
if (vshCommandOptULongLong(cmd, "minimum", &minimum) < 0) {
vshError(ctl, _("Unable to parse integer parameter minimum"));
goto cleanup;
}
if (vshCommandOptString(cmd, "mountpoint", &mountPoint) < 0) {
vshError(ctl, _("Unable to parse mountpoint parameter"));
goto cleanup;
}
if (virDomainFSTrim(dom, mountPoint, minimum, flags) < 0) {
vshError(ctl, _("Unable to invoke fstrim"));
goto cleanup;
}
ret = true;
cleanup:
return ret;
}
const vshCmdDef domManagementCmds[] = {
{"attach-device", cmdAttachDevice, opts_attach_device,
info_attach_device, 0},
......@@ -8332,6 +8378,7 @@ const vshCmdDef domManagementCmds[] = {
{"detach-interface", cmdDetachInterface, opts_detach_interface,
info_detach_interface, 0},
{"domdisplay", cmdDomDisplay, opts_domdisplay, info_domdisplay, 0},
{"domfstrim", cmdDomFSTrim, opts_domfstrim, info_domfstrim, 0},
{"domhostname", cmdDomHostname, opts_domhostname, info_domhostname, 0},
{"domid", cmdDomid, opts_domid, info_domid, 0},
{"domif-setlink", cmdDomIfSetLink, opts_domif_setlink, info_domif_setlink, 0},
......
......@@ -878,6 +878,20 @@ Output a URI which can be used to connect to the graphical display of the
domain via VNC, SPICE or RDP. If I<--include-password> is specified, the
SPICE channel password will be included in the URI.
=item B<domfstrim> I<domain> [I<--minimum> B<bytes>]
[I<--mountpoint mountPoint>]
Issue a fstrim command on all mounted filesystems within a running
domain. It discards blocks which are not in use by the filesystem.
If I<--minimum> B<bytes> is specified, it tells guest kernel length
of contiguous free range. Smaller than this may be ignored (this is
a hint and the guest may not respect it). By increasing this value,
the fstrim operation will complete more quickly for filesystems
with badly fragmented free space, although not all blocks will
be discarded. The default value is zero, meaning "discard
every free block". Moreover, a if user wants to trim only one mount
point, it can be specified via optional I<--mountpoint> parameter.
=item B<domhostname> I<domain>
Returns the hostname of a domain, if the hypervisor makes it available.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册