From patchwork Sat Jun 4 00:40:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Feiran Zheng X-Patchwork-Id: 98703 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 32891B6FB5 for ; Sat, 4 Jun 2011 11:05:18 +1000 (EST) Received: from localhost ([::1]:50512 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSfIg-0005Yh-Ki for incoming@patchwork.ozlabs.org; Fri, 03 Jun 2011 21:05:14 -0400 Received: from eggs.gnu.org ([140.186.70.92]:34450) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSevH-0000Qv-Vr for qemu-devel@nongnu.org; Fri, 03 Jun 2011 20:41:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QSevG-00021r-LN for qemu-devel@nongnu.org; Fri, 03 Jun 2011 20:41:03 -0400 Received: from mail-pw0-f45.google.com ([209.85.160.45]:63364) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QSevG-00021l-9o for qemu-devel@nongnu.org; Fri, 03 Jun 2011 20:41:02 -0400 Received: by pwi6 with SMTP id 6so1340278pwi.4 for ; Fri, 03 Jun 2011 17:41:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:from:date:message-id:subject:to:cc :content-type; bh=KtNtMhCwW36mAUTMCz/I3jGisntxl62++W0cJCtILPM=; b=fLAx6gdwwROw3R0RUyImSuvcTNTgqHzZMs8Z1QYlgN31GCEWzu2YWFyzRbZJPaMYpf uJem9Yl9QwbVSQp/H07Ev4jOonIaK6zAJ8pZwgfrhMKrHyFEVi1i4Ns9FcRrPogd6ZDy /XmGUelMT2OT9bZG7fM55G1DK04/4iLTOa/8Y= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:cc:content-type; b=V20DOL2YGxuZCAvEVkapf92fuX6Av6h6ru5/wHNFQ3GXXOMqTpGA6xTKLMRlTybQjD qAvGUtTvrNOElYJMDCJu8mcP8LGuXs5UdsCQFwN9xSTRFGy3D7jiZhRSGRxUR70W0u56 rsIN03l/194S2R6E1eRRzjM1TJH+vkGcweAMg= Received: by 10.68.44.197 with SMTP id g5mr1021727pbm.509.1307148061111; Fri, 03 Jun 2011 17:41:01 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.59.164 with HTTP; Fri, 3 Jun 2011 17:40:41 -0700 (PDT) From: Fam Zheng Date: Sat, 4 Jun 2011 08:40:41 +0800 Message-ID: To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.160.45 Cc: Kevin Wolf , Stefan Hajnoczi , Christoph Hellwig Subject: [Qemu-devel] [PATCH 02/12] VMDK: bugfix, align offset to cluster in get_whole_cluster 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 In get_whole_cluster, the offset is not aligned, to cluster when reading from backing_hd. So if it's the first write to child and the offset is not the cluster boundary, data is copied from parent at a wrong position. Signed-off-by: Fam Zheng --- block/vmdk.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index 9442794..f787528 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -489,6 +489,8 @@ static int get_whole_cluster(BlockDriverState *bs, if (!vmdk_is_cid_valid(bs, extent)) return -1; + // floor offset to cluster + offset -= offset % (extent->cluster_sectors * 512); ret = bdrv_read(bs->backing_hd, offset >> 9, whole_grain, extent->cluster_sectors); if (ret < 0) {