From patchwork Wed Apr 24 12:44:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fam Zheng X-Patchwork-Id: 239196 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 921A82C00BC for ; Wed, 24 Apr 2013 22:49:20 +1000 (EST) Received: from localhost ([::1]:51404 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUz8Q-0000ID-Rx for incoming@patchwork.ozlabs.org; Wed, 24 Apr 2013 08:49:18 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUz4F-0002tX-JO for qemu-devel@nongnu.org; Wed, 24 Apr 2013 08:45:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UUz4C-0006wX-7D for qemu-devel@nongnu.org; Wed, 24 Apr 2013 08:44:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19103) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUz4B-0006wQ-U8 for qemu-devel@nongnu.org; Wed, 24 Apr 2013 08:44:56 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3OCitY9022971 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 24 Apr 2013 08:44:55 -0400 Received: from localhost.localdomain.com ([10.66.7.14]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r3OCieWI012945; Wed, 24 Apr 2013 08:44:53 -0400 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 24 Apr 2013 20:44:34 +0800 Message-Id: <1366807475-26350-6-git-send-email-famz@redhat.com> In-Reply-To: <1366807475-26350-1-git-send-email-famz@redhat.com> References: <1366807475-26350-1-git-send-email-famz@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, Fam Zheng , stefanha@redhat.com Subject: [Qemu-devel] [PATCH v3 5/6] vmdk: store fields of VmdkMetaData in cpu endian X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Previously VmdkMetaData.offset is stored little endian while other fields are cpu endian. This changes offset to cpu endian and convert before writing to image. Signed-off-by: Fam Zheng --- block/vmdk.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index 0463d3b..16e1417 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -813,14 +813,15 @@ static int get_whole_cluster(BlockDriverState *bs, static int vmdk_L2update(VmdkExtent *extent, VmdkMetaData *m_data) { + uint32_t offset; + QEMU_BUILD_BUG_ON(sizeof(offset) != sizeof(m_data->offset)); + offset = cpu_to_le32(m_data->offset); /* update L2 table */ if (bdrv_pwrite_sync( extent->file, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(m_data->offset)), - &(m_data->offset), - sizeof(m_data->offset) - ) < 0) { + &offset, sizeof(offset)) < 0) { return VMDK_ERROR; } /* update backup L2 table */ @@ -830,8 +831,7 @@ static int vmdk_L2update(VmdkExtent *extent, VmdkMetaData *m_data) extent->file, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(m_data->offset)), - &(m_data->offset), sizeof(m_data->offset) - ) < 0) { + &offset, sizeof(offset)) < 0) { return VMDK_ERROR; } } @@ -938,7 +938,7 @@ static int get_cluster_offset(BlockDriverState *bs, } if (m_data) { - m_data->offset = tmp; + m_data->offset = *cluster_offset; m_data->l1_index = l1_index; m_data->l2_index = l2_index; m_data->l2_offset = l2_offset;