Patchwork [RFC,1/3] virtio-balloon: add guest_get_actual_ram()

login
register
mail settings
Submitter Luiz Capitulino
Date Dec. 18, 2012, 8:16 p.m.
Message ID <1355861815-2607-2-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/207197/
State New
Headers show

Comments

Luiz Capitulino - Dec. 18, 2012, 8:16 p.m.
A future commit will also want to use this.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 hw/virtio-balloon.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Patch

diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c
index dd1a650..03248df 100644
--- a/hw/virtio-balloon.c
+++ b/hw/virtio-balloon.c
@@ -161,6 +161,11 @@  static uint32_t virtio_balloon_get_features(VirtIODevice *vdev, uint32_t f)
     return f;
 }
 
+static ram_addr_t guest_get_actual_ram(const VirtIOBalloon *s)
+{
+    return ram_size - ((uint64_t) s->actual << VIRTIO_BALLOON_PFN_SHIFT);
+}
+
 static void virtio_balloon_stat(void *opaque, BalloonInfo *info)
 {
     VirtIOBalloon *dev = opaque;
@@ -186,8 +191,7 @@  static void virtio_balloon_stat(void *opaque, BalloonInfo *info)
      */
     reset_stats(dev);
 
-    info->actual = ram_size - ((uint64_t) dev->actual <<
-                               VIRTIO_BALLOON_PFN_SHIFT);
+    info->actual = guest_get_actual_ram(dev);
 }
 
 static void virtio_balloon_to_target(void *opaque, ram_addr_t target)