Hello, I'm trying to get memory usage statistic inside a guest machine using virDomainMemoryStats function at libvirt. According to http://libvirt.org/html/libvirt-libvirt.html#virDomainMemoryStatTags the structure could have a lot of useful memory statistic but the amount of parameters depends on the hypervisor and the driver. However using KVM I'm able to get VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON and VIR_DOMAIN_MEMORY_STAT_RSS only. Am I right it is not possible to get additional info such as used/unused memory inside a guest machine in case of KVM?
On Thu, Jul 03, 2014 at 04:31:46PM +0300, Gleb Voronich wrote:>Hello, > >I'm trying to get memory usage statistic inside a guest machine using >virDomainMemoryStats function at libvirt. >According to >http://libvirt.org/html/libvirt-libvirt.html#virDomainMemoryStatTags the >structure could have a lot of useful memory statistic but the amount of >parameters depends on the hypervisor and the driver. >However using KVM I'm able to get VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON >and VIR_DOMAIN_MEMORY_STAT_RSS only. >QEMU/KVM only supports these two IIRC.>Am I right it is not possible to get additional info such as used/unused >memory inside a guest machine in case of KVM? >Yes. Actually reporting some data from *inside* the domain is not what libvirt aims to provide. Martin
On 07/03/2014 07:58 AM, Martin Kletzander wrote:> On Thu, Jul 03, 2014 at 04:31:46PM +0300, Gleb Voronich wrote: >> Hello, >> >> I'm trying to get memory usage statistic inside a guest machine using >> virDomainMemoryStats function at libvirt. >> According to >> http://libvirt.org/html/libvirt-libvirt.html#virDomainMemoryStatTags the >> structure could have a lot of useful memory statistic but the amount of >> parameters depends on the hypervisor and the driver. >> However using KVM I'm able to get VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON >> and VIR_DOMAIN_MEMORY_STAT_RSS only. >> > > QEMU/KVM only supports these two IIRC. > >> Am I right it is not possible to get additional info such as used/unused >> memory inside a guest machine in case of KVM? >> > > Yes. Actually reporting some data from *inside* the domain is not > what libvirt aims to provide.In the case of the memory balloon device, libvirt CAN provide stats from the guest, because of the way the balloon device works. But if you aren't using a balloon, or if the guest is not cooperative, this won't work. Better would be a guest-agent command for getting at this information (but again, you are relying on guest cooperation). In short, libvirt is great at stats from the HOST point of view, but for stats from the GUEST point of view, you are often better off using the same mechanisms that you would for getting stats from a remote bare metal machine, without needing libvirt in the mix. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
At Thu, 3 Jul 2014 15:58:41 +0200, Martin Kletzander wrote:> > On Thu, Jul 03, 2014 at 04:31:46PM +0300, Gleb Voronich wrote: > >Hello, > > > >I'm trying to get memory usage statistic inside a guest machine using > >virDomainMemoryStats function at libvirt. > >According to > >http://libvirt.org/html/libvirt-libvirt.html#virDomainMemoryStatTags the > >structure could have a lot of useful memory statistic but the amount of > >parameters depends on the hypervisor and the driver. > >However using KVM I'm able to get VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON > >and VIR_DOMAIN_MEMORY_STAT_RSS only. > > > > QEMU/KVM only supports these two IIRC.Actually, you should get more stats when using the virtio balloon driver in your guests. E.g. the windows virtio driver supports these stats: SWAP_IN 0 /* Amount of memory swapped in */ SWAP_OUT 1 /* Amount of memory swapped out */ MAJFLT 2 /* Number of major faults */ MINFLT 3 /* Number of minor faults */ MEMFREE 4 /* Total amount of free memory */ MEMTOT 5 /* Total amount of memory */ See https://github.com/YanVugenfirer/kvm-guest-drivers-windows/blob/9a5cb6749d68bad8c346d31b811c854ab078652e/Balloon/sys/public.h IFAIR, these should be queried by the virDomainMemoryStats function. Claudio -- BSc (Comp) Claudio Bley - Principal Software Engineer AV-TEST GmbH, Klewitzstr. 7, 39112 Magdeburg, Germany Phone: +49 391 6075460, Fax: +49 391 6075469 Web: <http://www.av-test.org> * https://twitter.com/avtestorg * https://facebook.com/avtestorg * * https://plus.google.com/100383867141221115206/ * Eingetragen am / Registered at: Amtsgericht Stendal (HRB 114076) Geschaeftsfuehrer (CEO): Andreas Marx, Guido Habicht, Maik Morgenstern Our services shall be effected on the basis of the General Terms and Conditions of AV-TEST GmbH, which are accessible under <http://www.av-test.org/en/av-test/terms-and-conditions/> or obtainable upon request. Unsere Leistungen erfolgen auf der Grundlage der Allgemeinen Geschäftsbedingungen der AV-TEST GmbH, die unter <http://www.av-test.org/av-test/agb/> abrufbar sind oder auf Anfrage übersandt werden.