@@ -426,23 +426,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': {
@@ -498,22 +507,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;
}
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 <aneesh.kumar@linux.vnet.ibm.com> --- hw/virtio-9p.c | 34 +++++++++++++++++++++++----------- 1 files changed, 23 insertions(+), 11 deletions(-)