Patchwork fix endianess when changing memory with balloon.

login
register
mail settings
Submitter Victor Toso
Date Sept. 21, 2012, 8:29 p.m.
Message ID <1348259353-31417-1-git-send-email-victor@itoso.org>
Download mbox | patch
Permalink /patch/185911/
State New
Headers show

Comments

Victor Toso - Sept. 21, 2012, 8:29 p.m.
Signed-off-by: Victor Toso <victor@itoso.org>
---
 hw/virtio-balloon.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Patch

diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c
index dd1a650..9e0cd88 100644
--- a/hw/virtio-balloon.c
+++ b/hw/virtio-balloon.c
@@ -193,12 +193,15 @@  static void virtio_balloon_stat(void *opaque, BalloonInfo *info)
 static void virtio_balloon_to_target(void *opaque, ram_addr_t target)
 {
     VirtIOBalloon *dev = opaque;
+    uint32_t num_pages;
 
     if (target > ram_size) {
         target = ram_size;
     }
     if (target) {
-        dev->num_pages = (ram_size - target) >> VIRTIO_BALLOON_PFN_SHIFT;
+        num_pages = (ram_size - target) >> VIRTIO_BALLOON_PFN_SHIFT;
+        dev->num_pages = virtio_is_big_endian() ?
+            cpu_to_be32(num_pages): cpu_to_le32(num_pages);
         virtio_notify_config(&dev->vdev);
     }
 }