I currently use following approach but its failing
Find Max memory using following API
vdgiRet = virDomainGetInfo(domPtr, infoPtr);
memTotal = infoPtr->memory;
Find current utilization using following API
rVal = virDomainMemoryStats (domPtr, memStats, VIR_DOMAIN_MEMORY_STAT_NR, 0) ;
for (i = 0; i < rVal; i++)
{
if (memStats[i].tag == 7)
memUsed = memStats[i].val;
}
Which is the value of "VIR_DOMAIN_MEMORY_STAT_RSS = 7"
Then I calculate util as (memUsed/memTotal)
But the value of memUsed exceeds value of memTotal by small amount resulting in memUtil to be around 101 %.
I understand that VIR_DOMAIN_MEMORY_STAT_RSS is Resident Set Size of the process running the domain.
How do I Calculate the current memory utilization using alternate way?