[PATCH 2/4] latency: Parse the new disk latency keys in qemu monitor functions

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

 



---
 src/qemu/qemu_monitor.c      |   12 ++++++++++++
 src/qemu/qemu_monitor.h      |    4 ++++
 src/qemu/qemu_monitor_json.c |   36 +++++++++++++++++++++++++++++++++++-
 src/qemu/qemu_monitor_json.h |    5 ++++-
 src/qemu/qemu_monitor_text.c |   39 +++++++++++++++++++++++++++++----------
 src/qemu/qemu_monitor_text.h |    4 ++++
 6 files changed, 88 insertions(+), 12 deletions(-)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index db6107c..aac4b21 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1201,8 +1201,12 @@ int qemuMonitorGetBlockStatsInfo(qemuMonitorPtr mon,
                                  const char *devname,
                                  long long *rd_req,
                                  long long *rd_bytes,
+                                 long long *rd_total_times,
                                  long long *wr_req,
                                  long long *wr_bytes,
+                                 long long *wr_total_times,
+                                 long long *flush_req,
+                                 long long *flush_total_times,
                                  long long *errs)
 {
     int ret;
@@ -1217,12 +1221,20 @@ int qemuMonitorGetBlockStatsInfo(qemuMonitorPtr mon,
     if (mon->json)
         ret = qemuMonitorJSONGetBlockStatsInfo(mon, devname,
                                                rd_req, rd_bytes,
+                                               rd_total_times,
                                                wr_req, wr_bytes,
+                                               wr_total_times,
+                                               flush_req,
+                                               flush_total_times,
                                                errs);
     else
         ret = qemuMonitorTextGetBlockStatsInfo(mon, devname,
                                                rd_req, rd_bytes,
+                                               rd_total_times,
                                                wr_req, wr_bytes,
+                                               wr_total_times,
+                                               flush_req,
+                                               flush_total_times,
                                                errs);
     return ret;
 }
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index f241c9e..d7695e9 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -212,8 +212,12 @@ int qemuMonitorGetBlockStatsInfo(qemuMonitorPtr mon,
                                  const char *devname,
                                  long long *rd_req,
                                  long long *rd_bytes,
+                                 long long *rd_total_times,
                                  long long *wr_req,
                                  long long *wr_bytes,
+                                 long long *wr_total_times,
+                                 long long *flush_req,
+                                 long long *flush_total_times,
                                  long long *errs);
 
 int qemuMonitorGetBlockExtent(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 2a9a078..c917978 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -1318,8 +1318,12 @@ int qemuMonitorJSONGetBlockStatsInfo(qemuMonitorPtr mon,
                                      const char *devname,
                                      long long *rd_req,
                                      long long *rd_bytes,
+                                     long long *rd_total_times,
                                      long long *wr_req,
                                      long long *wr_bytes,
+                                     long long *wr_total_times,
+                                     long long *flush_req,
+                                     long long *flush_total_times,
                                      long long *errs)
 {
     int ret;
@@ -1330,7 +1334,9 @@ int qemuMonitorJSONGetBlockStatsInfo(qemuMonitorPtr mon,
     virJSONValuePtr reply = NULL;
     virJSONValuePtr devices;
 
-    *rd_req = *rd_bytes = *wr_req = *wr_bytes = *errs = 0;
+    *rd_req = *rd_bytes = *rd_total_times = 0;
+    *wr_req = *wr_bytes = *wr_total_times = 0;
+    *flush_req = *flush_total_times = *errs = 0;
 
     if (!cmd)
         return -1;
@@ -1396,6 +1402,13 @@ int qemuMonitorJSONGetBlockStatsInfo(qemuMonitorPtr mon,
                             "rd_operations");
             goto cleanup;
         }
+        if (virJSONValueObjectGetNumberLong(stats, "rd_total_times_ns",
+                                            rd_total_times) < 0) {
+            qemuReportError(VIR_ERR_INTERNAL_ERROR,
+                            _("cannot read %s statistic"),
+                            "rd_total_times_ns");
+            goto cleanup;
+        }
         if (virJSONValueObjectGetNumberLong(stats, "wr_bytes", wr_bytes) < 0) {
             qemuReportError(VIR_ERR_INTERNAL_ERROR,
                             _("cannot read %s statistic"),
@@ -1408,6 +1421,27 @@ int qemuMonitorJSONGetBlockStatsInfo(qemuMonitorPtr mon,
                             "wr_operations");
             goto cleanup;
         }
+        if (virJSONValueObjectGetNumberLong(stats, "wr_total_times_ns",
+                                                    wr_total_times) < 0) {
+            qemuReportError(VIR_ERR_INTERNAL_ERROR,
+                            _("cannot read %s statistic"),
+                            "wr_total_times_ns");
+            goto cleanup;
+        }
+        if (virJSONValueObjectGetNumberLong(stats, "flush_operations",
+                                            flush_req) < 0) {
+            qemuReportError(VIR_ERR_INTERNAL_ERROR,
+                            _("cannot read %s statistic"),
+                            "flush_operations");
+            goto cleanup;
+        }
+        if (virJSONValueObjectGetNumberLong(stats, "flush_total_times_ns",
+                                            flush_total_times) < 0) {
+            qemuReportError(VIR_ERR_INTERNAL_ERROR,
+                            _("cannot read %s statistic"),
+                            "flush_total_times_ns");
+            goto cleanup;
+        }
     }
 
     if (!found) {
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 9512793..a1ab39d 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -64,14 +64,17 @@ int qemuMonitorJSONGetBlockStatsInfo(qemuMonitorPtr mon,
                                      const char *devname,
                                      long long *rd_req,
                                      long long *rd_bytes,
+                                     long long *rd_total_times,
                                      long long *wr_req,
                                      long long *wr_bytes,
+                                     long long *wr_total_times,
+                                     long long *flush_req,
+                                     long long *flush_total_times,
                                      long long *errs);
 int qemuMonitorJSONGetBlockExtent(qemuMonitorPtr mon,
                                   const char *devname,
                                   unsigned long long *extent);
 
-
 int qemuMonitorJSONSetVNCPassword(qemuMonitorPtr mon,
                                   const char *password);
 int qemuMonitorJSONSetPassword(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 7bf733d..fbea855 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -674,8 +674,12 @@ int qemuMonitorTextGetBlockStatsInfo(qemuMonitorPtr mon,
                                      const char *devname,
                                      long long *rd_req,
                                      long long *rd_bytes,
+                                     long long *rd_total_times,
                                      long long *wr_req,
                                      long long *wr_bytes,
+                                     long long *wr_total_times,
+                                     long long *flush_req,
+                                     long long *flush_total_times,
                                      long long *errs)
 {
     char *info = NULL;
@@ -702,11 +706,9 @@ int qemuMonitorTextGetBlockStatsInfo(qemuMonitorPtr mon,
         goto cleanup;
     }
 
-    *rd_req = -1;
-    *rd_bytes = -1;
-    *wr_req = -1;
-    *wr_bytes = -1;
-    *errs = -1;
+    *rd_req = *rd_bytes = *rd_total_times = -1;
+    *wr_req = *wr_bytes = *wr_total_times = -1;
+    *flush_req = *flush_total_times = *errs = -1;
 
     /* The output format for both qemu & KVM is:
      *   blockdevice: rd_bytes=% wr_bytes=% rd_operations=% wr_operations=%
@@ -734,23 +736,40 @@ int qemuMonitorTextGetBlockStatsInfo(qemuMonitorPtr mon,
 
             while (*p) {
                 if (STRPREFIX (p, "rd_bytes=")) {
-                    p += 9;
+                    p += strlen("rd_bytes");
                     if (virStrToLong_ll (p, &dummy, 10, rd_bytes) == -1)
                         VIR_DEBUG ("error reading rd_bytes: %s", p);
                 } else if (STRPREFIX (p, "wr_bytes=")) {
-                    p += 9;
+                    p += strlen("wr_bytes");
                     if (virStrToLong_ll (p, &dummy, 10, wr_bytes) == -1)
                         VIR_DEBUG ("error reading wr_bytes: %s", p);
                 } else if (STRPREFIX (p, "rd_operations=")) {
-                    p += 14;
+                    p += strlen("rd_operations");
                     if (virStrToLong_ll (p, &dummy, 10, rd_req) == -1)
                         VIR_DEBUG ("error reading rd_req: %s", p);
                 } else if (STRPREFIX (p, "wr_operations=")) {
-                    p += 14;
+                    p += strlen("wr_operations=");
                     if (virStrToLong_ll (p, &dummy, 10, wr_req) == -1)
                         VIR_DEBUG ("error reading wr_req: %s", p);
-                } else
+                } else if (STRPREFIX (p, "rd_total_times_ns=")) {
+                    p += strlen("rd_total_times_ns=");
+                    if (virStrToLong_ll (p, &dummy, 10, rd_total_times) == -1)
+                        VIR_DEBUG ("error reading rd_total_times: %s", p);
+                } else if (STRPREFIX (p, "wr_total_times_ns=")) {
+                    p += strlen("wr_total_times_ns=");
+                    if (virStrToLong_ll (p, &dummy, 10, wr_total_times) == -1)
+                        VIR_DEBUG ("error reading wr_total_times: %s", p);
+                } else if (STRPREFIX (p, "flush_operations=")) {
+                    p += strlen("flush_operations=");
+                    if (virStrToLong_ll (p, &dummy, 10, flush_req) == -1)
+                        VIR_DEBUG ("error reading flush_req: %s", p);
+                } else if (STRPREFIX (p, "flush_total_times_ns=")) {
+                    p += strlen("flush_total_times_ns=");
+                    if (virStrToLong_ll (p, &dummy, 10, flush_total_times) == -1)
+                        VIR_DEBUG ("error reading flush_total_times: %s", p);
+                } else {
                     VIR_DEBUG ("unknown block stat near %s", p);
+                }
 
                 /* Skip to next label. */
                 p = strchr (p, ' ');
diff --git a/src/qemu/qemu_monitor_text.h b/src/qemu/qemu_monitor_text.h
index b250738..f7d9f5c 100644
--- a/src/qemu/qemu_monitor_text.h
+++ b/src/qemu/qemu_monitor_text.h
@@ -61,8 +61,12 @@ int qemuMonitorTextGetBlockStatsInfo(qemuMonitorPtr mon,
                                      const char *devname,
                                      long long *rd_req,
                                      long long *rd_bytes,
+                                     long long *rd_total_times,
                                      long long *wr_req,
                                      long long *wr_bytes,
+                                     long long *wr_total_times,
+                                     long long *flush_req,
+                                     long long *flush_total_times,
                                      long long *errs);
 int qemuMonitorTextGetBlockExtent(qemuMonitorPtr mon,
                                   const char *devname,
-- 
1.7.6

--
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]