[libvirt] Libvirt's DomainGetInfo Function Development

Martin Kletzander mkletzan at redhat.com
Sat Aug 6 06:00:10 UTC 2016

On Fri, Aug 05, 2016 at 06:12:25PM +0200, Andrea Bolognani wrote:
>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.

You could try using virDomainMemoryStats(), but I'm not sure how much
functionality Xen provides in this regard. Meybe none, Meybe everything
needed.  Idon't have Xen, so you have to try yourself.  To see how it is
used (or just to try it out) check out 'virsh dommemstat'.

>> 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
>libvir-list mailing list
>libvir-list at redhat.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20160806/83e2dcd1/attachment-0001.sig>

More information about the libvir-list mailing list