[libvirt] Libvirt's DomainGetInfo Function Development

Andrea Bolognani abologna at redhat.com
Fri Aug 5 13:36:20 UTC 2016

On Fri, 2016-08-05 at 17:45 +0500, Aleem Akhtar 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
> I mean without going inside guest domain.

The only way I can come up with at the moment relies on

  $ virsh qemu-agent-command guest \
          '{"execute": "guest-exec",
            "arguments": {"path": "/usr/bin/free",
                          "capture-output": true}}'

  $ virsh qemu-agent-command guest \
          '{"execute": "guest-exec-status",
            "arguments": {"pid": 1425}}'

  $ 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

See the virDomainQemuAgentCommand() API.

Andrea Bolognani / Red Hat / Virtualization

More information about the libvir-list mailing list