[PATCH 3/5] kvm tools: correctly handle mem ballooning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



from the virtio_balloon.h:
num_pages is the number of pages host wants Guest to give up.

Our implementation is doing the reverse, resulting in decreasing pages
when increasing needed and so on.
Reverse the implementation.

Signed-off-by: William Dauchy <william@xxxxxxxxx>
---
 tools/kvm/virtio/balloon.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/kvm/virtio/balloon.c b/tools/kvm/virtio/balloon.c
index e08f628..2201b9f 100644
--- a/tools/kvm/virtio/balloon.c
+++ b/tools/kvm/virtio/balloon.c
@@ -162,12 +162,12 @@ static void handle_mem(struct kvm *kvm, int fd, u32 type, u32 len, u8 *msg)
 
 	mem = *(int *)msg;
 	if (mem > 0) {
-		bdev.config.num_pages += 256 * mem;
-	} else if (mem < 0) {
-		if (bdev.config.num_pages < (u32)(256 * (-mem)))
+		if (bdev.config.num_pages < ((u32)(256 * mem)))
 			return;
 
-		bdev.config.num_pages += 256 * mem;
+		bdev.config.num_pages -= 256 * mem;
+	} else if (mem < 0) {
+		bdev.config.num_pages -= 256 * mem;
 	}
 
 	/* Notify that the configuration space has changed */
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux