[PATCH 07/11] qemu: bulk stats: implement balloon group

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

 



This patch implements the VIR_DOMAIN_STATS_BALLOON
group of statistics.

Signed-off-by: Francesco Romani <fromani@xxxxxxxxxx>
---
 include/libvirt/libvirt.h.in |  1 +
 src/qemu/qemu_driver.c       | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 992b124..78eb9b8 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -2512,6 +2512,7 @@ struct _virDomainStatsRecord {
 typedef enum {
     VIR_DOMAIN_STATS_STATE = (1 << 0), /* return domain state */
     VIR_DOMAIN_STATS_CPU_TOTAL = (1 << 1), /* return domain CPU info */
+    VIR_DOMAIN_STATS_BALLOON = (1 << 2), /* return domain balloon info */
 } virDomainStatsTypes;
 
 typedef enum {
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 7ffd052..9825f61 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17397,6 +17397,37 @@ qemuDomainGetStatsCpu(virConnectPtr conn ATTRIBUTE_UNUSED,
     return 0;
 }
 
+static int
+qemuDomainGetStatsBalloon(virConnectPtr conn,
+                          virDomainObjPtr dom,
+                          virDomainStatsRecordPtr record,
+                          int *maxparams,
+                          unsigned int privflags ATTRIBUTE_UNUSED)
+{
+    virQEMUDriverPtr driver = conn->privateData;
+    unsigned long cur_balloon = 0;
+    int err = 0;
+
+    err = qemuDomainGetBalloonMemory(driver, dom, &cur_balloon);
+    if (err)
+        return -1;
+
+    if (virTypedParamsAddULLong(&record->params,
+                                &record->nparams,
+                                maxparams,
+                                "balloon.current",
+                                cur_balloon) < 0)
+        return -1;
+
+    if (virTypedParamsAddULLong(&record->params,
+                                &record->nparams,
+                                maxparams,
+                                "balloon.maximum",
+                                dom->def->mem.max_balloon) < 0)
+        return -1;
+
+    return 0;
+}
 
 typedef int
 (*qemuDomainGetStatsFunc)(virConnectPtr conn,
@@ -17413,6 +17444,7 @@ struct qemuDomainGetStatsWorker {
 static struct qemuDomainGetStatsWorker qemuDomainGetStatsWorkers[] = {
     { qemuDomainGetStatsState, VIR_DOMAIN_STATS_STATE},
     { qemuDomainGetStatsCpu, VIR_DOMAIN_STATS_CPU_TOTAL },
+    { qemuDomainGetStatsBalloon, VIR_DOMAIN_STATS_BALLOON },
     { NULL, 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]