[PATCH 7/9] virsh: domjobinfo: Add switch to print raw fields

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 tools/virsh-domain.c | 24 +++++++++++++++++++++---
 tools/virsh.pod      |  6 +++++-
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 81229fa5ca..325d748b49 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -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));

diff --git a/tools/virsh.pod b/tools/virsh.pod
index e5428976a0..951cb738a0 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -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 display statistics also for failed jobs.

+In case I<--rawstats> is used, all fields are printed as received from the
+server without any attempts to interpred 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
-- 
2.23.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux