|
|
9119d9 |
From c9a9ebccf24d0b78b590b2899dae33c91b29848a Mon Sep 17 00:00:00 2001
|
|
|
9119d9 |
Message-Id: <c9a9ebccf24d0b78b590b2899dae33c91b29848a@dist-git>
|
|
|
9119d9 |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
Date: Fri, 22 Aug 2014 14:29:41 +0200
|
|
|
9119d9 |
Subject: [PATCH] virsh: Add support for completed job stats
|
|
|
9119d9 |
|
|
|
9119d9 |
New --completed flag for virsh domjobinfo command.
|
|
|
9119d9 |
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
(cherry picked from commit 13f3c4639f5a3b1692e2f626dc02a6977e28412e)
|
|
|
9119d9 |
|
|
|
9119d9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1063724
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
---
|
|
|
9119d9 |
tools/virsh-domain.c | 27 ++++++++++++++++++++++++---
|
|
|
9119d9 |
tools/virsh.pod | 7 +++++--
|
|
|
9119d9 |
2 files changed, 29 insertions(+), 5 deletions(-)
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
|
|
|
9119d9 |
index c75cd73..80b06ce 100644
|
|
|
9119d9 |
--- a/tools/virsh-domain.c
|
|
|
9119d9 |
+++ b/tools/virsh-domain.c
|
|
|
9119d9 |
@@ -4905,6 +4905,10 @@ static const vshCmdOptDef opts_resume[] = {
|
|
|
9119d9 |
.flags = VSH_OFLAG_REQ,
|
|
|
9119d9 |
.help = N_("domain name, id or uuid")
|
|
|
9119d9 |
},
|
|
|
9119d9 |
+ {.name = "completed",
|
|
|
9119d9 |
+ .type = VSH_OT_BOOL,
|
|
|
9119d9 |
+ .help = N_("return statistics of a recently completed job")
|
|
|
9119d9 |
+ },
|
|
|
9119d9 |
{.name = NULL}
|
|
|
9119d9 |
};
|
|
|
9119d9 |
|
|
|
9119d9 |
@@ -5195,14 +5199,18 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
|
|
|
9119d9 |
virTypedParameterPtr params = NULL;
|
|
|
9119d9 |
int nparams = 0;
|
|
|
9119d9 |
unsigned long long value;
|
|
|
9119d9 |
+ unsigned int flags = 0;
|
|
|
9119d9 |
int rc;
|
|
|
9119d9 |
|
|
|
9119d9 |
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
|
|
|
9119d9 |
return false;
|
|
|
9119d9 |
|
|
|
9119d9 |
+ if (vshCommandOptBool(cmd, "completed"))
|
|
|
9119d9 |
+ flags |= VIR_DOMAIN_JOB_STATS_COMPLETED;
|
|
|
9119d9 |
+
|
|
|
9119d9 |
memset(&info, 0, sizeof(info));
|
|
|
9119d9 |
|
|
|
9119d9 |
- rc = virDomainGetJobStats(dom, &info.type, ¶ms, &nparams, 0);
|
|
|
9119d9 |
+ rc = virDomainGetJobStats(dom, &info.type, ¶ms, &nparams, flags);
|
|
|
9119d9 |
if (rc == 0) {
|
|
|
9119d9 |
if (virTypedParamsGetULLong(params, nparams,
|
|
|
9119d9 |
VIR_DOMAIN_JOB_TIME_ELAPSED,
|
|
|
9119d9 |
@@ -5239,6 +5247,11 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
|
|
|
9119d9 |
&info.fileRemaining) < 0)
|
|
|
9119d9 |
goto save_error;
|
|
|
9119d9 |
} else if (last_error->code == VIR_ERR_NO_SUPPORT) {
|
|
|
9119d9 |
+ if (flags) {
|
|
|
9119d9 |
+ vshError(ctl, "%s", _("Optional flags are not supported by the "
|
|
|
9119d9 |
+ "daemon"));
|
|
|
9119d9 |
+ goto cleanup;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
vshDebug(ctl, VSH_ERR_DEBUG, "detailed statistics not supported\n");
|
|
|
9119d9 |
vshResetLibvirtError();
|
|
|
9119d9 |
rc = virDomainGetJobInfo(dom, &info;;
|
|
|
9119d9 |
@@ -5249,7 +5262,9 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
|
|
|
9119d9 |
vshPrint(ctl, "%-17s %-12s\n", _("Job type:"),
|
|
|
9119d9 |
vshDomainJobToString(info.type));
|
|
|
9119d9 |
if (info.type != VIR_DOMAIN_JOB_BOUNDED &&
|
|
|
9119d9 |
- info.type != VIR_DOMAIN_JOB_UNBOUNDED) {
|
|
|
9119d9 |
+ info.type != VIR_DOMAIN_JOB_UNBOUNDED &&
|
|
|
9119d9 |
+ (!(flags & VIR_DOMAIN_JOB_STATS_COMPLETED) ||
|
|
|
9119d9 |
+ info.type != VIR_DOMAIN_JOB_COMPLETED)) {
|
|
|
9119d9 |
ret = true;
|
|
|
9119d9 |
goto cleanup;
|
|
|
9119d9 |
}
|
|
|
9119d9 |
@@ -5314,7 +5329,13 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
|
|
|
9119d9 |
&value)) < 0) {
|
|
|
9119d9 |
goto save_error;
|
|
|
9119d9 |
} else if (rc) {
|
|
|
9119d9 |
- vshPrint(ctl, "%-17s %-12llu ms\n", _("Expected downtime:"), value);
|
|
|
9119d9 |
+ if (info.type == VIR_DOMAIN_JOB_COMPLETED) {
|
|
|
9119d9 |
+ vshPrint(ctl, "%-17s %-12llu ms\n",
|
|
|
9119d9 |
+ _("Total downtime:"), value);
|
|
|
9119d9 |
+ } else {
|
|
|
9119d9 |
+ vshPrint(ctl, "%-17s %-12llu ms\n",
|
|
|
9119d9 |
+ _("Expected downtime:"), value);
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
if ((rc = virTypedParamsGetULLong(params, nparams,
|
|
|
9119d9 |
diff --git a/tools/virsh.pod b/tools/virsh.pod
|
|
|
9119d9 |
index ea9267e..aad40d5 100644
|
|
|
9119d9 |
--- a/tools/virsh.pod
|
|
|
9119d9 |
+++ b/tools/virsh.pod
|
|
|
9119d9 |
@@ -1112,9 +1112,12 @@ Convert a domain name (or UUID) to a domain id
|
|
|
9119d9 |
|
|
|
9119d9 |
Abort the currently running domain job.
|
|
|
9119d9 |
|
|
|
9119d9 |
-=item B<domjobinfo> I<domain>
|
|
|
9119d9 |
+=item B<domjobinfo> I<domain> [I<--completed>]
|
|
|
9119d9 |
|
|
|
9119d9 |
-Returns information about jobs running on a domain.
|
|
|
9119d9 |
+Returns information about jobs running on a domain. I<--completed> tells
|
|
|
9119d9 |
+virsh to return information about a recently finished job. Statistics of
|
|
|
9119d9 |
+a completed job are automatically destroyed once read or when libvirtd
|
|
|
9119d9 |
+is restarted.
|
|
|
9119d9 |
|
|
|
9119d9 |
=item B<domname> I<domain-id-or-uuid>
|
|
|
9119d9 |
|
|
|
9119d9 |
--
|
|
|
9119d9 |
2.1.0
|
|
|
9119d9 |
|