From patchwork Fri Sep 21 11:17:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasilis Liaskovitis X-Patchwork-Id: 1491391 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id CC0AF402E1 for ; Fri, 21 Sep 2012 11:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933046Ab2IULSo (ORCPT ); Fri, 21 Sep 2012 07:18:44 -0400 Received: from mail-bk0-f46.google.com ([209.85.214.46]:44504 "EHLO mail-bk0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933045Ab2IULRy (ORCPT ); Fri, 21 Sep 2012 07:17:54 -0400 Received: by mail-bk0-f46.google.com with SMTP id w11so743835bku.19 for ; Fri, 21 Sep 2012 04:17:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=1XxcQa/iI4XYgAGgdwnE1yzKy19voFDIT06zLXVAWS4=; b=hq8h4Na5FBssT89kAHcb5w4K2ClU96FJswcYM/ixo+Bzx+fK4OhyES6N1S9CSO11+A PDtEPYCAvrakLGqN20tqwgLy7YYmKLiyfNhUmLmXB0HMIt4ImuGgURvchUkawdiX8HGQ rR8sK370MCGhdVSNa1pzhvPnpk4e1ZlQZ7GKZ1VBUVopC6lMknATFHzQmAs/Q4pg2ZtZ uTZ41qrsb2z0/LszIYzGIUhYqybWldG/dLV5pDLi8a5qVQQFjhgwcb5bjOZSX9eByHPY 7Oq1/YPz019yKPfF0gnIrUYd3Z1XvzvniNIfD9aRxix/86hAhqn9CEwlDdwZk1t0W0c9 nuHg== Received: by 10.204.148.66 with SMTP id o2mr1970562bkv.43.1348226273764; Fri, 21 Sep 2012 04:17:53 -0700 (PDT) Received: from dhcp-192-168-178-175.ri.profitbricks.localdomain ([62.217.45.26]) by mx.google.com with ESMTPS id x13sm5271435bkv.16.2012.09.21.04.17.53 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 21 Sep 2012 04:17:53 -0700 (PDT) From: Vasilis Liaskovitis To: qemu-devel@nongnu.org, kvm@vger.kernel.org, seabios@seabios.org Cc: avi@redhat.com, anthony@codemonkey.ws, kevin@koconnor.net, wency@cn.fujitsu.com, kraxel@redhat.com, eblake@redhat.com, blauwirbel@gmail.com, gleb@redhat.com, imammedo@redhat.com, Vasilis Liaskovitis Subject: [RFC PATCH v3 13/19] balloon: update with hotplugged memory Date: Fri, 21 Sep 2012 13:17:29 +0200 Message-Id: <1348226255-4226-14-git-send-email-vasilis.liaskovitis@profitbricks.com> X-Mailer: git-send-email 1.7.9 In-Reply-To: <1348226255-4226-1-git-send-email-vasilis.liaskovitis@profitbricks.com> References: <1348226255-4226-1-git-send-email-vasilis.liaskovitis@profitbricks.com> X-Gm-Message-State: ALoCoQlJi00hAwoutMIBg8gLfY6am3rTRGD1sMikhssCrGqt8/kOiOBb8K0THgXkYTU49qKvaRRO Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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); } }