Patchwork [v2,2/2] pvpanic: fix fwcfg for big endian hosts

login
register
mail settings
Submitter Michael S. Tsirkin
Date June 18, 2013, 1:02 p.m.
Message ID <1371560351-29057-2-git-send-email-mst@redhat.com>
Download mbox | patch
Permalink /patch/252344/
State New
Headers show

Comments

Michael S. Tsirkin - June 18, 2013, 1:02 p.m.
Convert port number to little endian when
exposing it in fw cfg.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/misc/pvpanic.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Patch

diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
index 8329a0a..7fd82cb 100644
--- a/hw/misc/pvpanic.c
+++ b/hw/misc/pvpanic.c
@@ -104,10 +104,11 @@  static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp)
 static void pvpanic_fw_cfg(ISADevice *dev, FWCfgState *fw_cfg)
 {
     PVPanicState *s = ISA_PVPANIC_DEVICE(dev);
+    uint16_t *pvpanic_port = g_malloc(sizeof(*pvpanic_port));
+    *pvpanic_port = cpu_to_le16(s->ioport);
 
-    fw_cfg_add_file(fw_cfg, "etc/pvpanic-port",
-                    g_memdup(&s->ioport, sizeof(s->ioport)),
-                    sizeof(s->ioport));
+    fw_cfg_add_file(fw_cfg, "etc/pvpanic-port", pvpanic_port,
+                    sizeof(*pvpanic_port));
 }
 
 int pvpanic_init(ISABus *bus)