balloon: Fix overflow when reporting actual memory size
authorAdam Litke <agl@us.ibm.com>
Thu, 25 Mar 2010 13:58:17 +0000 (08:58 -0500)
committerAurelien Jarno <aurelien@aurel32.net>
Sat, 27 Mar 2010 12:53:34 +0000 (13:53 +0100)
commite2968167ee74837c427a8936a604f6f57b95feeb
tree299225978d6c3bdf0ed6ce20580693e8d85deefd
parentcbed60b6a4884bc7cbf2243458dfbc3970840386
balloon: Fix overflow when reporting actual memory size

Beginning with its introduction, the virtio balloon has had an overflow error
that causes 'info balloon' to misreport the actual memory size when the balloon
itself becomes larger than 4G.  Use a cast when converting dev->actual from
pages to kB to prevent overflows.

Before:
(qemu) info balloon
balloon: actual=5120
(qemu) balloon 1025
(qemu) info balloon
balloon: actual=1025
(qemu) balloon 1024
(qemu) info balloon
balloon: actual=5120

After:
(qemu) info balloon
balloon: actual=5120
(qemu) balloon 1025
(qemu) info balloon
balloon: actual=1025
(qemu) balloon 1024
(qemu) info balloon
balloon: actual=1024

Signed-off-by: Adam Litke <agl@us.ibm.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
hw/virtio-balloon.c