[libvirt] Libvirt's DomainGetInfo Function Development

Andrea Bolognani abologna at redhat.com
Fri Aug 5 16:12:25 UTC 2016


On Fri, 2016-08-05 at 18:49 +0500, Aleem Akhtar wrote:
> Thanks.
> But I am using XEN.

I see. qemu-guest-agent is definitely not an option then.

> And I also don't want to go inside guest. I mean I want to
> get memory usage at the same level I am getting max memory
> and total memory.

The problem with that is that the host OS has zero knowledge
of how the guest OS is using the memory it's been assigned.

> I have another question. If Memory attribute of GetDomainInfo
> gives total memory I.e. memory in use plus remaining memory
> than what is the use of Max Memory?

You can configure your guest like

  <memory unit='KiB'>4194304</memory>
  <currentMemory unit='KiB'>2097152</currentMemory>

Doing so would give you 2 GB of initial memory and the
ability to increase that up to 4 GB at runtime.

So in the virDomainInfo structure, maxMem corresponds to
<memory> and memory corresponds to <currentMemory>.
Confusing, I know :)

> I also programmatically updated Memory using libvirt function
> I.e. 1GB to 512mb. When tried to get domain statistics again
> I got Max Memory 512mb and Memory 1GB. 
> How is this possible?

You mean memory = 512 MB and maxMem = 1 GB, right?


PS: This whole thread would have been more suitable for the
    libvirt-users mailing list - libvir-devel is targeted at
    the development of libvirt itself. Not a big deal, but
    maybe keep that in mind the next time :)
-- 
Andrea Bolognani / Red Hat / Virtualization




More information about the libvir-list mailing list