File kvm-qemu-preXX-balloon-report-overflow.patch of Package kvm
This backported patch is loosely derrived from the following upstream patch:
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>
---
Index: qemu-kvm-0.12.3/hw/virtio-balloon.c
===================================================================
--- qemu-kvm-0.12.3.orig/hw/virtio-balloon.c
+++ qemu-kvm-0.12.3/hw/virtio-balloon.c
@@ -142,7 +142,7 @@ static ram_addr_t virtio_balloon_to_targ
virtio_notify_config(&dev->vdev);
}
- return ram_size - (dev->actual << VIRTIO_BALLOON_PFN_SHIFT);
+ return ram_size - ((uint64_t)dev->actual << VIRTIO_BALLOON_PFN_SHIFT);
}
static void virtio_balloon_save(QEMUFile *f, void *opaque)