From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:46295) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkwVU-0000CW-8z for qemu-devel@nongnu.org; Tue, 18 Dec 2012 07:42:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TkwVS-000061-8w for qemu-devel@nongnu.org; Tue, 18 Dec 2012 07:42:48 -0500 Received: from mail-bk0-f47.google.com ([209.85.214.47]:44348) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TkwVS-00005C-0b for qemu-devel@nongnu.org; Tue, 18 Dec 2012 07:42:46 -0500 Received: by mail-bk0-f47.google.com with SMTP id j4so284816bkw.20 for ; Tue, 18 Dec 2012 04:42:45 -0800 (PST) From: Vasilis Liaskovitis Date: Tue, 18 Dec 2012 13:41:48 +0100 Message-Id: <1355834518-17989-21-git-send-email-vasilis.liaskovitis@profitbricks.com> In-Reply-To: <1355834518-17989-1-git-send-email-vasilis.liaskovitis@profitbricks.com> References: <1355834518-17989-1-git-send-email-vasilis.liaskovitis@profitbricks.com> Subject: [Qemu-devel] [RFC PATCH v4 20/30] balloon: update with hotplugged memory List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, seabios@seabios.org Cc: Vasilis Liaskovitis , pingfank@linux.vnet.ibm.com, gleb@redhat.com, stefanha@gmail.com, jbaron@redhat.com, blauwirbel@gmail.com, kevin@koconnor.net, kraxel@redhat.com, anthony@codemonkey.ws 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..149e8ba 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