[libvirt] [PATCH] Fix memory reporting for inactive domains in the qemu driver.

Currently, 'info' will always report that mem = max mem. Make sure we actually return the correct mem value. Signed-off-by: Cole Robinson <crobinso@redhat.com> --- src/qemu_driver.c | 24 +++++++++++++++--------- 1 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/qemu_driver.c b/src/qemu_driver.c index d3eb3ad..4e3e531 100644 --- a/src/qemu_driver.c +++ b/src/qemu_driver.c @@ -2553,16 +2553,22 @@ static int qemudDomainGetInfo(virDomainPtr dom, } } - err = qemudDomainGetMemoryBalloon(dom->conn, vm, &balloon); - if (err < 0) - goto cleanup; - info->maxMem = vm->def->maxmem; - if (err == 0) - /* Balloon not supported, so maxmem is always the allocation */ - info->memory = vm->def->maxmem; - else - info->memory = balloon; + + if (virDomainIsActive(vm)) { + err = qemudDomainGetMemoryBalloon(dom->conn, vm, &balloon); + if (err < 0) + goto cleanup; + + if (err == 0) + /* Balloon not supported, so maxmem is always the allocation */ + info->memory = vm->def->maxmem; + else + info->memory = balloon; + } else { + info->memory = vm->def->memory; + } + info->nrVirtCpu = vm->def->vcpus; ret = 0; -- 1.6.0.6

On Thu, Jun 18, 2009 at 12:35:39PM -0400, Cole Robinson wrote:
Currently, 'info' will always report that mem = max mem. Make sure we actually return the correct mem value.
Yes that makes sense to me, ACK ! thanks ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Thu, Jun 18, 2009 at 12:35:39PM -0400, Cole Robinson wrote:
Currently, 'info' will always report that mem = max mem. Make sure we actually return the correct mem value.
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Ahh, very subtle ! ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
participants (3)
-
Cole Robinson
-
Daniel P. Berrange
-
Daniel Veillard