]> git.proxmox.com Git - qemu.git/commitdiff
virtio-balloon: fixed endianness bug in the config space
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Thu, 7 Apr 2011 03:02:04 +0000 (13:02 +1000)
committerStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Thu, 7 Apr 2011 13:25:53 +0000 (14:25 +0100)
The specification for the virtio balloon device requres that the values
in the config space be encoded little-endian.  This differs from most
virtio things, where guest-native endian is the norm.

Currently, the qemu virtio-balloon code correctly makes the conversion
on get_config(), but doesn't on set_config for the 'actual' field.  The
kernel driver, on the other hand, correctly converts when setting the
actual field, but does not convert when reading the config space.  The
upshot is that virtio-balloon will only work correctly if both host and
guest are LE, making all the conversions nops.

This patch corrects the qemu side, correctly doing host-native <-> LE
conversions when accessing the config space.  This won't break any setups
that aren't already broken, and fixes the case of BE host, LE guest.
Fixing the BE guest case will require kernel fixes as well.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
hw/virtio-balloon.c

index 8adddeaa5335e9801b2157c0286ef31a357fa17f..257baf8d4fcc19430deff459eb93b1c154a4df17 100644 (file)
@@ -191,7 +191,7 @@ static void virtio_balloon_set_config(VirtIODevice *vdev,
     VirtIOBalloon *dev = to_virtio_balloon(vdev);
     struct virtio_balloon_config config;
     memcpy(&config, config_data, 8);
-    dev->actual = config.actual;
+    dev->actual = le32_to_cpu(config.actual);
 }
 
 static uint32_t virtio_balloon_get_features(VirtIODevice *vdev, uint32_t f)