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