From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TF1FA-0000G0-LY for qemu-devel@nongnu.org; Fri, 21 Sep 2012 07:18:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TF1F4-0003xz-Ee for qemu-devel@nongnu.org; Fri, 21 Sep 2012 07:18:00 -0400 Received: from mail-bk0-f45.google.com ([209.85.214.45]:44993) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TF1F4-0003r3-8R for qemu-devel@nongnu.org; Fri, 21 Sep 2012 07:17:54 -0400 Received: by mail-bk0-f45.google.com with SMTP id jg9so1317036bkc.4 for ; Fri, 21 Sep 2012 04:17:53 -0700 (PDT) From: Vasilis Liaskovitis Date: Fri, 21 Sep 2012 13:17:29 +0200 Message-Id: <1348226255-4226-14-git-send-email-vasilis.liaskovitis@profitbricks.com> In-Reply-To: <1348226255-4226-1-git-send-email-vasilis.liaskovitis@profitbricks.com> References: <1348226255-4226-1-git-send-email-vasilis.liaskovitis@profitbricks.com> Subject: [Qemu-devel] [RFC PATCH v3 13/19] balloon: update with hotplugged memory List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, kvm@vger.kernel.org, seabios@seabios.org Cc: Vasilis Liaskovitis , gleb@redhat.com, blauwirbel@gmail.com, kevin@koconnor.net, avi@redhat.com, anthony@codemonkey.ws, imammedo@redhat.com, eblake@redhat.com, kraxel@redhat.com query-balloon and "info balloon" should report total memory available to the guest. balloon inflate/ deflate can also use all memory available to the guest (initial + hotplugged memory) Ballon driver has been minimaly tested with the patch, please review and test. Caveat: if the guest does not online hotplugged-memory, it's easy for a balloon inflate command to OOM a guest. Signed-off-by: Vasilis Liaskovitis --- hw/virtio-balloon.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c index dd1a650..bca21bc 100644 --- a/hw/virtio-balloon.c +++ b/hw/virtio-balloon.c @@ -22,6 +22,7 @@ #include "virtio-balloon.h" #include "kvm.h" #include "exec-memory.h" +#include "dimm.h" #if defined(__linux__) #include @@ -147,10 +148,11 @@ static void virtio_balloon_set_config(VirtIODevice *vdev, VirtIOBalloon *dev = to_virtio_balloon(vdev); struct virtio_balloon_config config; uint32_t oldactual = dev->actual; + uint64_t hotplugged_ram_size = get_hp_memory_total(); memcpy(&config, config_data, 8); dev->actual = le32_to_cpu(config.actual); if (dev->actual != oldactual) { - qemu_balloon_changed(ram_size - + qemu_balloon_changed(ram_size + hotplugged_ram_size - (dev->actual << VIRTIO_BALLOON_PFN_SHIFT)); } } @@ -188,17 +190,20 @@ static void virtio_balloon_stat(void *opaque, BalloonInfo *info) info->actual = ram_size - ((uint64_t) dev->actual << VIRTIO_BALLOON_PFN_SHIFT); + info->actual += get_hp_memory_total(); } static void virtio_balloon_to_target(void *opaque, ram_addr_t target) { VirtIOBalloon *dev = opaque; + uint64_t hotplugged_ram_size = get_hp_memory_total(); - if (target > ram_size) { - target = ram_size; + if (target > ram_size + hotplugged_ram_size) { + target = ram_size + hotplugged_ram_size; } if (target) { - dev->num_pages = (ram_size - target) >> VIRTIO_BALLOON_PFN_SHIFT; + dev->num_pages = (ram_size + hotplugged_ram_size - target) >> + VIRTIO_BALLOON_PFN_SHIFT; virtio_notify_config(&dev->vdev); } } -- 1.7.9