Re: Libvirt's DomainGetInfo Function Development

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

 



Ok. So that's why I was getting 1 GB as a result.

So is there any way I can get memory in used programmatically?
I mean without going inside guest domain.

On Aug 5, 2016 5:42 PM, "Andrea Bolognani" <abologna@xxxxxxxxxx> wrote:
On Thu, 2016-08-04 at 20:02 +0500, Aleem Akhtar wrote:

> I am trying to get stats of Domains running under XEN hypervisor.
> I used Libvirt function for this purpose. I am trying to understand
> output for Memory. Domain running is Fedora-22 with 1GB Ram. Here is my
> code

> y = virDomainGetInfo(allDomain, &info);
> if (y == -1)
>     printf("Errorl\n");
> else {
>     printf("Max Memory: %lu\n", info.maxMem);
>     printf("Memory: %lu", info.memory);
> }

> I get output as

> Max Memory: 1048576
> Memory: 1048576

> Now, as per Libvirt API, info.memory should return the memory in KBytes
> used by the domain. My Question is, if info.memory returns memory used
> and my domain is using complete 100% of Max Memory or not? Also I tried
> to create Domain with memory varying from 128MB to 2GB with same effect.
> I also tried to run some applications in Domain but Memory usage return
> by given function does not change. Any help or guidance will be much
> appreciated.

The relevant virDomainInfo field is described as

  /* the memory in KBytes used by the domain */
  unsigned long memory;

but in this context, "used by" really means "available to".

So the output above tells you that your Fedora guest has
1 GB of memory available; how much of that memory is actually
being used by the guest OS is something that you can find out
by running top inside the guest.

-- 
Andrea Bolognani / Red Hat / Virtualization
--
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]