[libvirt] [PATCH 7/8] If available fetch the balloon driver memory stats
Daniel P. Berrange
berrange at redhat.com
Wed Jul 3 11:07:10 UTC 2013
On Tue, Jul 02, 2013 at 09:39:25AM -0400, John Ferlan wrote:
> 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;
> + }
If we hide all the QOM stuff inside the existing qemuMonitorGetMemoryStats()
API, then this patch just goes away entirely.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the libvir-list
mailing list