From patchwork Wed Mar 3 19:01:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 46871 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BE5F9B7CE4 for ; Thu, 4 Mar 2010 06:41:22 +1100 (EST) Received: from localhost ([127.0.0.1]:58194 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NmuPD-0005bM-4Z for incoming@patchwork.ozlabs.org; Wed, 03 Mar 2010 14:38:51 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nmtpb-0007cz-Bb for qemu-devel@nongnu.org; Wed, 03 Mar 2010 14:02:03 -0500 Received: from [199.232.76.173] (port=60480 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NmtpZ-0007c9-V8 for qemu-devel@nongnu.org; Wed, 03 Mar 2010 14:02:02 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NmtpZ-0001cO-1N for qemu-devel@nongnu.org; Wed, 03 Mar 2010 14:02:01 -0500 Received: from e8.ny.us.ibm.com ([32.97.182.138]:35307) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NmtpY-0001cI-OO for qemu-devel@nongnu.org; Wed, 03 Mar 2010 14:02:00 -0500 Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by e8.ny.us.ibm.com (8.14.3/8.13.1) with ESMTP id o23Is73f031660 for ; Wed, 3 Mar 2010 13:54:07 -0500 Received: from d03av06.boulder.ibm.com (d03av06.boulder.ibm.com [9.17.195.245]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o23J1wIY120390 for ; Wed, 3 Mar 2010 14:01:58 -0500 Received: from d03av06.boulder.ibm.com (loopback [127.0.0.1]) by d03av06.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id o23J3mD2010420 for ; Wed, 3 Mar 2010 12:03:48 -0700 Received: from localhost.localdomain (sig-9-76-214-227.mts.ibm.com [9.76.214.227]) by d03av06.boulder.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id o23J3daO009640; Wed, 3 Mar 2010 12:03:47 -0700 From: Anthony Liguori To: qemu-devel@nongnu.org Date: Wed, 3 Mar 2010 13:01:12 -0600 Message-Id: <1267642874-15001-17-git-send-email-aliguori@us.ibm.com> X-Mailer: git-send-email 1.6.5.2 In-Reply-To: <1267642874-15001-1-git-send-email-aliguori@us.ibm.com> References: <1267642874-15001-1-git-send-email-aliguori@us.ibm.com> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: "Aneesh Kumar K.V" Subject: [Qemu-devel] [PATCH 15/17] virtio-9p: Use little endian format on virtio X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Aneesh Kumar K.V 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 --- 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; }