[libvirt] KVM Domain memory and disk usage

Hi all, I am trying to use virsh to get the memory and storage usage for KVM domain. Right now we can get domain memory statistics through the following virsh cmds: 1. dumpxml: this returns "memory" and "currentMemory" 2. dominfo: this returns "Max memory" and "Used memory" 3. dommemstat: this returns "actual" and "rss" We think "memory" (from dumpxml) = "Max memory" (from dominfo) and "currentMemory" (from dumpxml) = "Used memory" (from dominfo). Can anyone please help us to confirm this? We don't understand what does "actual" stand for in dommemstat. Can anyone please explain us about that? Finally, we want to get the memory utilization of the domain on VM level in percentage. And we derive it as: Utilization = rss / Used memory Can anyone please provide any comment on this? In terms of disk usage, it seems virsh / libvirt does not support any domain disk information right now. If not, can anyone please give us any idea how to get the domain disk information (size, used space and so on)? Thanks a lot, Bruce

On Tue, Feb 25, 2014 at 09:19:34AM -0500, Qiang Fu wrote:
Hi all,
I am trying to use virsh to get the memory and storage usage for KVM domain.
Right now we can get domain memory statistics through the following virsh cmds: 1. dumpxml: this returns "memory" and "currentMemory"
This are settings for the domain that you can change before the domain starts. "memory" is the maximum it can reach and "currentMemory" is what the domain will have it cut down to using a memballoon.
2. dominfo: this returns "Max memory" and "Used memory"
This is "memory" and "currentMemory" respectively.
3. dommemstat: this returns "actual" and "rss"
"actual" is what qemu reports when we call for stats on monitor, "rss" is RSS of the qemu process you'd get from /proc, e.g. # grep VmRSS /proc/$(pidof qemu-system-x86_64)/status VmRSS: 610508 kB
We think "memory" (from dumpxml) = "Max memory" (from dominfo) and "currentMemory" (from dumpxml) = "Used memory" (from dominfo). Can anyone please help us to confirm this?
Yes.
We don't understand what does "actual" stand for in dommemstat. Can anyone please explain us about that?
As I said above, that's what qemu tells us on the monitor. I haven't gone into too much detail when looking at the code, so I can't tell you many more details, that may be a question for qemu.
Finally, we want to get the memory utilization of the domain on VM level in percentage. And we derive it as: Utilization = rss / Used memory Can anyone please provide any comment on this?
In terms of disk usage, it seems virsh / libvirt does not support any domain disk information right now. If not, can anyone please give us any idea how to get the domain disk information (size, used space and so on)?
You can get data about volumes in pools (vol-info), about volumes per-domain (domblkinfo) and their statistics (domblkstat). Martin
Thanks a lot, Bruce
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

Hi Martin, Thank you so much for your explanation. As you said here:
Right now we can get domain memory statistics through the following virsh cmds: 1. dumpxml: this returns "memory" and "currentMemory"
This are settings for the domain that you can change before the domain starts. "memory" is the maximum it can reach and "currentMemory" is what the domain will have it cut down to using a memballoon. However somehow we can observe RSS greater than the "memory", which is supposed to be the maximum it can reach. Have you ever seen this happen and could you provide us any comment? Thanks, Bruce On Thu, Feb 27, 2014 at 11:16 AM, Martin Kletzander <mkletzan@redhat.com>wrote:
On Tue, Feb 25, 2014 at 09:19:34AM -0500, Qiang Fu wrote:
Hi all,
I am trying to use virsh to get the memory and storage usage for KVM domain.
Right now we can get domain memory statistics through the following virsh cmds: 1. dumpxml: this returns "memory" and "currentMemory"
This are settings for the domain that you can change before the domain starts. "memory" is the maximum it can reach and "currentMemory" is what the domain will have it cut down to using a memballoon.
2. dominfo: this returns "Max memory" and "Used memory"
This is "memory" and "currentMemory" respectively.
3. dommemstat: this returns "actual" and "rss"
"actual" is what qemu reports when we call for stats on monitor, "rss" is RSS of the qemu process you'd get from /proc, e.g.
# grep VmRSS /proc/$(pidof qemu-system-x86_64)/status VmRSS: 610508 kB
We think "memory" (from dumpxml) = "Max memory" (from dominfo) and "currentMemory" (from dumpxml) = "Used memory" (from dominfo). Can anyone please help us to confirm this?
Yes.
We don't understand what does "actual" stand for in dommemstat. Can anyone please explain us about that?
As I said above, that's what qemu tells us on the monitor. I haven't gone into too much detail when looking at the code, so I can't tell you many more details, that may be a question for qemu.
Finally, we want to get the memory utilization of the domain on VM level in percentage. And we derive it as: Utilization = rss / Used memory Can anyone please provide any comment on this?
In terms of disk usage, it seems virsh / libvirt does not support any domain disk information right now. If not, can anyone please give us any idea how to get the domain disk information (size, used space and so on)?
You can get data about volumes in pools (vol-info), about volumes per-domain (domblkinfo) and their statistics (domblkstat).
Martin
Thanks a lot, Bruce
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

On 02/28/2014 11:28 AM, Qiang Fu wrote:
Right now we can get domain memory statistics through the following virsh cmds: 1. dumpxml: this returns "memory" and "currentMemory"
This are settings for the domain that you can change before the domain starts. "memory" is the maximum it can reach and "currentMemory" is what the domain will have it cut down to using a memballoon.
However somehow we can observe RSS greater than the "memory", which is supposed to be the maximum it can reach. Have you ever seen this happen and could you provide us any comment?
RSS from where? Are you looking at the memory usage by the qemu process in the host, or the amount of memory in use by the guest? The qemu process uses more memory than what it makes available to the guest. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

Hi Eric, When we run the "virsh dommemstat" cmd, it returns us two values, actual and rss. I am referring to the rss here. I believe this is the qemu process in the host. So you mean it could be greater than the maximum memory allocation ("memory" in "virsh dumpxml") to the guest? Why? Thanks, Bruce On Fri, Feb 28, 2014 at 3:15 PM, Eric Blake <eblake@redhat.com> wrote:
On 02/28/2014 11:28 AM, Qiang Fu wrote:
Right now we can get domain memory statistics through the following virsh cmds: 1. dumpxml: this returns "memory" and "currentMemory"
This are settings for the domain that you can change before the domain starts. "memory" is the maximum it can reach and "currentMemory" is what the domain will have it cut down to using a memballoon.
However somehow we can observe RSS greater than the "memory", which is supposed to be the maximum it can reach. Have you ever seen this happen and could you provide us any comment?
RSS from where? Are you looking at the memory usage by the qemu process in the host, or the amount of memory in use by the guest? The qemu process uses more memory than what it makes available to the guest.
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 02/28/2014 01:21 PM, Qiang Fu wrote:
Hi Eric,
[please don't top-post on technical lists]
When we run the "virsh dommemstat" cmd, it returns us two values, actual and rss.
'virsh dommemstat' calls the virDomainMemoryStats() API, which in turn reports information from multiple places. First, it is issuing the qemu monitor command 'qom-get' on the balloon device from the guest, where it then populates these fields: swap-in, swap-out, major-fault, minor-fault, unused, and available. Next, it uses /proc/PID/stat parsing to learn statistics about the memory usage of the overall qemu process; this is where it populates the rss field.
I am referring to the rss here. I believe this is the qemu process in the host. So you mean it could be greater than the maximum memory allocation ("memory" in "virsh dumpxml") to the guest? Why?
The RSS of the qemu process includes overhead memory that qemu itself allocated to manage the guest, even though the guest does not see that much memory. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (3)
-
Eric Blake
-
Martin Kletzander
-
Qiang Fu