[PATCH 11/11] qemu: bulk stats: add block allocation information

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

 



Management software, want to be able to allocate disk space on demand.
To support this, they need keep track of the space occupation
of the block device.
This information is reported by qemu as part of block stats.

This patch extend the block information in the bulk stats with
the allocation information, in order to save a call to the QEMU
monitor.
---
 src/libvirt.c          |  1 +
 src/qemu/qemu_driver.c | 15 +++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/src/libvirt.c b/src/libvirt.c
index cabfb91..81d71be 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -21591,6 +21591,7 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
  * "block.<num>.wr.times" - total time (ns) spent on writes.
  * "block.<num>.fl.reqs" - total flush requests
  * "block.<num>.fl.times" - total time (ns) spent on cache flushing
+ * "block.<num>.allocation" - offset of the highest written sector.
  *
  * Using 0 for @stats returns all stats groups supported by the given
  * hypervisor.
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 977e8c7..3fb54db 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17554,6 +17554,18 @@ do { \
         goto cleanup; \
 } while (0)
 
+#define QEMU_ADD_BLOCK_PARAM_ULL(RECORD, MAXPARAMS, NUM, NAME, VALUE) \
+do { \
+    char param_name[NAME_MAX]; \
+    snprintf(param_name, NAME_MAX, "block.%lu.%s", NUM, NAME); \
+    if (virTypedParamsAddULLong(&RECORD->params, \
+                                &RECORD->nparams, \
+                                MAXPARAMS, \
+                                param_name, \
+                                VALUE) < 0) \
+        goto cleanup; \
+} while (0)
+
 static int
 qemuDomainGetStatsBlock(virConnectPtr conn ATTRIBUTE_UNUSED,
                         virDomainObjPtr dom,
@@ -17595,6 +17607,9 @@ qemuDomainGetStatsBlock(virConnectPtr conn ATTRIBUTE_UNUSED,
                                 "fl.reqs", stats[i].flush_req);
         QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, i,
                                 "fl.times", stats[i].flush_total_times);
+
+        QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, i,
+                                 "allocation", stats[i].wr_highest_offset);
     }
 
     ret = 0;
-- 
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]