
Thanks. But I am using XEN. 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. 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? 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? On Aug 5, 2016 6:36 PM, "Andrea Bolognani" <abologna@redhat.com> wrote:
Ok. So that's why I was getting 1 GB as a result. So is there any way I can get memory in used
On Fri, 2016-08-05 at 17:45 +0500, Aleem Akhtar wrote: programmatically?
I mean without going inside guest domain.
The only way I can come up with at the moment relies on qemu-guest-agent:
$ virsh qemu-agent-command guest \ '{"execute": "guest-exec", "arguments": {"path": "/usr/bin/free", "capture-output": true}}' {"return":{"pid":1425}}
$ virsh qemu-agent-command guest \ '{"execute": "guest-exec-status", "arguments": {"pid": 1425}}' {"return":{"exitcode":0,"out-data":"ICA...zIK","exited":true}}
$ echo 'ICA...zIK' | base64 -d total used free Mem: 4020408 97244 3359560 Swap: 1048572 0 1048572
Of course you'll need to have qemu-guest-agent running inside the guest and process all the resulting information yourself.
See the virDomainQemuAgentCommand() API.
-- Andrea Bolognani / Red Hat / Virtualization