[PATCH 7/8] If available fetch the balloon driver memory stats

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

 



In the 'virsh dommemstats <domain>' qemu driver code, if we have a
balloonpath and we hadn't already collected the data (somehow) from the
"query-balloon" command, then use qom-get to attempt to fill in the
domain memory stats data from the balloon driver.
---
 src/qemu/qemu_driver.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f51e766..c9a66ff 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -9499,6 +9499,7 @@ qemuDomainMemoryStats(virDomainPtr dom,
     virQEMUDriverPtr driver = dom->conn->privateData;
     virDomainObjPtr vm;
     int ret = -1;
+    qemuMonitorObjectProperty prop;
 
     virCheckFlags(0, -1);
 
@@ -9518,6 +9519,22 @@ qemuDomainMemoryStats(virDomainPtr dom,
         qemuDomainObjPrivatePtr priv = vm->privateData;
         qemuDomainObjEnterMonitor(driver, vm);
         ret = qemuMonitorGetMemoryStats(priv->mon, stats, nr_stats);
+
+        /* The above call should only return the 'actual' memory due to
+         * changes that disabled statistics gathering from query-balloon.
+         * If so, let's check if we have a path to the balloon device
+         * and then try to gather more stats from there if possible
+         */
+        if ((ret == 0 || ret == 1) && priv->balloonpath) {
+            memset(&prop, 0, sizeof(qemuMonitorObjectProperty));
+            prop.type = QEMU_MONITOR_OBJECT_PROPERTY_BALLOON_STATS;
+            prop.curelems = ret;
+            prop.maxelems = nr_stats;
+            prop.val.ptr = (void **)stats;
+            if (qemuMonitorGetObjectProperty(priv->mon, priv->balloonpath,
+                                             "guest-stats", &prop) == 0)
+                ret = prop.curelems;
+        }
         qemuDomainObjExitMonitor(driver, vm);
 
         if (ret >= 0 && ret < nr_stats) {
-- 
1.8.1.4

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