mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-22 22:13:18 +00:00
virsh: Add support for completed job stats
New --completed flag for virsh domjobinfo command. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
1ffff046ac
commit
13f3c4639f
@ -5115,6 +5115,10 @@ static const vshCmdOptDef opts_resume[] = {
|
|||||||
.flags = VSH_OFLAG_REQ,
|
.flags = VSH_OFLAG_REQ,
|
||||||
.help = N_("domain name, id or uuid")
|
.help = N_("domain name, id or uuid")
|
||||||
},
|
},
|
||||||
|
{.name = "completed",
|
||||||
|
.type = VSH_OT_BOOL,
|
||||||
|
.help = N_("return statistics of a recently completed job")
|
||||||
|
},
|
||||||
{.name = NULL}
|
{.name = NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -5405,14 +5409,18 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
|
|||||||
virTypedParameterPtr params = NULL;
|
virTypedParameterPtr params = NULL;
|
||||||
int nparams = 0;
|
int nparams = 0;
|
||||||
unsigned long long value;
|
unsigned long long value;
|
||||||
|
unsigned int flags = 0;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (vshCommandOptBool(cmd, "completed"))
|
||||||
|
flags |= VIR_DOMAIN_JOB_STATS_COMPLETED;
|
||||||
|
|
||||||
memset(&info, 0, sizeof(info));
|
memset(&info, 0, sizeof(info));
|
||||||
|
|
||||||
rc = virDomainGetJobStats(dom, &info.type, ¶ms, &nparams, 0);
|
rc = virDomainGetJobStats(dom, &info.type, ¶ms, &nparams, flags);
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
if (virTypedParamsGetULLong(params, nparams,
|
if (virTypedParamsGetULLong(params, nparams,
|
||||||
VIR_DOMAIN_JOB_TIME_ELAPSED,
|
VIR_DOMAIN_JOB_TIME_ELAPSED,
|
||||||
@ -5449,6 +5457,11 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
|
|||||||
&info.fileRemaining) < 0)
|
&info.fileRemaining) < 0)
|
||||||
goto save_error;
|
goto save_error;
|
||||||
} else if (last_error->code == VIR_ERR_NO_SUPPORT) {
|
} else if (last_error->code == VIR_ERR_NO_SUPPORT) {
|
||||||
|
if (flags) {
|
||||||
|
vshError(ctl, "%s", _("Optional flags are not supported by the "
|
||||||
|
"daemon"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
vshDebug(ctl, VSH_ERR_DEBUG, "detailed statistics not supported\n");
|
vshDebug(ctl, VSH_ERR_DEBUG, "detailed statistics not supported\n");
|
||||||
vshResetLibvirtError();
|
vshResetLibvirtError();
|
||||||
rc = virDomainGetJobInfo(dom, &info);
|
rc = virDomainGetJobInfo(dom, &info);
|
||||||
@ -5459,7 +5472,9 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
|
|||||||
vshPrint(ctl, "%-17s %-12s\n", _("Job type:"),
|
vshPrint(ctl, "%-17s %-12s\n", _("Job type:"),
|
||||||
vshDomainJobToString(info.type));
|
vshDomainJobToString(info.type));
|
||||||
if (info.type != VIR_DOMAIN_JOB_BOUNDED &&
|
if (info.type != VIR_DOMAIN_JOB_BOUNDED &&
|
||||||
info.type != VIR_DOMAIN_JOB_UNBOUNDED) {
|
info.type != VIR_DOMAIN_JOB_UNBOUNDED &&
|
||||||
|
(!(flags & VIR_DOMAIN_JOB_STATS_COMPLETED) ||
|
||||||
|
info.type != VIR_DOMAIN_JOB_COMPLETED)) {
|
||||||
ret = true;
|
ret = true;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -5524,7 +5539,13 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
|
|||||||
&value)) < 0) {
|
&value)) < 0) {
|
||||||
goto save_error;
|
goto save_error;
|
||||||
} else if (rc) {
|
} else if (rc) {
|
||||||
vshPrint(ctl, "%-17s %-12llu ms\n", _("Expected downtime:"), value);
|
if (info.type == VIR_DOMAIN_JOB_COMPLETED) {
|
||||||
|
vshPrint(ctl, "%-17s %-12llu ms\n",
|
||||||
|
_("Total downtime:"), value);
|
||||||
|
} else {
|
||||||
|
vshPrint(ctl, "%-17s %-12llu ms\n",
|
||||||
|
_("Expected downtime:"), value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((rc = virTypedParamsGetULLong(params, nparams,
|
if ((rc = virTypedParamsGetULLong(params, nparams,
|
||||||
|
@ -1131,9 +1131,12 @@ Convert a domain name (or UUID) to a domain id
|
|||||||
|
|
||||||
Abort the currently running domain job.
|
Abort the currently running domain job.
|
||||||
|
|
||||||
=item B<domjobinfo> I<domain>
|
=item B<domjobinfo> I<domain> [I<--completed>]
|
||||||
|
|
||||||
Returns information about jobs running on a domain.
|
Returns information about jobs running on a domain. I<--completed> tells
|
||||||
|
virsh to return information about a recently finished job. Statistics of
|
||||||
|
a completed job are automatically destroyed once read or when libvirtd
|
||||||
|
is restarted.
|
||||||
|
|
||||||
=item B<domname> I<domain-id-or-uuid>
|
=item B<domname> I<domain-id-or-uuid>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user