mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
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: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
7f3534a5bb
commit
b1bf5efdc1
@ -6033,6 +6033,10 @@ static const vshCmdOptDef opts_domjobinfo[] = {
|
|||||||
.type = VSH_OT_BOOL,
|
.type = VSH_OT_BOOL,
|
||||||
.help = N_("print statistics for any kind of job (even failed ones)")
|
.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}
|
{.name = NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -6124,6 +6128,8 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
|
|||||||
int ivalue;
|
int ivalue;
|
||||||
int op;
|
int op;
|
||||||
int rc;
|
int rc;
|
||||||
|
size_t i;
|
||||||
|
bool rawstats = vshCommandOptBool(cmd, "rawstats");
|
||||||
|
|
||||||
VSH_REQUIRE_OPTION("keep-completed", "completed");
|
VSH_REQUIRE_OPTION("keep-completed", "completed");
|
||||||
|
|
||||||
@ -6143,9 +6149,9 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (virshDomainJobStatsToDomainJobInfo(params, nparams, &info) < 0)
|
if (virshDomainJobStatsToDomainJobInfo(params, nparams, &info) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else if (last_error->code == VIR_ERR_NO_SUPPORT) {
|
} else if (last_error->code == VIR_ERR_NO_SUPPORT) {
|
||||||
if (flags) {
|
if (flags != 0 || rawstats) {
|
||||||
vshError(ctl, "%s", _("Optional flags are not supported by the "
|
vshError(ctl, "%s",
|
||||||
"daemon"));
|
_("Optional flags or --rawstats are not supported by the daemon"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
vshDebug(ctl, VSH_ERR_DEBUG, "detailed statistics not supported\n");
|
vshDebug(ctl, VSH_ERR_DEBUG, "detailed statistics not supported\n");
|
||||||
@ -6155,6 +6161,18 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (rawstats) {
|
||||||
|
vshPrint(ctl, "Job type: %d\n\n", info.type);
|
||||||
|
|
||||||
|
for (i = 0; i < nparams; i++) {
|
||||||
|
g_autofree char *par = virTypedParameterToString(¶ms[i]);
|
||||||
|
vshPrint(ctl, "%s: %s\n", params[i].field, NULLSTR(par));
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = true;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
vshPrint(ctl, "%-17s %-12s\n", _("Job type:"),
|
vshPrint(ctl, "%-17s %-12s\n", _("Job type:"),
|
||||||
virshDomainJobToString(info.type));
|
virshDomainJobToString(info.type));
|
||||||
|
|
||||||
|
@ -1381,7 +1381,7 @@ Returns basic information about the domain.
|
|||||||
Abort the currently running domain job.
|
Abort the currently running domain job.
|
||||||
|
|
||||||
=item B<domjobinfo> I<domain> [I<--completed> [I<--keep-completed>]]
|
=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
|
Returns information about jobs running on a domain. I<--completed> tells
|
||||||
virsh to return information about a recently finished job. Statistics of
|
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.
|
Normally only statistics for running and successful completed jobs are printed.
|
||||||
I<--anystats> can be used to also display statistics for failed jobs.
|
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
|
Note that time information returned for completed
|
||||||
migrations may be completely irrelevant unless both source and
|
migrations may be completely irrelevant unless both source and
|
||||||
destination hosts have synchronized time (i.e., NTP daemon is running
|
destination hosts have synchronized time (i.e., NTP daemon is running
|
||||||
|
Loading…
x
Reference in New Issue
Block a user