提交 b1bf5efd 编写于 作者: P Peter Krempa

virsh: domjobinfo: Add switch to print raw fields

Introduce --rawstats which prints all statistics fields from the new API
similarly to how the virsh event handler prints them.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
上级 7f3534a5
......@@ -6033,6 +6033,10 @@ static const vshCmdOptDef opts_domjobinfo[] = {
.type = VSH_OT_BOOL,
.help = N_("print statistics for any kind of job (even failed ones)")
},
{.name = "rawstats",
.type = VSH_OT_BOOL,
.help = N_("print the raw data returned by libvirt")
},
{.name = NULL}
};
......@@ -6124,6 +6128,8 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
int ivalue;
int op;
int rc;
size_t i;
bool rawstats = vshCommandOptBool(cmd, "rawstats");
VSH_REQUIRE_OPTION("keep-completed", "completed");
......@@ -6143,9 +6149,9 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
if (virshDomainJobStatsToDomainJobInfo(params, nparams, &info) < 0)
goto cleanup;
} else if (last_error->code == VIR_ERR_NO_SUPPORT) {
if (flags) {
vshError(ctl, "%s", _("Optional flags are not supported by the "
"daemon"));
if (flags != 0 || rawstats) {
vshError(ctl, "%s",
_("Optional flags or --rawstats are not supported by the daemon"));
goto cleanup;
}
vshDebug(ctl, VSH_ERR_DEBUG, "detailed statistics not supported\n");
......@@ -6155,6 +6161,18 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
if (rc < 0)
goto cleanup;
if (rawstats) {
vshPrint(ctl, "Job type: %d\n\n", info.type);
for (i = 0; i < nparams; i++) {
g_autofree char *par = virTypedParameterToString(&params[i]);
vshPrint(ctl, "%s: %s\n", params[i].field, NULLSTR(par));
}
ret = true;
goto cleanup;
}
vshPrint(ctl, "%-17s %-12s\n", _("Job type:"),
virshDomainJobToString(info.type));
......
......@@ -1381,7 +1381,7 @@ Returns basic information about the domain.
Abort the currently running domain job.
=item B<domjobinfo> I<domain> [I<--completed> [I<--keep-completed>]]
[I<--anystats>]
[I<--anystats>] [I<--rawstats>]
Returns information about jobs running on a domain. I<--completed> tells
virsh to return information about a recently finished job. Statistics of
......@@ -1391,6 +1391,10 @@ I<--keep-completed> is used) or when libvirtd is restarted.
Normally only statistics for running and successful completed jobs are printed.
I<--anystats> can be used to also display statistics for failed jobs.
In case I<--rawstats> is used, all fields are printed as received from the
server without any attempts to interpret the data. The "Job type:" field is
special, since it's reported by the API and not part of stats.
Note that time information returned for completed
migrations may be completely irrelevant unless both source and
destination hosts have synchronized time (i.e., NTP daemon is running
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册