qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 15/17] virtio-9p: Use little endian format on virtio


From: Anthony Liguori
Subject: [Qemu-devel] [PATCH 15/17] virtio-9p: Use little endian format on virtio
Date: Wed, 3 Mar 2010 13:01:12 -0600

From: Aneesh Kumar K.V <address@hidden>

We need to use platform independent data format as
part of protocol data. 9P uses little endian format
on wire

Signed-off-by: Aneesh Kumar K.V <address@hidden>
---
 hw/virtio-9p.c |   34 +++++++++++++++++++++++-----------
 1 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 97fcb8a..65f5827 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -425,23 +425,32 @@ static size_t pdu_unmarshal(V9fsPDU *pdu, size_t offset, 
const char *fmt, ...)
     for (i = 0; fmt[i]; i++) {
        switch (fmt[i]) {
        case 'b': {
-           int8_t *valp = va_arg(ap, int8_t *);
+           uint8_t *valp = va_arg(ap, uint8_t *);
            offset += pdu_unpack(valp, pdu, offset, sizeof(*valp));
            break;
        }
        case 'w': {
-           int16_t *valp = va_arg(ap, int16_t *);
-           offset += pdu_unpack(valp, pdu, offset, sizeof(*valp));
+           uint16_t val, *valp;
+           valp = va_arg(ap, uint16_t *);
+           val = le16_to_cpupu(valp);
+           offset += pdu_unpack(&val, pdu, offset, sizeof(val));
+           *valp = val;
            break;
        }
        case 'd': {
-           int32_t *valp = va_arg(ap, int32_t *);
-           offset += pdu_unpack(valp, pdu, offset, sizeof(*valp));
+           uint32_t val, *valp;
+           valp = va_arg(ap, uint32_t *);
+           val = le32_to_cpupu(valp);
+           offset += pdu_unpack(&val, pdu, offset, sizeof(val));
+           *valp = val;
            break;
        }
        case 'q': {
-           int64_t *valp = va_arg(ap, int64_t *);
-           offset += pdu_unpack(valp, pdu, offset, sizeof(*valp));
+           uint64_t val, *valp;
+           valp = va_arg(ap, uint64_t *);
+           val = le64_to_cpup(valp);
+           offset += pdu_unpack(&val, pdu, offset, sizeof(val));
+           *valp = val;
            break;
        }
        case 'v': {
@@ -497,22 +506,25 @@ static size_t pdu_marshal(V9fsPDU *pdu, size_t offset, 
const char *fmt, ...)
     for (i = 0; fmt[i]; i++) {
        switch (fmt[i]) {
        case 'b': {
-           int8_t val = va_arg(ap, int);
+           uint8_t val = va_arg(ap, int);
            offset += pdu_pack(pdu, offset, &val, sizeof(val));
            break;
        }
        case 'w': {
-           int16_t val = va_arg(ap, int);
+           uint16_t val;
+           cpu_to_le16w(&val, va_arg(ap, int));
            offset += pdu_pack(pdu, offset, &val, sizeof(val));
            break;
        }
        case 'd': {
-           int32_t val = va_arg(ap, int);
+           uint32_t val;
+           cpu_to_le32w(&val, va_arg(ap, uint32_t));
            offset += pdu_pack(pdu, offset, &val, sizeof(val));
            break;
        }
        case 'q': {
-           int64_t val = va_arg(ap, int64_t);
+           uint64_t val;
+           cpu_to_le64w(&val, va_arg(ap, uint64_t));
            offset += pdu_pack(pdu, offset, &val, sizeof(val));
            break;
        }
-- 
1.6.5.2





reply via email to

[Prev in Thread] Current Thread [Next in Thread]