[PATCH 03/11] qemu: add helper to get the block stats

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

 



Add an helper function to get the block stats
of a disk.
This helper is meant to be used by the bulk stats API;
future patches may want to refactor qemuDomainGetBlock*
to make use of this function as well.

Signed-off-by: Francesco Romani <fromani@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1842e60..e7dd5ed 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -136,6 +136,18 @@ VIR_LOG_INIT("qemu.qemu_driver");
 
 #define QEMU_NB_BANDWIDTH_PARAM 6
 
+struct qemuBlockStats {
+    long long rd_req;
+    long long rd_bytes;
+    long long wr_req;
+    long long wr_bytes;
+    long long rd_total_times;
+    long long wr_total_times;
+    long long flush_req;
+    long long flush_total_times;
+    long long errs; /* meaning less for QEMU */
+};
+
 static void processWatchdogEvent(virQEMUDriverPtr driver,
                                  virDomainObjPtr vm,
                                  int action);
@@ -178,6 +190,12 @@ static int qemuDomainHelperGetVcpus(virDomainObjPtr vm,
                                     unsigned char *cpumaps,
                                     int maplen);
 
+static int qemuDiskGetBlockStats(virQEMUDriverPtr driver,
+                                 virDomainObjPtr vm,
+                                 virDomainDiskDefPtr disk,
+                                 struct qemuBlockStats *stats);
+
+
 virQEMUDriverPtr qemu_driver = NULL;
 
 
@@ -9672,6 +9690,47 @@ qemuDomainBlockStats(virDomainPtr dom,
     return ret;
 }
 
+
+
+static int
+qemuDiskGetBlockStats(virQEMUDriverPtr driver,
+                      virDomainObjPtr vm,
+                      virDomainDiskDefPtr disk,
+                      struct qemuBlockStats *stats)
+{
+    int ret = -1;
+    qemuDomainObjPrivatePtr priv;
+
+    if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_QUERY) < 0)
+        goto cleanup;
+
+    priv = vm->privateData;
+
+    qemuDomainObjEnterMonitor(driver, vm);
+
+    ret = qemuMonitorGetBlockStatsInfo(priv->mon,
+                                       disk->info.alias,
+                                       &stats->rd_req,
+                                       &stats->rd_bytes,
+                                       &stats->rd_total_times,
+                                       &stats->wr_req,
+                                       &stats->wr_bytes,
+                                       &stats->wr_total_times,
+                                       &stats->flush_req,
+                                       &stats->flush_total_times,
+                                       &stats->errs);
+
+    qemuDomainObjExitMonitor(driver, vm);
+
+    if (!qemuDomainObjEndJob(driver, vm))
+        vm = NULL;
+
+ cleanup:
+    if (vm)
+        virObjectUnlock(vm);
+    return ret;
+}
+
 static int
 qemuDomainBlockStatsFlags(virDomainPtr dom,
                           const char *path,
-- 
1.9.3

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