This one was actually correct originally. When we inflate (-i) the balloon we increase num_pages, which is a counter of how many pages the balloon has. Thanks, Sasha On Wed, Oct 24, 2012 at 8:51 AM, William Dauchy <william@xxxxxxxxx> wrote: > 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