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

[libvirt] [PATCHv2 54/62] qemu: Export stats relevant for the frontend separately



While we report the read and written byte stats for every single layer
of the backing chain, qemu in fact reports them only for the frontend.

Split out the relevant stats into a separate function so that we can
later fix this bug and stop reporting it for backing chain entries where
they don't make sense.

Signed-off-by: Peter Krempa <pkrempa redhat com>
---
 src/qemu/qemu_driver.c | 54 ++++++++++++++++++++++++++++++++++----------------
 1 file changed, 37 insertions(+), 17 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6ea86c8cbf..479bf3adfe 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -20096,23 +20096,6 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
         goto cleanup;
     }

-    QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx,
-                            "rd.reqs", entry->rd_req);
-    QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx,
-                            "rd.bytes", entry->rd_bytes);
-    QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx,
-                            "rd.times", entry->rd_total_times);
-    QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx,
-                            "wr.reqs", entry->wr_req);
-    QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx,
-                            "wr.bytes", entry->wr_bytes);
-    QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx,
-                            "wr.times", entry->wr_total_times);
-    QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx,
-                            "fl.reqs", entry->flush_req);
-    QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx,
-                            "fl.times", entry->flush_total_times);
-
     QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx,
                              "allocation", entry->wr_highest_offset);

@@ -20141,6 +20124,39 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
 }


+static int
+qemuDomainGetStatsBlockExportFrontend(const char *frontendname,
+                                      virHashTablePtr stats,
+                                      size_t recordnr,
+                                      virDomainStatsRecordPtr records,
+                                      int *nrecords)
+{
+    qemuBlockStats *entry;
+    int ret = -1;
+
+    /* In case where qemu didn't provide the stats we stop here rather than
+     * trying to refresh the stats from the disk. Inability to provide stats is
+     * usually caused by blocked storage so this would make libvirtd hang */
+    if (!stats || !frontendname || !(entry = virHashLookup(stats, frontendname))) {
+        ret = 0;
+        goto cleanup;
+    }
+
+    QEMU_ADD_BLOCK_PARAM_LL(records, nrecords, recordnr, "rd.reqs", entry->rd_req);
+    QEMU_ADD_BLOCK_PARAM_LL(records, nrecords, recordnr, "rd.bytes", entry->rd_bytes);
+    QEMU_ADD_BLOCK_PARAM_LL(records, nrecords, recordnr, "rd.times", entry->rd_total_times);
+    QEMU_ADD_BLOCK_PARAM_LL(records, nrecords, recordnr, "wr.reqs", entry->wr_req);
+    QEMU_ADD_BLOCK_PARAM_LL(records, nrecords, recordnr, "wr.bytes", entry->wr_bytes);
+    QEMU_ADD_BLOCK_PARAM_LL(records, nrecords, recordnr, "wr.times", entry->wr_total_times);
+    QEMU_ADD_BLOCK_PARAM_LL(records, nrecords, recordnr, "fl.reqs", entry->flush_req);
+    QEMU_ADD_BLOCK_PARAM_LL(records, nrecords, recordnr, "fl.times", entry->flush_total_times);
+
+    ret = 0;
+ cleanup:
+    return ret;
+}
+
+
 static int
 qemuDomainGetStatsBlockExportHeader(virDomainDiskDefPtr disk,
                                     virStorageSourcePtr src,
@@ -20195,6 +20211,10 @@ qemuDomainGetStatsBlockExportDisk(virDomainDiskDefPtr disk,
                                                 records, nrecords) < 0)
             goto cleanup;

+        if (qemuDomainGetStatsBlockExportFrontend(alias, stats, *recordnr,
+                                                  records, nrecords) < 0)
+            goto cleanup;
+
         if (qemuDomainGetStatsOneBlock(driver, cfg, dom, records, nrecords,
                                        alias, src, *recordnr,
                                        stats) < 0)
-- 
2.16.2


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