Discussion:
[libvirt] KVM Domain memory and disk usage
Qiang Fu
2014-02-25 14:19:34 UTC
Permalink
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
Martin Kletzander
2014-02-27 16:16:39 UTC
Permalink
Post by Qiang Fu
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
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.
Post by Qiang Fu
2. dominfo: this returns "Max memory" and "Used memory"
This is "memory" and "currentMemory" respectively.
Post by Qiang Fu
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
Post by Qiang Fu
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.
Post by Qiang Fu
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.
Post by Qiang Fu
Finally, we want to get the memory utilization of the domain on VM level in
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
Post by Qiang Fu
Thanks a lot,
Bruce
--
libvir-list mailing list
https://www.redhat.com/mailman/listinfo/libvir-list
Qiang Fu
2014-02-28 18:28:37 UTC
Permalink
Hi Martin,
Post by Qiang Fu
Right now we can get domain memory statistics through the following virsh
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
Post by Qiang Fu
Post by Qiang Fu
Hi all,
I am trying to use virsh to get the memory and storage usage for KVM
domain.
Post by Qiang Fu
Right now we can get domain memory statistics through the following virsh
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.
Post by Qiang Fu
2. dominfo: this returns "Max memory" and "Used memory"
This is "memory" and "currentMemory" respectively.
Post by Qiang Fu
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
Post by Qiang Fu
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.
Post by Qiang Fu
We don't understand what does "actual" stand for in dommemstat. Can
anyone
Post by Qiang Fu
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.
Post by Qiang Fu
Finally, we want to get the memory utilization of the domain on VM level
in
Post by Qiang Fu
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
Post by Qiang Fu
Thanks a lot,
Bruce
--
libvir-list mailing list
https://www.redhat.com/mailman/listinfo/libvir-list
Eric Blake
2014-02-28 20:15:37 UTC
Permalink
Post by Martin Kletzander
Post by Qiang Fu
Right now we can get domain memory statistics through the following virsh
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
Qiang Fu
2014-02-28 20:21:30 UTC
Permalink
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
Post by Eric Blake
Post by Martin Kletzander
Post by Qiang Fu
Right now we can get domain memory statistics through the following
virsh
Post by Martin Kletzander
Post by Qiang Fu
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
Post by Martin Kletzander
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
Eric Blake
2014-02-28 20:34:45 UTC
Permalink
Post by Qiang Fu
Hi Eric,
[please don't top-post on technical lists]
Post by Qiang Fu
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.
Post by Qiang Fu
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
Loading...